Closed parautenbach closed 2 years ago
template documentation template source (message by IssueLinks)
Hey there @phracturedblue, @tetienne, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (template
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
I believe this is still an issue. Any response (comments) on this issue would be appreciated.
The sensor in your example is not a "new style template sensor", it's a trigger-based template sensor: https://www.home-assistant.io/integrations/template/#trigger-based-template-sensors Such sensors will only update when the trigger fires, as explained in the documentation.
You need to make the sensor trigger on its own state.
You need to make the sensor trigger on its own state.
Do you mean like this?
template:
- trigger:
- platform: event
event_type: amcrest
event_data:
event: CallNoAnswered
payload:
action: Start
- platform: state
entity_id: binary_sensor.doorbell_rang
to: "on"
binary_sensor:
name: Doorbell Rang
icon: "{{ 'mdi:bell-ring-outline' if is_state('binary_sensor.doorbell_rang', 'on') else 'mdi:bell-outline' }}"
state: true
auto_off: 5 # seconds
@parautenbach yes, something like that.
You probably need a trigger also when changing to the off state. In the next release of Home Assistant (2022.2) you can instead do like this to trigger on any state change (but not attribute change)
- platform: state
entity_id: binary_sensor.doorbell_rang
to: ~
You probably need a trigger also when changing to the off state.
Indeed! Thanks for catching that.
I'm thinking of submitting a change/example for the docs too to make this way of making the icon dynamic a bit more apparent.
The problem
When defining a new style template sensor, it isn't possible to self reference the sensor in the icon template. A related issue referring to the old style has been logged and resolved before. By not allowing this, the only alternative is to create an intermediate helper sensor, which seems unnecessary.
What is version of Home Assistant Core has the issue?
core-2021.9.7
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Template
Link to integration documentation on our website
https://www.home-assistant.io/integrations/template/
Example YAML snippet