But the template isn’t working any different for the “unexpected” error that you just posted. The old editor would have done the same thing.
Hello
i tried to automate my switch with template, it can run if i hit manually but cant run auto. kindly pls how solve it.
platform: template
value_template: >-
{{ as_timestamp(strptime(states(“sensor.time_date”), “%H:%M, %Y-%m-%d”)) ==
as_timestamp(strptime(states(“sensor.asr_prayer”), “%Y-%m-%dT%H:%M:%S”)) - 300
}}
service: switch.turn_on
entity_id: ‘switch.bel_guru, switch.bel_aspura, switch.bel_rusunawa’
i got this error in logs :
The ‘entity_id’ option is deprecated, please remove it from your configuration
Can you surround your yaml with three back-ticks before and after? It’ll format it in a monospace font, and spacing is important in yaml. Eg:
This is monospaced and
leading spaces will be preserved.
Hi there, my be i have done logic mistake. could you possible to help me? I think my code problem is about entities.
Im trying to do thermostat. How can i do when i use 2 nodemcu? im using one for temperature measurement… other for controlling heater… 2 device is different point of my house. but they are in the same wireless hub… two of them working well know, but I couldnt do thermostat
Happy to try to help, but I think you’re best of creating a new post and add information about your system, settings and configuration you tried.
actually i did already :slight_smile
This really isn’t an error. You no longer need the entity_id
in your sensor
or binary_sensor
templates that are in your configuration files. This isn’t keeping your automation from running - there’s likely some other error in the trigger
if you can run it from the developer/service tool (assuming that’s what you mean when you state you can run it manually).
To eliminate this error, simply comment them out in your config files templates - HA now figures it out when to update the sensor/binary_sensor
without the added overhead of the entity_id
.
Please follow @SteveDinn’s instructions by re-posting but with the requested formatting. For example, copying and pasting your provided code in the proper format looks like this:
platform: template
value_template: >-
{{ as_timestamp(strptime(states(“sensor.time_date”), “%H:%M, %Y-%m-%d”)) ==
as_timestamp(strptime(states(“sensor.asr_prayer”), “%Y-%m-%dT%H:%M:%S”)) - 300
}}
service: switch.turn_on
entity_id: ‘switch.bel_guru, switch.bel_aspura, switch.bel_rusunawa’
Looking at this way shows a problem with spacing (and YAML is VERY sensitive to spacing!). Additionally, this isn’t complete - assuming it is within an automation, you need an action:
section and maybe a condition:
section depending on what you are trying to do.
Please post the complete automation and then we can help more (starting with the alias
line through the action
section.
Additionally, you can test the template in the developer/template tool - I use that almost every time…
Hey @petro – I was using the code you recommended for the making a sensor that would tell me which alexa was the last one spoken to…
- platform: template
sensors:
last_alexa:
entity_id:
- media_player.exercise_room_echo
- media_player.garage_dot
- media_player.kitchen_echo_show
- media_player.livingroom_dot
- media_player.master_bedroom_dot
- media_player.office_dot
value_template: >
{{ states.media_player | selectattr('attributes.last_called', 'eq', True) | map(attribute='entity_id') | first }}
How do you recommend removing the entity_id from this code? I know it’s using it as a reference point in the value template. I’m fairly new at this and have tried a couple things and have yet to come up with a viable solution on my own.
Thanks for any info
I don’t think this is needed anymore, the alexa media player now offers the last spoken device as a media_player. Check your states list.
Thanks, I’ll look into that now!
Did not find one in the states list, however I just looked at their wiki page and they show to correct the issue… Thanks again for the quick reply and for reference if anyone else sees this and is curious here is what it says
Home Assistant 115.x breaking changes - “remove entity_id option from your templates, as it is now deprecated.”
An easy fix is to create a group of your alexa devices and then use a template sensor to evaluate the group.
group:
echos:
name: Echomania
entities:
- media_player.this_echo
- media_player.that_echo
- media_player.his_echo_show
- media_player.her_echo_show
- platform: template
sensors:
last_alexa:
value_template: >
{{ expand(states.group.echos) | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}
Then how would I have to adjust this best, thank you very much.
washing_machine_status:
entity_id:
- input_select.washing_machine_status
value_template: '{{ states.input_select.washing_machine_status.state}}'
friendly_name: 'Waschmaschine'
like this:
washing_machine_status:
value_template: '{{ states.input_select.washing_machine_status.state}}'
friendly_name: 'Waschmaschine'
Hi all, I also have this error in my logs and I have found which template sensor is causing the issue.
Please see below code (it’s a sensor to display all unavailable items). The sensor is still working, but it is still showing my blacklisted items since this error.
- platform: template
sensors:
unavailable_entities:
entity_id: sensor.time
friendly_name: Unavailable Entities
unit_of_measurement: items
icon_template: >
{% if states('sensor.unavailable_entities')|int == 0 %} mdi:check-circle
{% else %} mdi:alert-circle
{% endif %}
value_template: >
{{states|selectattr('state', 'in', ['unavailable','unknown','none'])
|reject('in', expand('group.entity_blacklist'))
|reject('eq', states.group.entity_blacklist)
|reject('eq', states.group.alexamailtts)
|reject('eq', states.group.hsfangroup)
|reject('eq', states.group.hslightgroup)
|list|length}}
attribute_templates:
entities: >
{{states|selectattr('state', 'in', ['unavailable','unknown','none'])
|reject('in', expand('group.entity_blacklist'))
|reject('eq' , states.group.entity_blacklist)
|reject('eq' , states.group.alexamailtts)
|reject('eq' , states.group.hsfangroup)
|reject('eq' , states.group.hslightgroup)
|map(attribute='entity_id')|list|join(', ')}}
If I remove entity_id, the sensor is not updated anymore. I tried to find the answer elsewhere, but couldn’t find it. Can anyone please help me with this one. Thanks!
That’s not true, that template will update once a minute at least.
Indeed. Although I use a similar sensor and once a minute isn’t good enough, so I use an automation that triggers on every state change in the system, with a condition that the state change was either from or to ‘unavailable’, ‘unknown’ or ‘none’ and an action that calls update_entity. Works well.
Well his template uses states
which is throttled to at least once a minute. So if he has states that are changing all the time, it’ll pretty much update once a minute.
Yeah, I know, I’m just saying that you can make it update more frequently if desired by using an automation.
And that it probably is desired, because that’s the whole point of the sensor.
Well, he’s going from once a minute with sensor.time to at least once a minute without it. I was just trying to let him know that it will update.
Ha, I can’t help but think we’re talking cross purposes for some reason.
He’s saying that he wanted it to update every minute.
He then said that if he removed entity_id it wouldn’t, which is false.
You corrected him by saying that it will continue to update once a minute, which is true.
I was adding to both of you that this sensor actually should be updated every time the states change otherwise it’s not actually doing what it’s designed to do (ie - monitor entities that go unavailable) so to achieve that goal you need an automation.
If the sensor updates every minute, you could have entities going unavailable for 59 seconds at a time without it ever registering on the sensor.