Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template not being evaluated after update to 18.1.1 #1968

Closed
1liminal1 opened this issue Oct 5, 2024 · 6 comments
Closed

Template not being evaluated after update to 18.1.1 #1968

1liminal1 opened this issue Oct 5, 2024 · 6 comments

Comments

@1liminal1
Copy link

Problem/Motivation

After the update, it now just reads out the message and no longer evaluates the template

Expected behavior

It should evaluate the template and give the correct options

Actual behavior

It just reads out the entire string

Steps to reproduce

input node

Here is a screen shot of the node;

image

Here is the message json

{
   "message":"[{% set door = is_state('binary_sensor.balcony_door_sensor', 'on') %}  {% set bdoor = is_state('binary_sensor.bedroom_balcony_door', 'on') %}  {% set window = is_state('binary_sensor.second_bedroom_window', 'on') %}  {% if door and window and bdoor %}  Please close both balcony doors and the bedroom window? {% elif door and window %}  Please close the balcony door and the bedroom window? {% elif bdoor and window %}  Please close the bedroom balcony door and the bedroom window? {% elif bdoor and door %}  Please close both balcony doors? {% elif window %} Please close the bedroom window?  {% elif door %} Please close the balcony door?  {% elif bdoor %} Please close the bedroom balcony door? {% endif %}]",
   "data":{"type":"announce", "method":"speak"},
   "target":[
       "media_player.bathroom_spot",
       "media_player.bedroom_show",
       "media_player.living_room_show",
       "media_player.kitchen_show"
   ]
}

Proposed changes

Bug?

@1liminal1 1liminal1 changed the title Template not being evaluated after update to 4.0.3 Template not being evaluated after update to 18.1.1 Oct 5, 2024
@3ative
Copy link

3ative commented Oct 5, 2024

Seconded.
For a workaround I've had to grab a "Global Get" and substitute a variable.
Prior to update, this worked fine:

msg.payload =
    "The temperature is " + "{{states.sensor.bedroom_temperature.state}}"
return msg

Now only this works:

var state = global.get('homeassistant').homeAssistant.states["sensor.bedroom_temperature"].state
msg.payload =
    "The temperature is " + state 
return msg

@3ative
Copy link

3ative commented Oct 5, 2024

I found the Render Template Node still works:
TP-Node-Tester

So it seems: {{states.sensor.bedroom_temperature.state}} IS a valid way to get an entity's State/Value/Etc. It's just not getting evaluated elsewhere like it always was.

@frenck
Copy link
Member

frenck commented Oct 5, 2024

So it seems: {{states.sensor.bedroom_temperature.state}} IS a valid way to get an entity's State/Value/Etc

It is strongly discouraged. Don't use that.

@1liminal1
Copy link
Author

Seconded. For a workaround I've had to grab a "Global Get" and substitute a variable. Prior to update, this worked fine:

How do you make that work?

@1liminal1
Copy link
Author

It is strongly discouraged. Don't use that.

Um, thanks...

Is this a you thing, or a node red thing. Why is this now broken?

I understand you're busy, but Im sure a lot of people are using templating in Node Red.

@1liminal1
Copy link
Author

I have no idea what frenck was trying to say, but the render template works. And its an issue with HA core, not Node Red anyway.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants