Basically I’m trying to make a template that will allow me to make an automation that will ‘catch’ a failed attempt at arming the alarm and will be able to eventually report back over TTS why the house alarm hasn’t been able to arm.
respectively. Which confuses me. In addition, in developer view open_sensors shows ‘null’ rather than none. I tried null too and that still returns as false.
@frenck do you think I should log this as a bug? I think it has to do with the value of the sensor being ‘null’ which is probably messing up the logic ?
Hmm… What happens if you have a sensor open.
Does it report a number or the name of the sensor that is open.
Perhaps you can do a reverse check?
Is open_sensors >= 1?
Interestingly, it doesn’t actually seem to be reporting the open_sensors. @neliss do you know if this is something I’m doing wrong or just something the platform doesn’t yet support (but some of the code is there ready for when it does?) Cheers!
You can’t use is_state_attr() on attributes when checking for none because the logic will always return false if the attribute is not populated (I.E. none).
I’m wondering if open_sensorsonly takes on a value if the alarm is armed? Because my alarm is disarmed right now, lots of sensors are ‘open’ - and open_sensors is still ‘null’
I can’t use the notification editor because I want to ultimately create an automatic TTS announcement - so I’m guessing I’d have to do this using the actions editor and rig up some input_booleans?
open_sensors is only populated when you try to arm but it failed (the problematic sensors are listed) or when the alarm is triggered (the sensor that triggered is listed).
So it is not surprising that the data is empty when the system is disarmed.
Works a TREAT setting up the Google TTS as a NOTIFY service then targeting that from Alarmo. Generates a nice MP3 with details of which sensors are preventing the arming!
This topic has helped me solve a long-standing issue with some template sensors. I think I found a bug but I don’t know enough about templates to know for sure.
Here is a simplified use case that demonstrates the issue:
{% if 1 == 1 %}
Result
{% else %}
None
{% endif %}
As expected, Result is returned. But…
{% if 1 == 2 %}
Result
{% else %}
None
{% endif %}
does not work. If I change ‘None’ to anything else, it does work.
{% if 1 == 2 %}
Result
{% else %}
None.
{% endif %}
works.
{% if 1 == 2 %}
Result
{% else %}
none
{% endif %}
works. Only ‘None’ fails. The sensors worked in the past but sometime in the last few months, they quit.
It’s not a bug, None is a keyword in jinja that means ‘nothing’. Typically setting a sensor to none will cause an error. Use ‘unknown’ or ‘unavailable’ instead.
because ‘==’ is used to check if a state to state_attr has an explicit value (or not), while the check for none is an existence check ? At least that’s how I always make the difference between the 2. Example in most of the automations where this is relevant:
{{trigger.to_state is not none and
trigger.from_state is not none and
trigger.to_state.state != trigger.from_state.state}}
while also checking:
{{trigger.to_state.state != 'unavailable' and
trigger.from_state.state != 'unavailable'}}