They told me that I don’t understand.
They told me that it is impossible.
They made me understand that enough is enough and I should stop talking nonsense.
Here is my binary_sensor:
binary_sensor:
- platform: template
sensors:
test_for_petro:
friendly_name: Test for Petro
device_class: power
value_template: >
{{ is_state('binary_sensor.smoke_1','on') }}
According to the documentation linked bellow, the template can only be true or false. Nothing else, that is impossible
I quote:
If you are using the state of a platform that might not be available during startup, the Template Sensor may get an
unknown
state. To avoid this (…). The same would apply to theis_state()
function. You should replace{{ states.switch.source.state == 'on' }}
with this equivalent that returnstrue
/false
and never gives anunknown
result:{{ is_state('switch.source', 'on') }}
And this is exactly what I did, using is_state
to never have an unknown
status not even at startup.
But look:
Zoom
What do you see between 13:57:09 and 13:58:37?
Yes! You’re right! Unknown value.
But…, but…, that is not possible, the documentation is clear “returns true
/false
and never gives an unknown
result:”
They told me that it was HA unable to render the template.
Once again, that can’t be the reason, even if I put rubbish as sensor, it is still rendering:
There must be something in the log according to them, here is the log at that time:
Error on retrieving data: empty response
14:12:27 – (WARNING) waze_travel_time - message first occurred at 14:02:28 and shows up 2 times
Unable to ping Kodi via websocket
14:11:22 – (WARNING) kodi - message first occurred at 13:59:23 and shows up 4 times
hci0 (C9:18:FB:E4:C9:1A): Error stopping scanner: [org.bluez.Error.Failed] No discovery started
14:01:38 – (ERROR) bluetooth
Update of sensor.ical_agenda_d_olivier_event_0 is taking over 10 seconds
13:57:38 – (WARNING) helpers/entity.py
Unable to find referenced entities switch.sonoff_1000d4aac6_1 or it is/they are currently not available
13:56:32 – (WARNING) helpers/service.py
Error while executing automation automation.gateway_tradfri_sonoff: Template rendered invalid service:
13:56:32 – (ERROR) automation
Gateway TRADFRI - Sonoff: Error executing script. Error for call_service at pos 1: Template rendered invalid service:
13:56:32 – (ERROR) automation
Can’t see anything related to my binary_sensor, nor the sensor smoke_1
it is based on here.
So, for sure, that transition to/from unknown is in the logbook, right? No, it is not.
So, is_state
is robust as it is always rendering but, it is not always true
or false
.
Is it a problem? Yes, because I made some automation triggered on state going to off
that are triggered when unknown
is back to off
.
Should I open an issue on the Github of HomeAssistant?