A way to control RGB(W(W))

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

A way to control RGB(W(W))

Post by poudenes »

Hi All,

Is it possible to change color to RGB(W(W)) bulbs using dzVents?
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: A way to control RGB(W(W))

Post by poudenes »

find out that i can use this

Code: Select all

os.execute('curl "http://127.0.0.1:8081/json.htm?type=command&param=setcolbrightnessvalue&idx=3&hue=18&brightness=50&iswhite=false"')
hue i can select the color and brightness i can change the level of it
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: A way to control RGB(W(W))

Post by dannybloe »

That's interesting. Are there more commands like these? Maybe useful to add this to the rgbw_device.lua adapter.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: A way to control RGB(W(W))

Post by poudenes »

dannybloe wrote: Wednesday 22 November 2017 8:17 That's interesting. Are there more commands like these? Maybe useful to add this to the rgbw_device.lua adapter.
You can also use this for kelvin level

Code: Select all

http://127.0.0.1:8081/json.htm?type=command&param=setkelvinlevel&idx=8&kelvin=10
Where kelvin=10 can be between 1-100

But for kelvin i created a dummy switch with 10 different kelvin levels :10, 20, 30, 40, 50, 60, 70, 80, 90, 100

The link i use in dzVents was needed to give my MiLight bulbs some color for specific action
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: A way to control RGB(W(W))

Post by BakSeeDaa »

dannybloe wrote: Wednesday 22 November 2017 8:17 That's interesting. Are there more commands like these? Maybe useful to add this to the rgbw_device.lua adapter.
The FIBARO RGBW Controller has 5 nice animation programs built in that can be set using the Domoticz API URL.

Predefined animation programs

6 = Fireplace
7 = Storm
8 = Rainbow
9 = Aurora
10 = LPD

As discussed here the idx parameter i the querystring is not the Domoticz device idx but a hidden "internal Z-wave device idx".

There are some oddities though. If you select an animation program and switch to solid light, it will not switch on the same animation program again (next time). That is, you'd have to turn on another animation program first (turn the animation program off first will also work). Another thing is that if you send several commands without a delay, the device will generate a z-wave timeout. If we use a short delay it will work, almost every time.

Below is an example dzVents script. In current dzVents version (2.3.1) we can not use delays for the openURL command. Thats why I use the function delayedOpenURL() in my script.

I've created a selector switch to trigger the script.

Code: Select all

Level	Level name
0	Off		
10	Fireplace
20	Storm
30	Rainbow
40	Aurora
50	LPD
60	Solid RED

Code: Select all

return {
	active = true,
	logging = {
		level = domoticz.LOG_DEBUG,
		marker = 'RGBW'
	},
	on = {
		devices = {
			'RGBW Selector'
		},
	},
	data = {
		last_animation_program = {initial=0}
	},
	execute = function(domoticz, device)

		local RGB_ANIMATION_OFF = 0
		local RGB_ANIMATION_FIREPLACE = 10
		local RGB_ANIMATION_STORM = 20
		local RGB_ANIMATION_RAINBOW = 30
		local RGB_ANIMATION_AURORA = 40
		local RGB_ANIMATION_LPD = 50
		local RGB_DEV = 337
		local RGB_ZW_INT_NODE = 75 -- See: https://www.domoticz.com/forum/viewtopic.php?t=8605

		local function delayedOpenURL(url, delay)
			delay = delay or 0
			if delay == 0 then
				domoticz.openURL(url)
			else
				domoticz.log('Requesting url '..url..' with a delay of '..tostring(delay)..' seconds', domoticz.LOG_DEBUG)
				os.execute('(sleep '..delay..';curl -s "'..url..'" > /dev/null)&')
			end
		end

		local function setRGBWAnimation(rgbAnimation)
			--  Add the number 6-10 to query string, base64- and URL encoded
			local url = domoticz.settings['Domoticz url']..'/json.htm?type=command&param=applyzwavenodeconfig&idx='..RGB_ZW_INT_NODE..'&valuelist=72_'

			local delay = 0
			if rgbAnimation == domoticz.data.last_animation_program then
				if rgbAnimation ~= RGB_ANIMATION_OFF then 
					delayedOpenURL(url..'MQ%3D%3D', 0) -- Switch off the animation program first
					delay = 2
				end
			else
				domoticz.data.last_animation_program = rgbAnimation
			end

			if rgbAnimation == RGB_ANIMATION_OFF then
				delayedOpenURL(url..'MQ%3D%3D', delay)
			elseif rgbAnimation == RGB_ANIMATION_FIREPLACE then
				delayedOpenURL(url..'Ng%3D%3D', delay)
			elseif rgbAnimation == RGB_ANIMATION_STORM then
				delayedOpenURL(url..'Nw%3D%3D', delay)
			elseif rgbAnimation == RGB_ANIMATION_RAINBOW then
				delayedOpenURL(url..'OA%3D%3D', delay)
			elseif rgbAnimation == RGB_ANIMATION_AURORA then
				delayedOpenURL(url..'OQ%3D%3D', delay)
			elseif rgbAnimation == RGB_ANIMATION_LPD then
				delayedOpenURL(url..'MTA%3D', delay)
			end
		end

		local function setRGBWChannels(vBrightness, vHex)
			local url = domoticz.settings['Domoticz url']..'/json.htm?type=command&param=setcolbrightnessvalue&idx='..RGB_DEV..'&hex='..vHex..'&brightness='..vBrightness..'&iswhite=false'
			domoticz.openURL(url)
		end

		if device.level <= 50 then
			setRGBWAnimation(device.level)
		else
			setRGBWChannels(100, 'ff0000') -- Solid RED
		end

	end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest