Author Topic: Code to return all devices in a room?  (Read 803 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

Online akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6201
  • Karma: +276/-70
  • "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, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

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

Online akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6201
  • Karma: +276/-70
  • "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, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Deeps

  • Sr. Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Re: Code to return all devices in a room?
« Reply #4 on: July 02, 2018, 02:13:48 am »
Hi..

I am facing same issue now. But my count of rooms and bulbs is very high. Basically my plugin is for agriculture land bulbs.
So I have almost 10-15 rooms and hundreds of bulbs

I i do device list and search for individual room and then apply room logic in loop, it will be tooo much lengthy process.

is there any API to get device ids for provided room id, room wise device list.

Online akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6201
  • Karma: +276/-70
  • "Less is more"
Re: Code to return all devices in a room?
« Reply #5 on: July 02, 2018, 03:14:01 am »
Please don't ask the same question in multiple threads, it makes it very difficult to have a coherent conversation. 

You started a new thread on this elsewhere, which I answered.  You have given more information here, but I still see no problem with the basic approach.

Suggest we continue on your new thread.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.