This is really strange, at least to me.
I have a template sensor that translates the next_alarm sensor to a more friendly state (today xx:xx, tomorrow xx:xx and so on).
But when there is no alarm set it says “no alarm”.
I can get Node red to trigger on all states except “no alarm”. I don’t get it…
I have tried both events state node and trigger state node:
Both are “clean” in the settings
But they don’t react to “no alarm”
[{"id":"93d71aa4f4f8f075","type":"server-state-changed","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.alarm_andreas","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":190,"y":1180,"wires":[["28d066513a7f18fd","6853f103260afe37"]]},{"id":"4832ad88dee432e4","type":"trigger-state","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.alarm_andreas","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":180,"y":1260,"wires":[["6853f103260afe37"],[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
The sensor is a template sensor and looks like this:
- platform: template
sensors:
alarm_andreas:
friendly_name: "Alarm Andreas"
value_template: >-
{% set day = { 'Monday':'Måndag', 'Tuesday':'Tisdag', 'Wednesday':'Onsdag', 'Thursday':'Torsdag', 'Friday':'Fredag', 'Saturday':'Lördag', 'Sunday':'Söndag' } %}
{% set fullformat = '%Y-%m-%d %H:%M' %}
{% set timeformat = '%H:%M' %}
{% set timestamp = (state_attr('sensor.andreas_next_alarm', 'Time in Milliseconds') |int(0) /1000) | int %}
{% if states('sensor.andreas_next_alarm') == 'unavailable' %}
Inget alarm
{% elif timestamp | timestamp_custom('%Y-%m-%d', true) == (as_timestamp(states.sensor.date.state)+ (86400)) | timestamp_custom("%Y-%m-%d",true)%}
Imorgon {{ timestamp | timestamp_custom(timeformat, true) }}
{% elif (1+ (timestamp - now().timestamp() | int) / 86400) | int == 1 %}
Idag {{ timestamp | timestamp_custom(timeformat, true) }}
{% elif (1+ (timestamp - now().timestamp() | int) / 86400) | int <= 7 %}
{{ day[timestamp | timestamp_custom("%A",true)] }} {{ timestamp | timestamp_custom(timeformat, true) }}
{% else %}
{{ timestamp | timestamp_custom(fullformat, true) }}
{% endif %}
Can anyone see why Node red would just ignore the state change to “Inget alarm” (No alarm)