# Need help with State nodes. Trying to get the state of a Shelly 1 detached switch as trigger for a flow

**URL:** <https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [13 July 2022 00:25 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025 "2022-07-13T00:25:20Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![AgingTechNerd](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@AgingTechNerd](https://discourse.nodered.org/u/AgingTechNerd)\
**Post date:** [17 July 2022 22:32 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/21 "2022-07-17T22:32:29Z")

</div>

Thanks for this. I have imported them and tried them briefly. I will digest them tomorrow (reno in progress here at the moment).

As for the video I tried replying to your post that included it but I see it put my reply under that post but also at the bottom of the thread in progress. I was referring to post #12 15 Jul 01:10 the video:  
Node Red for Beginners - 2021 Edition (Using Home Assistant). Anyway he goes crazy fast at times. He was using the Call Service node which what I was looking for but he flew over them so fast. At least it made me aware of them and was able to get it working for my Garage Door red light Shelly module.

I was playing with the Current State Polling node last night and the exact syntax is not jumping out at me in the docs.

 ![Screen Shot 2022-07-17 at 6.18.47 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/511c3db1612d1f7437cdb2f0fba5c6e4c39f9ffb.png)

What settings do you think should I use?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [17 July 2022 23:49 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/22 "2022-07-17T23:49:48Z")

</div>

To work out what state it is reporting go into your home assistant main console

then go down to developer tools on the left hand menu

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f198972f581babecf8137a8b47b340c8463b5ff3.png)

In there you can then go to States in the top menu

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/27972e3c49286433b903ea015912ba5ffc3e9f9d.png)

From there you can see all your entities and what state they are in

Simply open and close one of the doors that the Shelley is attached to and you will see that state change - probably between on and off

Once you have this enttity and what state it changes between you can put it into the node

In the bottom section of that node you have the option to press the small add button

Add a new property - msg.topic and put in there Door1State (as an example)

These msg.topics are what triggers the boolean node that i showed you

I think you will find in one of the examples he posted that he used the Current state node rather than the call service node as well

Craig

---

<div class="post-metadata">

