Compare timestamps

Hi,

I want to start a flow based on the time set in an input_datetime, which can be changed via the HA GUI.
So I need to compare sensor.time with input_datetime.pool_start_time but it is always true.
I’m comparing state_type string, which is not working.
Isn’t there a state_type timestamp?
Or even a complete different solution to start the flow based on an input_datetime.

Here is my folw

[{"id":"cfd380fa.130c98","type":"api-current-state","z":"964574f3.5f4d","name":"","server":"969aa5f8.2b8818","version":1,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"is","override_topic":false,"entity_id":"input_datetime.pool_start_time","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":220,"wires":[["a99b2c03.c88488"],["ad8fc635.4920f"]]},{"id":"969aa5f8.2b8818","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

update:
I changed the “State Location” from the surrent state node to a different msg. the pyload, now it’s actually comparing sensor.time with input_datetime.pool_start_time
but it’s always false as the sting from the sensor.time is 23:54 and the input_datetime.xxx is 23:54:00
which is not the same…
So the flow is now working as it should but not as I wanted it to.

the new folw

[{"id":"cfd380fa.130c98","type":"api-current-state","z":"964574f3.5f4d","name":"","server":"969aa5f8.2b8818","version":1,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"is","override_topic":false,"entity_id":"input_datetime.pool_start_time","state_type":"str","state_location":"pool_start_time","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":220,"wires":[["a99b2c03.c88488"],["ad8fc635.4920f"]]},{"id":"969aa5f8.2b8818","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

cheers

I am using a slightly different way to achieve the same. Maybe it works for you too:

For me I want it to trigger 10min earlier, but you can simply just remove this.
It is triggered by a timestamp on interval every minute.

[{"id":"5fd4bf94.3d203","type":"join","z":"1de400c0.5ce76f","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":810,"y":180,"wires":[["3baa06b3.7b18fa"]]},{"id":"3baa06b3.7b18fa","type":"function","z":"1de400c0.5ce76f","name":"Compare Times","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"x":960,"y":180,"wires":[["69f8941b.a2457c"]]},{"id":"69f8941b.a2457c","type":"switch","z":"1de400c0.5ce76f","name":"Is it Time?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1120,"y":180,"wires":[["1123ea0c.e5c056"]]},{"id":"cb3ff133.0f556","type":"api-current-state","z":"1de400c0.5ce76f","name":"Get Alarm Time","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_datetime.alarm","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":120,"wires":[["ed1570d4.2671d"]]},{"id":"ed1570d4.2671d","type":"moment","z":"1de400c0.5ce76f","name":"Alarm - 10min","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"10","adjType":"minutes","adjDir":"subtract","format":"YYYY-MM-DD HH:mm","locale":"C","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":640,"y":120,"wires":[["5fd4bf94.3d203"]]},{"id":"c2b4d347.fde2","type":"moment","z":"1de400c0.5ce76f","name":"Current Time","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"0","adjType":"minutes","adjDir":"subtract","format":"YYYY-MM-DD HH:mm","locale":"C","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":630,"y":180,"wires":[["5fd4bf94.3d203"]]}]
1 Like

with you input I managed to kick of my flow based on input_datetime.

here is the working flow

[{"id":"a43add40.62c578","type":"server-state-changed","z":"964574f3.5f4d","name":"time now","server":"969aa5f8.2b8818","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.time","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":580,"y":280,"wires":[["841c069f.dd4b7","cfd380fa.130c98"]]},{"id":"cfd380fa.130c98","type":"api-current-state","z":"964574f3.5f4d","name":"pool start time","server":"969aa5f8.2b8818","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_datetime.pool_start_time","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":780,"y":320,"wires":[["5f2e789e.2866f"]]},{"id":"841c069f.dd4b7","type":"moment","z":"964574f3.5f4d","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Vienna","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"de_AT","output":"payload","outputType":"msg","outTz":"Europe/Vienna","x":770,"y":240,"wires":[["f64643f4.ef03a8"]]},{"id":"5f2e789e.2866f","type":"moment","z":"964574f3.5f4d","name":"format time","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Vienna","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"de_AT","output":"payload","outputType":"msg","outTz":"Europe/Vienna","x":990,"y":320,"wires":[["f64643f4.ef03a8"]]},{"id":"f64643f4.ef03a8","type":"join","z":"964574f3.5f4d","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1150,"y":280,"wires":[["a58e955.579ff68"]]},{"id":"a58e955.579ff68","type":"function","z":"964574f3.5f4d","name":"Compare Times","func":"newmsg = {};\nif (msg.payload[0] == msg.payload[1]) {\n    newmsg.payload = \"True\";\n} else {\n    newmsg.payload = \"False\";\n}\n\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1320,"y":280,"wires":[["48cfa9fa.20b99"]]},{"id":"48cfa9fa.20b99","type":"switch","z":"964574f3.5f4d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1490,"y":280,"wires":[["9d53a303.8b1ce8"]]},{"id":"9d53a303.8b1ce8","type":"api-call-service","z":"964574f3.5f4d","name":"start pool pump","server":"969aa5f8.2b8818","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.pool_pump","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1660,"y":280,"wires":[[]]},{"id":"969aa5f8.2b8818","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

thanks a lot!