Home Assistant Community

Next device alarm in Node Red

#1

I’m trying to use the Ariela app’s mqtt sensor that sends the next due alarm with node red.

trigger:
minutes: /1
platform: time
seconds: 0
condition:
condition: template
value_template: '{{ (((as_timestamp(now()) | int) + 3*60) | timestamp_custom("%Y-%m-%d %H:%M:00")) == states.sensor.android_device_next_alarm.state }}'
action:
data:
  entity_id: scene.wakeup
service: scene.turn_on

I’m new to node-red and I can’t seem to figure out the best way about this, has anyone else done this? How do I compare the time/date the sensor gives to the current time/date

#2

[{"id":"5d03a6d4.d2b098","type":"moment","z":"ffbd7f06.4a014","name":"","topic":"","input":"","inputType":"msg","inTz":"America/Los_Angeles","adjAmount":0,"adjType":"days","adjDir":"add","format":"Y-MM-DD HH:mm:00","locale":"en_US","output":"date","outputType":"msg","outTz":"America/Los_Angeles","x":308,"y":448,"wires":[["d346d4e0.8a30f8"]]},{"id":"fe6b9853.eeb818","type":"inject","z":"ffbd7f06.4a014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/1 0-23 * * *","once":false,"onceDelay":0.1,"x":118,"y":448,"wires":[["5d03a6d4.d2b098"]]},{"id":"d346d4e0.8a30f8","type":"api-current-state","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.android_device_next_alarm","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","x":622,"y":448,"wires":[["4becaece.37fd"]]},{"id":"4becaece.37fd","type":"switch","z":"ffbd7f06.4a014","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"date","vt":"msg"}],"checkall":"true","repair":false,"outputs":1,"x":882,"y":448,"wires":[["9e83b60c.b47d08"]]},{"id":"9e83b60c.b47d08","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","service_domain":"scene","service":"turn_on","data":"{\"entity_id\":\"scene.wakeup\"}","mergecontext":"","output_location":"","output_location_type":"none","x":1050,"y":448,"wires":[[]]}]
#3

Could also just use a get template node to compare the dates within Home Assistant.

[{"id":"527499f5.6f6b38","type":"api-render-template","z":"ffbd7f06.4a014","name":"compare","server":"2dad33ee.42bf5c","template":"{{ (((as_timestamp(now()) | int) + 3*60) | timestamp_custom(\"%Y-%m-%d %H:%M:00\")) == states.sensor.android_device_next_alarm.state }}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"","templateLocationType":"none","x":428,"y":480,"wires":[["1d2f7b1f.d5fa25"]]},{"id":"1d2f7b1f.d5fa25","type":"switch","z":"ffbd7f06.4a014","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":562,"y":480,"wires":[["8dc86a83.9aa508"]]},{"id":"d173413c.7f95b","type":"inject","z":"ffbd7f06.4a014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/1 0-23 * * *","once":false,"onceDelay":0.1,"x":278,"y":480,"wires":[["527499f5.6f6b38"]]},{"id":"8dc86a83.9aa508","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","service_domain":"scene","service":"turn_on","data":"{\"entity_id\":\"scene.wakeup\"}","mergecontext":"","output_location":"","output_location_type":"none","x":730,"y":480,"wires":[[]]}]
#4

Perfect! thank you very much for that