Page 1 of 2
Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 9:40
by EddyG
I have a Xioami zigbee lamp, which can be set by color temp and brightness.
The Domoticz Gui works (although the setting of color temp cannot be saved)

- 2019-04-01_09-42-04.png (14.54 KiB) Viewed 4689 times
The command from the gui in the domoticz log is:
Code: Select all
Status: setcolbrightnessvalue: ID: 333, bri: 50, color: '{m: 2, RGB: 000000, CWWW: 7788, CT: 136}'
How do I accomplice this in DzVents? I am using domoticz 4.10580 with dzVents 2.4.16
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 9:50
by waaren
EddyG wrote: ↑Monday 01 April 2019 9:40
I have a Xioami zigbee lamp, which can be set by color temp and brightness.
The Domoticz Gui works (although the setting of color temp cannot be saved)
2019-04-01_09-42-04.png
The command from the gui in the domoticz log is:
Code: Select all
Status: setcolbrightnessvalue: ID: 333, bri: 50, color: '{m: 2, RGB: 000000, CWWW: 7788, CT: 136}'
How do I accomplice this in DzVents? I am using domoticz 4.10580 with dzVents 2.4.16
In dzVents 2.4.16 a couple of new methods for RGBW devices were introduced. Please experiment a bit with the new setHex, setHue and /or setColor methods (see the wiki)
Very much interested in your results.
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 10:00
by EddyG
I know. I already did, but not (yet) the expected results. The setHue uses m: 1 and cwww: 0000
But I will check further.
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 10:09
by EddyG
Tnx. Got it working with: .setColor(0,0,0,60,150,150,2,160).silent()
Now some fine tuning for the right brightness and tempcolor.
For me a nice brightness and color temp is: .setColor(0,0,0,80,144,144,2,120).silent()
Now I can change them according to my mood
B.t.w. The color selector in Domoticz does work but and is not saved in domoticz.
I saw in the database that the setting (as from above) is NOT saved in the database in column Color.
I think it should be so it can be used the next time the lamp is switched on.
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 10:18
by waaren
EddyG wrote: ↑Monday 01 April 2019 10:00
I know. I already did, but not (yet) the expected results. The setHue uses m: 1 and cwww: 0000
But I will check further.
[Edit] You found it already !
Can you try this ?
Code: Select all
local light = dz.devices(333)
light.setColor(0,0,0, 50, 119, 136, 2, 136) -- setColor(r, g, b, br, cw, ww, m, t)
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 10:27
by EddyG
I tried a getColor() for this device,but that give an error:
Code: Select all
2019-04-01 10:26:38.368 Status: dzVents: Error (2.4.16): An error occured when calling event handler slave overloop
2019-04-01 10:26:38.368 Status: dzVents: Error (2.4.16): ...domoticz/dzVents/runtime/device-adapters/rgbw_device.lua:176: attempt to index local 'ct' (a nil value)
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 11:29
by waaren
EddyG wrote: ↑Monday 01 April 2019 10:27
I tried a getColor() for this device,but that give an error:
Code: Select all
2019-04-01 10:26:38.368 Status: dzVents: Error (2.4.16): An error occured when calling event handler slave overloop
2019-04-01 10:26:38.368 Status: dzVents: Error (2.4.16): ...domoticz/dzVents/runtime/device-adapters/rgbw_device.lua:176: attempt to index local 'ct' (a nil value)
That should nog happen. I assume the color field is not set.
Can you please show what is in the domoticz database for this device to help me identifying the issue so that it can be fixed or at least prevent the Error ?
cd <domoticzdir>
sudo sqlite3 domoticz.db
sqlite>.headers on
sqlite>select * from devicestatus where id = 333;
sqlite>.q
Re: Color and brightness with a zigbee lamp
Posted: Monday 01 April 2019 11:51
by EddyG
Here it is. And you are right Color field is not set, and if I fill it in manually in the database the content is deleted after an action.
Code: Select all
ID|HardwareID|DeviceID|Unit|Name|Used|Type|SubType|SwitchType|Favorite|SignalLevel|BatteryLevel|nValue|sValue|LastUpdate|Order|AddjValue|AddjMulti|AddjValue2|AddjMulti2|StrParam1|StrParam2|LastLevel|Protected|CustomImage|Description|Options|Color
819|33|0x00158d0002b7d689_light|46|Overloop lamp|1|241|8|7|0|4|255|0|80|2019-04-01 11:45:09|64|0.0|1.0|0.0|1.0|||80|0|0|||
Re: Color and brightness with a zigbee lamp
Posted: Friday 05 April 2019 13:37
by EddyG
I upgraded to dzVents 2.4.17 I get an error with .getColor()
Code: Select all
2019-04-05 13:32:01.866 Status: dzVents: Error (2.4.17): Color field not set for this device
The SetColor works fine, so should not return the .getColor() values?
I know it is not really a color device, but I would like to get back the current color temperature as a value between 0 and 255
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 10:58
by waaren
Mayki wrote: ↑Sunday 14 April 2019 10:34
Is there any progress with this thing?
Yes. In recent Beta's you will get a message that the color field is not set.
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 11:43
by EddyG
That is correct, but it is an error.
I would like to have a function to get the color temperature back.
In a separate function or in the .getcolor() function.
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 13:41
by waaren
EddyG wrote: ↑Sunday 14 April 2019 11:43
That is correct, but it is an error.
I would like to have a function to get the color temperature back.
In a separate function or in the .getcolor() function.
My understanding of setting color temperature for these type of devices is by /json.htm?param=setkelvinlevel&type=command&idx=nnnn&kelvin=[0-100]
What this does is changing the values ww and cw of the json string in the color field in the database (table devicestatus). This means that dzVents needs the colorfield to be filled in order to calculate a Kelvin value.
Happy to try and implement a getKelvin method if you know of any other way to get this value from domoticz. I do not own such a device so I need a bit of help to investigate.
Can you show me the output of http://domoticz_IP:domoticz_port/json.htm?type=devices&rid=nnnn
and the output of
sqlite> select * from devicestatus where id = nnnn;
after http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=1
, http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=66
and http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=100
Thanks !
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 14:23
by EddyG
waaren wrote: ↑Sunday 14 April 2019 13:41
Can you show me the output of http://domoticz_IP:domoticz_port/json.htm?type=devices&rid=nnnn
and the output of
sqlite> select * from devicestatus where id = nnnn;
after http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=1
, http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=66
and http://domoticz_IP:domoticz_port/json.htm?param=setkelvinlevel&type=command&idx=nnnn &kelvin=100
Thanks !
Code: Select all
{
"ActTime": 1555243812,
"AstrTwilightEnd": "22:42",
"AstrTwilightStart": "04:34",
"CivTwilightEnd": "21:08",
"CivTwilightStart": "06:08",
"DayLength": "13:49",
"NautTwilightEnd": "21:53",
"NautTwilightStart": "05:24",
"ServerTime": "2019-04-14 14:10:12",
"SunAtSouth": "13:05",
"Sunrise": "06:44",
"Sunset": "20:33",
"app_version": "4.10602",
"result": [
{
"AddjMulti": 1.0,
"AddjMulti2": 1.0,
"AddjValue": 0.0,
"AddjValue2": 0.0,
"BatteryLevel": 255,
"Color": "",
"CustomImage": 0,
"Data": "Off",
"Description": "",
"DimmerType": "abs",
"Favorite": 0,
"HardwareID": 33,
"HardwareName": "Zigbee",
"HardwareType": "Zigbee2MQTT",
"HardwareTypeVal": 94,
"HaveDimmer": true,
"HaveGroupCmd": false,
"HaveTimeout": false,
"ID": "0x00158d0002b7d689_light",
"Image": "Light",
"IsSubDevice": false,
"LastUpdate": "2019-04-14 14:09:08",
"Level": 49,
"LevelInt": 49,
"MaxDimLevel": 100,
"Name": "Overloop lamp",
"Notifications": "false",
"PlanID": "5",
"PlanIDs": [
5,
6
],
"Protected": false,
"ShowNotifications": true,
"SignalLevel": 3,
"Status": "Off",
"StrParam1": "",
"StrParam2": "",
"SubType": "WW",
"SwitchType": "Dimmer",
"SwitchTypeVal": 7,
"Timers": "false",
"Type": "Color Switch",
"TypeImg": "dimmer",
"Unit": 46,
"Used": 1,
"UsedByCamera": false,
"XOffset": "0",
"YOffset": "0",
"idx": "819"
}
],
"status": "OK",
"title": "Devices"
}
The data in the database is for all the kelvin settings the same, so it seems that that setting is not saved in the database. I think it should be saved in the last column 'Color' but it is not.
In the Domoticz web interface the color temperature can be set to to different one, but the settings 'dot' stays always in the middle and cannot be saved either.
Code: Select all
819|33|0x00158d0002b7d689_light|46|Overloop lamp|1|241|8|7|0|3|255|0|49|2019-04-14 14:09:08|64|0.0|1.0|0.0|1.0|||49|0|0|||
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 14:32
by waaren
EddyG wrote: ↑Sunday 14 April 2019 14:23
Code: Select all
{
"result": [
{
"Color": "",
"HardwareType": "Zigbee2MQTT",
}
],
"status": "OK",
"title": "Devices"
}
The data in the database is for all the kelvin settings the same, so it seems that that setting is not saved in the database. I think it should be saved in the last column 'Color' but it is not.
Thx for having a look. Maybe the developer of Zigbee2MQTT can help here ?
Re: Color and brightness with a zigbee lamp
Posted: Sunday 14 April 2019 16:07
by EddyG
Re: Color and brightness with a zigbee lamp
Posted: Monday 06 May 2019 20:00
by Omemanti
I bought an Ikea Tradfri LED bulb(RGB) yesterday.
it worked like a charm, after some hassle I got it all working.
But is there a possibility to create a custom button so set it to a selected color? So I can hit that button and the light goes to a pre-set red glow.
I got as far as a dummy switch, but now I have to add an action and it says "(Should start with http://, https:// or script://)"
and now I'm seeking help
Thnx!
Re: Color and brightness with a zigbee lamp
Posted: Monday 06 May 2019 20:13
by waaren
Omemanti wrote: ↑Monday 06 May 2019 20:00
Is there a possibility to create a custom button so set Ikea Tradfri LED bulb(RGB) to a selected color ?
Have a look at
the dzVents wiki on how to create a script triggered by the dummy switch. In that script you can set the Ikea Tradfri LED bulb(RGB) to any color you like.
could look like something as.
Code: Select all
return {
on = { devices = { "name of your custom button" }},
execute = function(dz, item)
Ikea = dz.devices(idx of your Ikea bulb)
if item.active then
Ikea.setRGB(255,0,0)
else
Ikea.switchOff()
end
end
}
Re: Color and brightness with a zigbee lamp
Posted: Monday 06 May 2019 22:05
by Omemanti
Thanks, exactly what I needed!
Re: Color and brightness with a zigbee lamp
Posted: Tuesday 21 May 2019 21:42
by domogijs
i copy pasted your script but i get an error:
700 Error: EventSystem: Lua script testtt did not return a commandArray
2019-05-21 21:40:36.882 Error: EventSystem: Lua script testtt did not return a commandArray
2019-05-21 21:40:36.890 Error: EventSystem: Lua script testtt did not return a commandArray
Any idea?
Re: Color and brightness with a zigbee lamp
Posted: Tuesday 21 May 2019 22:42
by waaren
domogijs wrote: ↑Tuesday 21 May 2019 21:42
I copy pasted your script but i get an error:
Any idea?
The script is dzVents code and you saved it as a Lua script