Author Topic: Code to return all devices in a room?  (Read 177 times)

Offline Hippogriff

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +2/-2
Code to return all devices in a room?
« on: February 23, 2017, 04:05:26 am »
Hi, I have 15 Philips Hue bulbs across the house and 8 of them are said to be in the "outside" room in Vera.

I can use the Hue App to control when they come on and off, and I can create a Scene in Vera, selecting each device, and control them that way.

What I'd, ideally, like to do is to be able to have a Scene that runs some code that retrieves the 8 devices that are in the "outside" room and then just loops and sets their state.

Is it possible to interrogate Vera for just the devices located in a specific room (they'll all be the same type of device in my case) so I can then send the following command to all 8 in a loop?

Code: [Select]
luup.call_action ("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{newLoadlevelTarget="100"},device#)
I did Google briefly, but this must have passed me by.
Cheers, Hippo

Offline akbooer

  • Master Member
  • *******
  • Posts: 4750
  • Karma: +205/-67
  • "Less is more"
Re: Code to return all devices in a room?
« Reply #1 on: February 23, 2017, 08:52:07 am »
Yes, easy.  The device table in luup.devices has a variable room_num which can be used for this.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay.

Offline Hippogriff

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +2/-2
Re: Code to return all devices in a room?
« Reply #2 on: February 24, 2017, 10:22:23 am »
Thank you.

I did look at that yesterday - however, even though the UI reported each device I was interested in as being in room 14, the code I was using that logged room_num always showed them as room_num 0.

However, for sanity, I ran my code again just now and now they're showing as room_num 14!  ???
Cheers, Hippo

Offline akbooer

  • Master Member
  • *******
  • Posts: 4750
  • Karma: +205/-67
  • "Less is more"
Re: Code to return all devices in a room?
« Reply #3 on: February 24, 2017, 10:54:58 am »
Perhaps you reloaded in between times?  Anyway, glad it's behaving itself now!
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay.