Light control with Shellys

Hello everyone, I have 4 shellys at home. Now I have 3 switches for 3 lights each. In addition, I have 1 switch at the entrance. When I enter the building (and press the switch at the entrance) then only one lamp should switch on (so 1 Shelly reacts)! and that only when it is dark (I don't have a brightness sensor yet, maybe someone else has an idea.)

When I leave the building again and I press the switch at the entrance, all Shellys that are switched on should switch off.

Does anyone have an idea how I can solve this with Nodered?

Many Thanks!!

For me it is not clear how this switch should determine whether you are entering or leaving your home.

I have 3 switches in the room for 3 different lights. At the entrance I also have a switch. if i now enter the building i press the switch in the entrance, then the light in the entrance should come on automatically. (The official switch for the light in the entrance, however, is in the room next to the three station wagons.) Now, while working, I can also switch on another lamp from the three station wagons. and so it can be that at the end all 3 lamps light up.
If I go now I just want to press the switch again at the entrance so that all lights switch off automatically.

Station wagons??? Have you now left home and are on a train?

no sorry that's the google translator .., i mean 3 switches next to each other

I guess the logic for the entrance switch is:

  • If 1 or more lights are on, turn everything off.
  • If no lights are on, just turn on the entrance light.

I can't think of anything else that would improve that without having a two-button switch at the entrance or using long/short or single/double click options on the switch.

You could use one of the astronomical nodes in place of a sensor. Keep track of day/night using a separate flow. When going down the turn on logic, check whether it is night and if so, turn on, else don't turn on.

Then you could extend that to check for solar eclipses and turn the light on then :crazy_face:

Apart from the logic TotallyInformation proposed you could use the flow context to store a variable that either says "at home" or "away". When pressing the switch you just toggle this variable:

  • if it is toggled to "away" > switch off everything
  • if it is toggled to "at home" > switch on entrance light

I think the idea is correct, but how do I implement it? :upside_down_face:

I like to use the function node, but I'm not a perfect javascript programmer (not even close to perfect indeed :grin:)

[{"id":"898a956a.a6fde","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"867723a2.bdcbc8","type":"inject","z":"898a956a.a6fde","name":"toggle switch","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":220,"wires":[["99e5d35f.e94da8"]]},{"id":"99e5d35f.e94da8","type":"function","z":"898a956a.a6fde","name":"","func":"// get status from context\nvar s = flow.get(\"athome\");\n\n// check if variable exists\nif (typeof s == 'undefined') {\n    // set to 0 if not exist\n    s = false;\n}\n\n// toggle status\ns = !s;\n// save status to context\nflow.set(\"athome\", s);\n\n// so now what? are we at home\nvar msg1;\nvar msg2;\nvar msg3;\nvar msg4;\nif (s) {\n    // turn on shelly 1\n    msg1 = { payload:{\"turn\":\"on\"} };\n    msg2 = { payload:{} };\n    msg3 = { payload:{} };\n    msg4 = { payload:{} };\n} else {\n    msg1 = { payload:{\"turn\":\"off\"} };\n    msg2 = { payload:{\"turn\":\"off\"} };\n    msg3 = { payload:{\"turn\":\"off\"}};\n    msg4 = { payload:{\"turn\":\"off\"} };\n}\nreturn [msg1, msg2, msg3, msg4];\n\n","outputs":4,"noerr":0,"initialize":"","finalize":"","x":400,"y":220,"wires":[["6b3f6848.1a9a08"],["6b3f6848.1a9a08"],["6b3f6848.1a9a08"],["6b3f6848.1a9a08"]]},{"id":"6b3f6848.1a9a08","type":"debug","z":"898a956a.a6fde","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":220,"wires":[]}]

This example has an inject node that is like a toggle switch. It toggles the status and then the function will output 4 payloads. I thing I have the same payload to toggle my shelly at home, but I'm not sure (not at home at the moment). You just have to connect each output with the corresponding mqtt node.

For sure there is another, possible easier way to do that

Would it be possible to wire the input at the entrance as a switch instead of as a button? So then the gesture of moving the switch to the ON position can trigger the ON actions, and moving the switch to the OFF position can trigger the OFF actions.

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