This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Philips HUE Lamps state
#8
Yes you can control by name by adding these 2 functions to your user.hue:
Code:
function makeLightsTable()   local lights = getHueLights()   if lights then     lights = json.pdecode(lights)     LightsTable = {}     for _, foundlights in pairs(lights) do       LightsTable[foundlights.name] = tonumber(_)     end     storage.set("hue:lights", LightsTable)   end   return LightsTable end function makeGroupsTable()   local groups = getHueGroups()   if groups then     groups = json.pdecode(groups)     GroupsTable = {}     for _, foundgroups in pairs(groups) do       GroupsTable[foundgroups.name] = tonumber(_)     end     storage.set("hue:groups", GroupsTable)   end   return GroupsTable end
Then add this as a resident script at 0 seconds:
Code:
--Create lights and groups table (resident at 0) require('user.hue') makeLightsTable() makeGroupsTable() os.sleep(600)
From now on you can get the lamp ID by name using this:
Code:
lamp_id = storage.get("hue:lights")["Plafondlamp Woonkamer"] or 0 body_msg = '{"on":false}' sendToLight(lamp_id,body_msg) -- or group_id = storage.get("hue:groups")["Woonkamer"] or 0 body_msg = '{"on":true}' sendToGroup(group_id,body_msg)

PS: You are correct, there once was a mistake in a older user.hue lib with the sendToGroup function, it was already corrected in my latest version(s)
Reply


Messages In This Thread
Philips HUE Lamps state - by gdimaria - 21.09.2021, 15:18
RE: Philips HUE Lamps state - by admin - 22.09.2021, 12:54
RE: Philips HUE Lamps state - by gdimaria - 22.09.2021, 15:34
RE: Philips HUE Lamps state - by gdimaria - 14.12.2021, 17:44
RE: Philips HUE Lamps state - by Erwin van der Zwart - 15.12.2021, 14:09
RE: Philips HUE Lamps state - by gdimaria - 15.12.2021, 14:47
RE: Philips HUE Lamps state - by admin - 15.12.2021, 05:50
RE: Philips HUE Lamps state - by gdimaria - 15.12.2021, 13:53
RE: Philips HUE Lamps state - by gdimaria - 16.12.2021, 07:02
RE: Philips HUE Lamps state - by gdimaria - 16.12.2021, 12:32
RE: Philips HUE Lamps state - by gdimaria - 25.01.2022, 13:09

Forum Jump: