Author Topic: Bulk Relocate reassign device / rooms  (Read 209 times)

Offline RichieB

  • Full Member
  • ***
  • Posts: 128
  • Karma: +1/-0
Bulk Relocate reassign device / rooms
« on: August 04, 2018, 05:26:01 am »
hey i have  39 devices in no room  ( forgive me it started with one device and then it grew) is there a way to bulk assign devices to rooms instead of doing it one by one like with Luup code ?

Offline akbooer

  • Master Member
  • *******
  • Posts: 6158
  • Karma: +275/-69
  • "Less is more"
Re: Bulk Relocate reassign device / rooms
« Reply #1 on: August 04, 2018, 06:14:48 am »
... instead of doing it one by one like with Luup code ?

Do you mean you DO want to use code, or you don't?

What criterion would you want to use to select WHICH ones to move?

It's straight-forward to type in a list of device numbers and have a short piece of code assign those devices to a given room.
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 RichieB

  • Full Member
  • ***
  • Posts: 128
  • Karma: +1/-0
Re: Bulk Relocate reassign device / rooms
« Reply #2 on: August 04, 2018, 07:39:52 am »
... instead of doing it one by one like with Luup code ?


It's straight-forward to type in a list of device numbers and have a short piece of code assign those devices to a given room.

this is what i want to do i have 39 devices in No Room and i just need to assign them without going through them one by one

Offline akbooer

  • Master Member
  • *******
  • Posts: 6158
  • Karma: +275/-69
  • "Less is more"
Re: Bulk Relocate reassign device / rooms
« Reply #3 on: August 04, 2018, 08:51:56 am »
That's easy, then.

Run the following code in the Lua Test window, setting the variable room to the new room number and filling out the list of devices you want to move...

Code: [Select]
local devices = {151,152,153,154,155,156,157,158,159}  -- change this as needed
local room = 0  -- new room number here
for _,d in pairs(devices) do
    luup.attr_set ("room", room, d)
end
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 akbooer

  • Master Member
  • *******
  • Posts: 6158
  • Karma: +275/-69
  • "Less is more"
Re: Bulk Relocate reassign device / rooms
« Reply #4 on: August 04, 2018, 09:15:59 am »
...and, obviously, if the device numbers are contiguous, you can use a simple loop rather than a device list

Code: [Select]
for d = 151, 159 do
...

Actually, it won't matter if there are gaps in the device numbering, so long as all the devices within the range you specify are to be moved.
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 rigpapa

  • Hero Member
  • *****
  • Posts: 674
  • Karma: +101/-1
Re: Bulk Relocate reassign device / rooms
« Reply #5 on: August 04, 2018, 09:16:43 am »
Code is definitely the expedient way to go for a large number of rooms. For a smaller number, if you know the room id (number), you can change "room" field in the Advanced > Params tab for each device. Doing it this way bypasses the reload of Luup that the UI launches when changing the room name by the dropdown on the Control tab, which is largely what makes it so slow and tedious.
« Last Edit: August 04, 2018, 10:02:28 am by rigpapa »
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 RichieB

  • Full Member
  • ***
  • Posts: 128
  • Karma: +1/-0
Re: Bulk Relocate reassign device / rooms
« Reply #6 on: August 04, 2018, 09:42:57 am »
spank you -- worked like a charm