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

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.

What settings do you think should I use?

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

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

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

1 Like

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.

[{"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?

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

1 Like

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

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

Craig

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.

Aah right that makes more sense then.

Craig

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