15.12.2021, 14:47
(15.12.2021, 14:09)Erwin van der Zwart Wrote: Yes you can control by name by adding these 2 functions to your user.hue:
Then add this as a resident script at 0 seconds: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
From now on you can get the lamp ID by name using this:Code:--Create lights and groups table (resident at 0) require('user.hue') makeLightsTable() makeGroupsTable() os.sleep(600)
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)
Sorry, I don't understand... I can already control on/off and 0-100% brightness.... How I could use that system? What I need is to set and feedback of RGB COLOURS....