Author Topic: Set switch OFF if all lights get shut off  (Read 123 times)

Offline scottr

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Set switch OFF if all lights get shut off
« on: November 03, 2017, 09:26:37 pm »
I have a room with a GE / Jasco in-wall switch.  It controls 3 GE / Jasco in-wall outlets with floor lamps plugged into the switched outlet.  I also have to of the Aeon Labs remotes so that we can control the lights in this room independently.

RIght now:

   Switch ON = All lights on

 Remote, turn each light off (one at a time):
    All lights off, switch still on

 TO turn the lights on from the switch, I need to:
1. Turn switch off
2. Turn switch back on

 Is there a way to program a scene such that when the last light gets switched off, the switch gets set to off?


Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9724
  • Karma: +737/-136
    • RTS Services Plugins
Re: Set switch OFF if all lights get shut off
« Reply #1 on: November 03, 2017, 11:20:58 pm »
You can do that with PLEG.

Offline sebby

  • Full Member
  • ***
  • Posts: 195
  • Karma: +6/-3
Re: Set switch OFF if all lights get shut off
« Reply #2 on: November 04, 2017, 10:41:02 am »
I have a room with a GE / Jasco in-wall switch.  It controls 3 GE / Jasco in-wall outlets with floor lamps plugged into the switched outlet.  I also have to of the Aeon Labs remotes so that we can control the lights in this room independently.

RIght now:

   Switch ON = All lights on

 Remote, turn each light off (one at a time):
    All lights off, switch still on

 TO turn the lights on from the switch, I need to:
1. Turn switch off
2. Turn switch back on

 Is there a way to program a scene such that when the last light gets switched off, the switch gets set to off?

should be pretty easy to do in luup.  Create a scene that fires whenever any of the lamps gets turned off and then get the status of each lamp via a luup.variable_get and if they are all off set the switch to off.   assuming your lamp devices are 20,21,22 and your switch is device 40

Code: [Select]
-- this gets the status of the lamps, 1 is on 0 is off
local lamp1 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 20)
local lamp2 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 21)
local lamp3 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 22)

-- this checks if they are all off and turns the switch off
if (lamp1 == "0") and (lamp2 == "0") and (lamp3 == "0") then
   luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 40)
end

Offline kwieto

  • Full Member
  • ***
  • Posts: 168
  • Karma: +5/-5
Re: Set switch OFF if all lights get shut off
« Reply #3 on: November 04, 2017, 02:08:31 pm »
If the Switch supports power metering you can set there scene with the condition that if power readings drop to 0, then the switch it's turned off and then on

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9724
  • Karma: +737/-136
    • RTS Services Plugins
Re: Set switch OFF if all lights get shut off
« Reply #4 on: November 04, 2017, 02:19:37 pm »
In PLEG

Inputs:
SwitchPower   Bound to the Switch Power setting.
SwitchOn        Bound to when the Switch Indicates it's On

Condition:
PowerZero        SwitchPower == 0
Reset               PowerZero and SwitchOn and (SwitchOn; PowerZero)

Actions for Reset  ... turn switch off, then on.

This is much more tricky in LUA ... without the sequence expression ... you could trip and infinite loop.


« Last Edit: November 04, 2017, 02:22:25 pm by RichardTSchaefer »