I am trying to remove all the [homeassistant.components.binary_sensor.template] Could not render template... from the HASS log file, but I have been unable to use the is_state() function. How are you HASS users checking attribute values?
This is an example of the statement which litters the log file with the above messages: {{ states.sensor.alarm_keypad.attributes.alarm }}
I get an unknown value when I do: {{ states("sensor.alarm_keypad.attributes.alarm" }}
or {{ is_state("sensor.alarm_keypad.attributes.alarm", "true") }}
NOTE: states.sensor.alarm_keypad.attributes.alarm is boolean.
is_state won’t check for an attribute, it will only check for state.
If sensor.alarm_keypad exists in the entity list, and if that entity has the attribute alarm, then the template {{ states.sensor.alarm_keypad.attributes.alarm }} will render without errors.
Travis,
The sensor.alarm_keypad does exists in the entity list and the template does work as expected in my automations/alerts. However, it still generates errors on startup of HASS. This would indicate a race condition where these binary sensors templates are evaluated before the referenced entity is created. So the next question is, is there an order in which these entities should be added?
Here is the section of the binary sensor template:
Oh, so it works fine after HA is loaded? That happens with several of my value templates. Some sensors have “null” or nothing for their states at boot, I get this error, then a few min later they populate and it’s fine.
I would like to make a switch which reflects a alarm sensor attribute state (true = switch on + call script, false = switch off + call service). I have {{ state_attr('sensor.business_keypad', 'chime') }} which gives me true/false output. How do I combine this with is_state()?