I checked and line 21 is handling the response of the function getHueLights() that is located in the user.hue, so i guess you use a older version of the user lib.
Can you try to replace your user.hue with this version? A restart might be required.
10.08.2020, 12:48 (This post was last modified: 10.08.2020, 12:54 by Erwin van der Zwart.)
Hi,
Yes you can do that, in the user.hue there are already 2 functions to use for group commands, getHueGroups() and sendToGroup()
First you have to get the groups by this command:
Code:
12345
--Get all group information require('user.hue')
-- get all lights from bridgeresult = getHueGroups()
log(result)
When you know the group ID you can control it with:
Code:
12345678910
require('user.hue')
value = event.getvalue()
group_id = 1-- change this ID to your actual group, see getHueGroups() resultifvalue == truethenbody_msg = '{"on":true}'sendToGroup(group_id,body_msg)
elsebody_msg = '{"on":false}'sendToGroup(group_id,body_msg)
end
thank you for your help. The Script for group switching works perfect. I tried the same with brigtness but had no luck. Just change the script from lampID to GroupID didn´t work.
Do you have any scripts for controlling the Brightness, RGB an CT for Group´s with Feedback ?
Is there a chance that upcomming releases of W4K Firmware have an nativ integration of Philips HUE ?
05.09.2020, 15:57 (This post was last modified: 05.09.2020, 16:07 by Erwin van der Zwart.)
Did you also called the function sendToGroup?
No I don’t think so, i have not seen any development in that direction, they work on speech control and new mobile app at this moment. Maybe i will start a new project to build a app for HUE this winter, but I don’t have time until November this year..
--Control HUE from byte object (brightness) (use as event based script)require('user.hue')
value = event.getvalue() -- 1 byte unsigned integer scale 0 - 100group_id = 1-- change this ID to your actual light, see getHueLights() result for lamps or use your app to resolve themsetBrightness(group_id,value)
then i added a function in user.hue with also no luck.
I just tested with my latest user lib and this command and works perfect
Code:
123456
require('user.hue')
require('json')
--log(json.pdecode(getHueGroups())) -- enable to check group number--setBrightnessGroup(1,100) -- Group, brightness in %setBrightnessCTGroup(1,60,2000) -- Group, brightness in %, CT in Kelvin
It's the last line in the code "Keuken Werkblad" The individual lamps "Keuken Werkblad L" & "Keuken Werkblad R" get updated in both "state", "bri" and "rgb"
Can you help me out?
Erwin's script uses getHueLights() which does not include groups. Try this to get info for both lights and groups together (replace the relevant script part with this):
Code:
12345678910111213141516
-- loop indefenitlywhiletruedoreply = getHueLights()
mylamps = json.decode(reply)
-- get groups startreply = getHueGroups()
groups = json.pdecode(reply)
iftype(groups) == 'table'thenfork, vinpairs(groups) domylamps[ k ] = vendend-- get groups endfor_, iteminpairs(mylamps) do
09.11.2020, 15:17 (This post was last modified: 09.11.2020, 15:21 by Firechief.)
Dear Admin,
I've added these lines to the resident Hue script. Now none of the Hue lamp statusses are updated, neither the brightness nor the rgb. These worked before i added the lines. I do not get log's when switching lamps on or off. No error logs as well. I'm using the v5 user.hue library.
-- Set name (Lookup in HUE app under light configuration) and feedback adresses (don't change statevalue, brivalue and colorvalue as they are used as memoryfield)addressmapping = {
-- Name -- On/Off FB -- Bright FB -- Color FB
['Led terras'] = {state = '20/0/1', bri = '20/1/1', rgb = '20/2/1', ct = '20/3/1', statevalue = '', brivalue = '', colorvalue = ''},
['Keuken Eiland'] = {state = '20/0/2', bri = '20/1/2', rgb = '20/2/2', statevalue = '', brivalue = '', colorvalue = ''},
['Keuken Werkblad R'] = {state = '20/0/3', bri = '20/1/3', rgb = '20/2/3', statevalue = '', brivalue = '', colorvalue = ''},
['Keuken Werkblad L'] = {state = '20/0/4', bri = '20/1/4', rgb = '20/2/4', statevalue = '', brivalue = '', colorvalue = ''},
['Douche L'] = {state = '20/0/5', bri = '20/1/5', rgb = '20/2/5', statevalue = '', brivalue = '', colorvalue = ''},
['Douche R'] = {state = '20/0/6', bri = '20/1/6', rgb = '20/2/6', statevalue = '', brivalue = '', colorvalue = ''},
['Keuken Werkblad'] = {state = '20/0/7', bri = '20/1/7', rgb = '20/2/7', statevalue = '', brivalue = '', colorvalue = ''},
}
-- Set polling interval in secondsinterval = 1-- Use logginglogging = truerequire('user.hue')
require('json')
-- loop indefenitlywhiletruedoreply = getHueLights()
mylamps = json.decode(reply)
-- get groups startreply = getHueGroups()
groups = json.pdecode(reply)
iftype(groups) == 'table'thenfork, vinpairs(groups) domylamps[ k ] = vendend-- get groups endfor_, iteminpairs(mylamps) do-- Check if lamp is found by bridge otherwise it make no sense to send commandsifitem.state.reachable == truethen-- On/Offname = addressmapping[item.name]
ifnamethenaddr = addressmapping[item.name]['state']
ifaddrandaddr ~= ''thencurrentvalue = addressmapping[item.name]['statevalue']
ifcurrentvalue ~= item.state.onthengrp.update(addr, item.state.on)
addressmapping[item.name]['statevalue'] = item.state.oniflogging == truethenlog('lamp ' .. item.name .. ' state is: ' .. tostring(item.state.on))
endendendend-- Brightnessname = addressmapping[item.name]
ifnamethenaddr = addressmapping[item.name]['bri']
ifaddrandaddr ~= ''then-- Check if lamp is on otherwise overrule BRI value to 0ifitem.state.on == falsethenitem.state.bri = 0endcurrentvalue = addressmapping[item.name]['brivalue']
ifcurrentvalue ~= item.state.brithengrp.update(addr, math.floor((tonumber(item.state.bri)/2.55) + 0.5))
addressmapping[item.name]['brivalue'] = item.state.briiflogging == truethenlog('lamp ' .. item.name .. ' brightness is: ' .. math.floor((tonumber(item.state.bri)/2.55) + 0.5) .. ' %')
endendendend-- Colorname = addressmapping[item.name]
ifnamethenaddr = addressmapping[item.name]['rgb']
ifaddrandaddr ~= ''then-- Check if lamp is on otherwise overrule color value to 0ifitem.state.on == falsethencolorvalue = 0endifitem.state.colormode == 'xy'thencurrentvalue = addressmapping[item.name]['colorvalue']
colorvalue = xy_to_rgb(item.state.xy[1],item.state.xy[2],item.state.bri)
--colorvalue = xyz_to_rgb((item.state.xy[1] * 100), (item.state.xy[2] * 100))ifcurrentvalue ~= colorvaluethengrp.update(addr, colorvalue)
addressmapping[item.name]['colorvalue'] = colorvalueiflogging == truethenlog('lamp ' .. item.name .. ' color is: ' .. colorvalue)
endendelseifitem.state.colormode == 'ct'thencurrentvalue = addressmapping[item.name]['colorvalue']
--colortemp = math.floor((item.state.ct / 0.0769) + 0.5) --0.0769230769230769colortemp = math.abs((item.state.ct - 500) / 2)
colortemp = math.floor(colortemp + 0.5)
colortemp = 80 + colortempifcolortemp > 255thencolortemp = 255endr = lmcore.inttohex(255, 1)
g = lmcore.inttohex(255, 1)
b = lmcore.inttohex(colortemp, 1)
rgb = r .. g .. bcolortemp = lmcore.hextoint(rgb,3)
ifcurrentvalue ~= colortempthen--colortempconverted = ct_to_rgb(colortemp)grp.update(addr, colortemp)
addressmapping[item.name]['colorvalue'] = colortempiflogging == truethenlog('lamp ' .. item.name .. ' color is: ' .. colortemp)
endendendendendend--log('manufacturername = ' .. item.manufacturername)--log('swversion = ' .. item.swversion)--log('type = ' .. item.type)--log('ct = ' .. item.state.ct)--log('reachable = ' .. item.state.reachable)--log('alert = ' .. item.state.alert)--log('on = ' .. item.state.on)--log('bri = ' .. item.state.bri)--log('colormode = ' .. item.state.colormode)--log('hue = ' .. item.state.hue)--log('sat = ' .. item.state.sat)--log('effect = ' .. item.state.effect)--log('x = ' .. item.state.xy[1])--log('y = ' .. item.state.xy[2])--log('uniqueid = ' .. item.uniqueid)--log('modelid = ' .. item.modelid)--log('name = ' .. item.name)end-- Delay loopos.sleep(interval)
end
Kind regards
Can it be that there's a typo in the lines?
Code:
123456789
-- get groups startreply = getHueGroups()
groups = json.pdecode(reply) -- ==>json.decode(reply) ???iftype(groups) == 'table'thenfork, vinpairs(groups) domylamps[ k ] = vendend-- get groups end