# Sensor.time comparison for trigger

**URL:** <https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170>\
**Category:** General\
**Created:** [28 May 2022 06:30 UTC](https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170 "2022-05-28T06:30:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [28 May 2022 06:30 UTC](https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170/1 "2022-05-28T06:30:10Z")

</div>

Hi there,  
I want to add a time condition to a trigger node. Meaing, the trigger should only triggers within or after a certain time of the day. Could this be done by adding a 2nd condition with the sensor.time? But how to compare those values to my time window?  
Does anybody has any glue / advice? Thank you.

Dave

```auto
[{"id":"6dcfc4887aa56637","type":"trigger-state","z":"a5f2299564d70994","name":"Rain?","server":"a11aa034.815b8","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.regen","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"entity_id","targetValue":"sensor.time","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":">","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":800,"y":1167.5,"wires":[[],[]]},{"id":"a11aa034.815b8","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}]

```

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [28 May 2022 07:00 UTC](https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170/2 "2022-05-28T07:00:41Z")

</div>

Use a switch node or another filter node which blocks the trigger node if time is not correct.

---

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [28 May 2022 08:54 UTC](https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170/3 "2022-05-28T08:54:54Z")

</div>

Thanks, yes that's what I am doing right, just want it to simplify and just combine the conditions into one node instead of having multiple conditions in a flow. JJ

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 June 2022 08:55 UTC](https://discourse.nodered.org/t/sensor-time-comparison-for-trigger/63170/4 "2022-06-11T08:55:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
