# Store Binary Sensor Status and check it at certain time

**URL:** <https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767>\
**Category:** General\
**Created:** [17 March 2021 10:38 UTC](https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767 "2021-03-17T10:38:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![katya](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@katya](https://discourse.nodered.org/u/katya)\
**Post date:** [17 March 2021 10:38 UTC](https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767/1 "2021-03-17T10:38:29Z")

</div>

I have a sensor that sends an MQTT message when it is open and closed. Which node should I use to update the sensor status and store this information whether its open or closed?

I want to check if the sensor status is open at 2pm and if it is then I want to send a msg.payload. Will I need another node for this action?

🙂

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 March 2021 10:57 UTC](https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767/2 "2021-03-17T10:57:48Z")

</div>

when incoming mqqt sensor value is received save the payload to context store. Then use inject node or another timer node to retrieve context stored value at 02:00 and check if open.  
e.g.

```auto
[{"id":"32730060.fd6438","type":"inject","z":"5a245aa1.510164","name":"simulate mqtt node input closed","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"closed","payloadType":"str","x":280,"y":2680,"wires":[["f06bb65c.dd7ea"]]},{"id":"f06bb65c.dd7ea","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"sensor_blah","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":2700,"wires":[[]]},{"id":"5d9398b6.afb928","type":"inject","z":"5a245aa1.510164","name":"simulate mqtt node input open","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"open","payloadType":"str","x":270,"y":2720,"wires":[["f06bb65c.dd7ea"]]},{"id":"74d2aa8d.c95f6c","type":"inject","z":"5a245aa1.510164","name":"at 02:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 02 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":2600,"wires":[["e161fa25.fbe788"]]},{"id":"e161fa25.fbe788","type":"switch","z":"5a245aa1.510164","name":"","property":"sensor_blah","propertyType":"flow","rules":[{"t":"eq","v":"open","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":2600,"wires":[["43216397.c9cc14"]]},{"id":"43216397.c9cc14","type":"debug","z":"5a245aa1.510164","name":"do something","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":2600,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![katya](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@katya](https://discourse.nodered.org/u/katya)\
**Post date:** [17 March 2021 11:14 UTC](https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767/3 "2021-03-17T11:14:37Z")

</div>

THANKS SO MUCH!

I should be able to get it working now!

---

<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:** [31 March 2021 11:15 UTC](https://discourse.nodered.org/t/store-binary-sensor-status-and-check-it-at-certain-time/42767/4 "2021-03-31T11:15:14Z")

</div>

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