Author Topic: A single switch to turn off all lights within a room  (Read 332 times)

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2465
  • Karma: +35/-48
  • Life Moves Pretty Fast....
A single switch to turn off all lights within a room
« on: August 24, 2018, 02:49:37 pm »
Hi

Just a thought/idea (long shot)

Is it possible to create a ?switch? that turns on or off all of the lights within the room it is assigned to within Vera ?

So rather than have to create a virtual switch linked to an associated scene for each room, or have an itemised list of device IDs within a some lua code by room.

Could a single piece of code be created that when run, looks for the room that this switch is assigned , look up all the lights within it, and then based on the command (on or off) carry out the required action?

As always I might be missing something completely obvious with this - if I am sorry - just let me know.
« Last Edit: August 24, 2018, 02:53:37 pm by parkerc »

Offline cokeman

  • Full Member
  • ***
  • Posts: 113
  • Karma: +1/-0
Re: A single switch to turn off all lights within a room
« Reply #1 on: August 24, 2018, 02:51:55 pm »
Yea. Nice feature.

Hope they will make it in a feature version

But not only light. Tsrv. Or what ever you need

Dimmer. On/off switch. Etc
Vera 3 in the summerhouse, Vera Plus at home
@Denmark

Offline rigpapa

  • Hero Member
  • *****
  • Posts: 674
  • Karma: +101/-1
Re: A single switch to turn off all lights within a room
« Reply #2 on: August 24, 2018, 02:53:19 pm »
That would be a very simple plugin to write in the simple case. But what about other devices in the room? Media players, etc.?
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2465
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: A single switch to turn off all lights within a room
« Reply #3 on: August 24, 2018, 02:56:49 pm »
I?m just thinking about lights at the moment, as that is my pain point - if I look at my Hue integration, I have 6 lights within one room (4 are in one light fitting, but are shown individually)

Having a dimmer for all, as well as an off/on grouping option would be nice touch too (@cokeman)

If we can group them, then maybe we could also use veras ability to make a device invisible option, that way once grouped they do not appear individually within the UI, we just have a grouped light option. When you ungroup they are made visible again.
« Last Edit: August 24, 2018, 03:00:26 pm by parkerc »

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 1326
  • Karma: +35/-32
Re: A single switch to turn off all lights within a room
« Reply #4 on: August 24, 2018, 08:17:35 pm »
I use a virtual switch for my 3 exterior lights, al 3 in different rooms. When the switch is manually turned on/off, this triggers a PLEG action to turn on/off the lights. I also trigger the virtual switch based on sunrise/sunset.  It could easily be done in a scene as well.
Vera 3, 1.7.1030, CT101, Everspring motion sensor, GE/Jasco switch, Leviton outlet, AeonLabs sensor, NuTone garage door, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual/Multi Switch, Weatherunderground, LB60Z-1 bulb, Hue, Alexa

Offline Mike Yeager

  • Hero Member
  • *****
  • Posts: 571
  • Karma: +9/-12
Re: A single switch to turn off all lights within a room
« Reply #5 on: August 24, 2018, 08:36:12 pm »
This is the job of the virtual switch. Don't ask the developers to do simple stuff like this for you, they'll only find a way to screw it up...

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2465
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: A single switch to turn off all lights within a room
« Reply #6 on: August 25, 2018, 02:58:58 am »
Agreed, using PLEG or a scene to group devices ; and then having a single trigger to carry out the same action across all of them is straightforward  - Home Automation 101 - stuff.

Ideally out of the box Vera should have come with built in grouping capability for lighting and rooms. If I look within the Phillips Hue app , they allow you to group individual lights and control them together under 1 identity in the UI (hiding them as individual lights when grouped)

In the absence of it being built in to Vera; Im curious what it would take to code something thats dynamic (no scene/PLEG association needed) - I can envisage a sort of virtual switch too, but one thats coded upfront to i) be aware of the room its assigned to ii) to be able to look up all the lights that are in that same room automatically and iii) can then control alll of them together (a sort of Dynamic Grouping Switch)
« Last Edit: August 25, 2018, 06:54:33 am by parkerc »

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2465
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: A single switch to turn off all lights within a room
« Reply #7 on: August 25, 2018, 06:58:04 am »
Just been working on a piece of code on the side, that lists all the lights, their assigned room, and then their status. (For those with LuaTest, copy and paste to confirm)

Code: [Select]
function get_key_for_value( t, key )
  for k,v in ipairs(t) do
    if k==key then return v
  end
 end
end

local SSID = "urn:upnp-org:serviceId:SwitchPower1"
local HSID = "urn:micasaverde-com:serviceId:HaDevice"

local myLookupTable = {
  ["1"] = "on",
  ["0"] = "off",
};

for deviceNo,d in pairs(luup.devices) do
   if d.category_num == 2 then         
      local tripped = luup.variable_get(SSID, "Status", deviceNo) or "Nil"
      if (tripped == "1") then
      end
   
local onoff = myLookupTable[tripped], 1
local kick = get_key_for_value( luup.rooms, d.room_num )
 
 print ("The " ..kick.. " light, called (" .. d.description .. ") is switched " .. onoff)
   
   end
   end
« Last Edit: August 25, 2018, 07:00:45 am by parkerc »

Offline Helen

  • Global Moderator
  • Sr. Newbie
  • *****
  • Posts: 46
  • Karma: +0/-0
Re: A single switch to turn off all lights within a room
« Reply #8 on: August 25, 2018, 08:06:36 am »
Hello,

We would like to thank you for the feedback and please note that we have added a feature request in our internal bug tracking on this matter.


Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2465
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: A single switch to turn off all lights within a room
« Reply #9 on: August 25, 2018, 12:44:54 pm »
Hello,

We would like to thank you for the feedback and please note that we have added a feature request in our internal bug tracking on this matter.

Thanks @Veronica