**Author:** ![AgingTechNerd](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@AgingTechNerd](https://discourse.nodered.org/u/AgingTechNerd)\
**Post date:** [19 July 2022 22:50 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/25 "2022-07-19T22:50:54Z")

</div>

Thanks, That all was a great help. I wracked my brains for a few more hours than I'm ashamed to admit. Your examples gave me the push I needed get through through these initial mental blocks. I just realised it's probably been over 20 years since I've done anything boolean to this level of detail.

So it's working now. Maybe not the prettiest flow that I'm sure I'll be able to refine at some point after I get HA to take over HomeSeer (probably 50% there now). I notice the lamp module relay clicks off for a brief fraction of a second when not all doors are open so I'll need to sort that out at some point. I've slowed the polling interval to 30 seconds just to save traffic and relay wear and tear.

 ![Garage Door Status red light as of 19 July 2022](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/63aeb4ebdf9778805e2a749db2c592ff521fcf10.png)

```auto
[{"id":"a4012a36144edec6","type":"inject","z":"f3065858ee281ed6","name":"Inject poll request every 10 seconds","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":190,"y":20,"wires":[["7976d22124690475","75043dcf67ad42ce","383535e4ee49913c","a77185f4a57db2a8"]]},{"id":"fa55b854dc59c73c","type":"change","z":"f3065858ee281ed6","name":"Change off (door open) to True","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"false","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":160,"wires":[["4540ccb1d03157ed"]]},{"id":"7976d22124690475","type":"api-current-state","z":"f3065858ee281ed6","name":"Door 1 status","server":"ee1bb5a.f1bd648","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.shelly1_58bf25d86793_input","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"Garage Door 1","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":100,"wires":[["e4cadaee927c9552"],["e4cadaee927c9552"]]},{"id":"75043dcf67ad42ce","type":"api-current-state","z":"f3065858ee281ed6","name":"Door 2 Status","server":"ee1bb5a.f1bd648","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.shelly1_e89f6d85c8b5_input","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"garage door 2","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":160,"wires":[["fa55b854dc59c73c"],["fa55b854dc59c73c"]]},{"id":"e4cadaee927c9552","type":"change","z":"f3065858ee281ed6","name":"Change off (door open) to True","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":100,"wires":[["4540ccb1d03157ed"]]},{"id":"4540ccb1d03157ed","type":"BooleanLogicUltimate","z":"f3065858ee281ed6","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"4","topic":"result","restrictinputevaluation":false,"delayEvaluation":0,"x":710,"y":180,"wires":[["2f3b95dc529aec5f"],["2f3b95dc529aec5f"],[]]},{"id":"7eaa68159eaf8083","type":"api-call-service","z":"f3065858ee281ed6","name":"Dining Room Red Lamp Turn on (a garage door is open)","server":"ee1bb5a.f1bd648","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_on","areaId":[],"deviceId":["117a514e077dcbe8cd7102b23c3353ba"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":530,"y":400,"wires":[[]]},{"id":"a9f8ecd40f5a614f","type":"inject","z":"f3065858ee281ed6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Manual turn_on","payloadType":"str","x":140,"y":400,"wires":[["7eaa68159eaf8083"]]},{"id":"d2ef636f5185fed8","type":"inject","z":"f3065858ee281ed6","name":"Manual turn_off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"turn_off","payloadType":"str","x":140,"y":440,"wires":[["3f3b9ef081720690"]]},{"id":"3f3b9ef081720690","type":"api-call-service","z":"f3065858ee281ed6","name":"Dining Room Red Lamp Turn off (all garage doors are closed)","server":"ee1bb5a.f1bd648","version":5,"debugenabled":false,"domain":"homeassistant","service":"turn_off","areaId":[],"deviceId":["117a514e077dcbe8cd7102b23c3353ba"],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":540,"y":460,"wires":[[]]},{"id":"2f3b95dc529aec5f","type":"change","z":"f3065858ee281ed6","name":"Change true to turn_on and false to turn_off","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"turn_on","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":180,"wires":[["dcaca20b24cc68c2"]]},{"id":"5330671a6c7768ac","type":"debug","z":"f3065858ee281ed6","name":"Is it sending a turn_on?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":400,"wires":[]},{"id":"dcaca20b24cc68c2","type":"switch","z":"f3065858ee281ed6","name":"Seperate turn_on and turn_off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"turn_on","vt":"str"},{"t":"eq","v":"turn_off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":300,"wires":[["5330671a6c7768ac","7eaa68159eaf8083"],["94708fc0c928154e","3f3b9ef081720690"]]},{"id":"94708fc0c928154e","type":"debug","z":"f3065858ee281ed6","name":"Is it sending a turn_off?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":460,"wires":[]},{"id":"83016d9a16e6131e","type":"change","z":"f3065858ee281ed6","name":"Change off (door open) to True","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"false","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":280,"wires":[["4540ccb1d03157ed"]]},{"id":"383535e4ee49913c","type":"api-current-state","z":"f3065858ee281ed6","name":"Door 3 status","server":"ee1bb5a.f1bd648","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.shelly1_e89f6d867d60_input","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"Garage Door 3","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":220,"wires":[["b25c93b93ef8cdd5"],["b25c93b93ef8cdd5"]]},{"id":"a77185f4a57db2a8","type":"api-current-state","z":"f3065858ee281ed6","name":"Door 4 Status","server":"ee1bb5a.f1bd648","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.shelly1_e89f6d85f316_input","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"garage door 4","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":280,"wires":[["83016d9a16e6131e"],["83016d9a16e6131e"]]},{"id":"b25c93b93ef8cdd5","type":"change","z":"f3065858ee281ed6","name":"Change off (door open) to True","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":220,"wires":[["4540ccb1d03157ed"]]},{"id":"ee1bb5a.f1bd648","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}]

```

My next task is to figure out how do some daily reminder announcements over Sonos...

Really appreciate all the help so far. I'm so glad I finally made some traction. May I call on you again if I hit another snag?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [19 July 2022 23:18 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/26 "2022-07-19T23:18:46Z")

</div>

Great to hear it is all working now - well done hanging in there and getting over the first hurdle !

Yep happy to help out if you have any more questions etc.

Maybe you can become the Home Assistant/Node Red Guru on here !

Craig

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [19 July 2022 23:21 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/27 "2022-07-19T23:21:17Z")

</div>

Just noticed - you do not need the 4 change nodes - there is an option in the boolean to accept the home assistant on and off states -

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c594d006fcd071b964e0842124fd9ed96b783bac.png)

Untick the option to Reject non boolean True/False input values

Craig

---

<div class="post-metadata">

**Author:** ![AgingTechNerd](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@AgingTechNerd](https://discourse.nodered.org/u/AgingTechNerd)\
**Post date:** [20 July 2022 16:22 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/28 "2022-07-20T16:22:58Z")

</div>

Thanks for this. I do have the Reject non boolean True/False input values unchecked but as I recall I needed to invert the door state outputs. The way I set up the sensors on the garage door openers ON=Closed OFF=Open. I did that so the Shelly Cloud app icons would show green when each door was closed.

 ![IMG_5029](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81f41ff90457c4ecdcf050d68ca454da88861de2.jpeg)

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [20 July 2022 23:04 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/29 "2022-07-20T23:04:52Z")

</div>

Aah right that makes more sense then.

Craig

---

<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:** [12 August 2022 18:30 UTC](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025/33 "2022-08-12T18:30:23Z")

</div>

Closed on 12 August 2022 18:30 UTC

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

[Previous page](https://discourse.nodered.org/t/need-help-with-state-nodes-trying-to-get-the-state-of-a-shelly-1-detached-switch-as-trigger-for-a-flow/65025.md?page=1)
