sub slave devices
Moderators: leecollings, remb0
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
sub slave devices
I have a question about sub slave devices, the manual said that it was the most difficult and complicated part and that seems to be true so i hope someone over here can help me.
What i want to acomplish:
i have two led strips, for now call them LED_strip1 and LED_strip2. If i turn LED_strip1 on i want LED_strip2 to turn on with it but when i turn on LED_strip2 i do not want LED_strip1 to turn on.
That i accomplished with the sub slave devices and it works fine but there is one problem, If i dim or change the color of LED_strip1 LED_strip2 does not dim or change color als LED_strip1 does, the sub slave device connection does seem to only affect the on/off state. is this normal behavior or am i configuring something wrong?
i hope someone can help me and possibly others.
What i want to acomplish:
i have two led strips, for now call them LED_strip1 and LED_strip2. If i turn LED_strip1 on i want LED_strip2 to turn on with it but when i turn on LED_strip2 i do not want LED_strip1 to turn on.
That i accomplished with the sub slave devices and it works fine but there is one problem, If i dim or change the color of LED_strip1 LED_strip2 does not dim or change color als LED_strip1 does, the sub slave device connection does seem to only affect the on/off state. is this normal behavior or am i configuring something wrong?
i hope someone can help me and possibly others.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
no one an idea?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
Re: sub slave devices
afaik is usable only for on/off state...
you will have to use some sort of script (dzvents)
you will have to use some sort of script (dzvents)
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
too bad i am not really good at that sort of thing, blockly is what i use and some example lua scripts.
i can read most things in scripts but writing them is a whole other level, respect to those who can!
but if any one has some spare time, feel free to suggest something because i have no idea how i can accomplish that.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
This might help:snellejellep wrote: ↑Friday 25 May 2018 14:11 ....
but if any one has some spare time, feel free to suggest something because i have no idea how i can accomplish that.
Code: Select all
--[[ LEDSlaveDemo.lua (tested and working on dzVents 2.4.5)
]]--
return {
on = { devices = { "LED_strip1" } },
logging = { level = domoticz.LOG_INFO, -- switch to LOG_DEBUG when needed
marker = "LEDSlaveDemo" },
execute = function(dz, trigger)
local slave = dz.devices("LED_strip2")
dz.log(trigger.name .. " state: " .. trigger.state ..", dimlevel: " .. trigger.level .. "%" ,dz.LOG_DEBUG)
if trigger.state == "On" then
slave.switchOn().checkFirst() -- remove the checkFirst() if you also control the on/off state of this dimmer outside domoticz
slave.dimTo(trigger.level)
else
slave.switchOff().checkFirst() -- remove the checkFirst() if you also control the on/off state of this dimmer outside domoticz
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
wow thanks, i will check that out! and thanks for the comments in the code, maby i can pick up something from that and try it out myself. again, massive thanks!waaren wrote: ↑Saturday 26 May 2018 17:38This might help:snellejellep wrote: ↑Friday 25 May 2018 14:11 ....
but if any one has some spare time, feel free to suggest something because i have no idea how i can accomplish that.
Code: Select all
--[[ LEDSlaveDemo.lua (tested and working on dzVents 2.4.5) ]]-- return { on = { devices = { "LED_strip1" } }, logging = { level = domoticz.LOG_INFO, -- switch to LOG_DEBUG when needed marker = "LEDSlaveDemo" }, execute = function(dz, trigger) local slave = dz.devices("LED_strip2") dz.log(trigger.name .. " state: " .. trigger.state ..", dimlevel: " .. trigger.level .. "%" ,dz.LOG_DEBUG) if trigger.state == "On" then slave.switchOn().checkFirst() -- remove the checkFirst() if you also control the on/off state of this dimmer outside domoticz slave.dimTo(trigger.level) else slave.switchOff().checkFirst() -- remove the checkFirst() if you also control the on/off state of this dimmer outside domoticz end end }
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
On / Off and dimLevel is now handled in the script but Color and brightness is a small challenge. What type / subtype are your LED strips ?snellejellep wrote: ↑Thursday 24 May 2018 15:30 If i dim or change the color of LED_strip1 LED_strip2 does not dim or change color als LED_strip1 does, the sub slave device connection does seem to only affect the on/off state. is this normal behavior or am i configuring something wrong?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
i noticed that when i dim it turns off the "slave" and when i dim again it turns back on, i dont know if that is normal or not but i wanted to mention that.
for what led strips i use: the so called master is an philips hue led strip and the slave a yeelight led strip.
if you need more information/tests etc. feel free to ask
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
Thx for your reply.
I was referring to the type / subtype as displayed in the devices tab.
When I have that info I will play a little bit further with the script and also try to copy the color and brightness Will then also look into your remark that the slave switches off when you dim the master the first time.
I was referring to the type / subtype as displayed in the devices tab.
When I have that info I will play a little bit further with the script and also try to copy the color and brightness Will then also look into your remark that the slave switches off when you dim the master the first time.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
well i do not have dzvents hardware but these are my devices


i hope this helps you?


i hope this helps you?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
@snellejellep,
DzVents weather is just a name of one of my dummy hardware. In use only to define virtual devices.
and yes this is the information I need to continue my little script puzzle. Will get back to you once I have something and tested the different scenarios.

and yes this is the information I need to continue my little script puzzle. Will get back to you once I have something and tested the different scenarios.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
@waaren,
i tried the script, it does work fine when i use the switches in domoticz but when i use my hue dimmer switch that i have on the wall it does not seem to react. or is it because i first saved the script, tried it and then realized that there were comments that said i had to remove the checkfirst, which i did afterwards? because i saw in the log that it created a lua script? so maby that is not updated when i update in domoticz? i cant seem to find it in the logs
i tried the script, it does work fine when i use the switches in domoticz but when i use my hue dimmer switch that i have on the wall it does not seem to react. or is it because i first saved the script, tried it and then realized that there were comments that said i had to remove the checkfirst, which i did afterwards? because i saw in the log that it created a lua script? so maby that is not updated when i update in domoticz? i cant seem to find it in the logs
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
Please try this updated script. Much obliged if you could report your findings. Master - Slave setup with colors is not completely straight forward as the time the script is triggered the color value is not yet landed in dzVents. So script must be forced to execute a second time.snellejellep wrote: ↑Monday 28 May 2018 19:19 @waaren,
i tried the script, it does work fine when i use the switches in domoticz but when i use my hue dimmer switch that i have on the wall it does not seem to react. or is it because i first saved the script, tried it and then realized that there were comments that said i had to remove the checkfirst, which i did afterwards? because i saw in the log that it created a lua script? so maby that is not updated when i update in domoticz? i cant seem to find it in the logs
To do this a couple of vars must be stored in the data section.
I tested with a HUE bulb and a Yeelight bulb and color is following now but still look a bit different.
Code: Select all
--[[ LEDSlaveDemo.lua (tested and working on dzVents 2.4.6) but probably also working on earlier versions
]]--
return {
on = { devices = {"LED_strip1" } },
logging = { level = domoticz.LOG_DEBUG, -- switch to LOG_INFO when results are OK
marker = "LEDSlaveDemo" },
data = { setColor = { initial = true }, -- This is necessary because color does not follow in the first pass
dimLevel = { initial = 50 },
color = { initial = {} }},
execute = function(dz, trigger)
local slave = dz.devices("LED_strip2")
dz.log("Master ( name / state / level / color ) ( " ..
trigger.name .. " / " ..
trigger.state .. " / " ..
trigger.level .. " / " ..
trigger.color .. " )",dz.LOG_DEBUG)
colorTable = dz.utils.fromJSON(trigger.color) -- convert color (a json string) to a Lua table
if trigger.state ~= "Off" and trigger.level > 0 then -- State can be "On", "Off" or "set Color"
dz.data.dimLevel = trigger.level
dz.data.color = trigger.color
slave.setRGB( colorTable.r, colorTable.g, colorTable.b )
slave.dimTo(tonumber(dz.data.dimLevel))
if dz.data.setColor then -- We need to trigger the script another time as the color
dz.data.dimLevel = trigger.level -- does not follow the first pass. Does not seem timing but looks like
trigger.dimTo(dz.data.dimLevel) -- dzVents is not yet updated with right color values from master
dz.data.setColor = false
else
dz.data.setColor = true
end
else
slave.switchOff()
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: sub slave devices
it now works! wow! thanks! only one small thing is that it does not seem to mirror te color to the second strip? or maby that is because the hue strip is an rgbw strip with two white tone leds in addition to the rgb ones and the yeelight only has the rgb ones. but sill, massive thanks!
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
[EDIT]snellejellep wrote: ↑Tuesday 29 May 2018 8:07 it now works! wow! thanks! only one small thing is that it does not seem to mirror te color to the second strip? or maby that is because the hue strip is an rgbw strip with two white tone leds in addition to the rgb ones and the yeelight only has the rgb ones. but sill, massive thanks!
Error was "Error opening url: http://127.0.0.1:8080/json.htm?param=se ... hite=false"
this means dzVents has no access to the domoticz API via a HTTP json call
Solution: SETUP -> SETTINGS -> SYSTEM -> SYSTEM SETUP
[ LOCAL NETWORKS (NO USERNAME / PASSWORD ]
enter (at least) 127.0.0.*
after [APLLY SETTINGS] dzVents will be able to send / receive information to/ from domoticz using HTTP json calls
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 24
- Joined: Tuesday 17 October 2017 19:38
- Target OS: NAS (Synology & others)
- Domoticz version: 4.10603
- Contact:
Re: sub slave devices
@waaren
Thanks for your example, just the thing i was looking for but could you maybe explain how to use it?
If i understand it correctly i should make Led_strip2 a slave of Led_strip1, then i add your script as a Lua Device (or All) script or should i add it as a dzVents script and again Device?
Thanks in advance.
Thanks for your example, just the thing i was looking for but could you maybe explain how to use it?
If i understand it correctly i should make Led_strip2 a slave of Led_strip1, then i add your script as a Lua Device (or All) script or should i add it as a dzVents script and again Device?
Thanks in advance.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
Using this script Led_strip2 will follow state and color of Led_strip1. No need to set anything else as long as the device types / subtypes are the same.schumi2004 wrote: ↑Thursday 07 March 2019 19:07If i understand it correctly i should make Led_strip2 a slave of Led_strip1, then i add your script as a Lua Device (or All) script or should i add it as a dzVents script and again Device?
How you add the script using the event editor does not change the behavior of it. That choice does only change the template used in the editor but you should overwrite it completely with this script.
Hope this clarifies.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 24
- Joined: Tuesday 17 October 2017 19:38
- Target OS: NAS (Synology & others)
- Domoticz version: 4.10603
- Contact:
Re: sub slave devices
Hi waaren,
Thanks for the feedback.
Eventually i got it running without errors but for some reason the Strip2 did not follow Strip1 although devices are the same.
Maybe it's because of a misconfiguration on my side but i will debug that later tomorrow.
Thanks for the feedback.
Eventually i got it running without errors but for some reason the Strip2 did not follow Strip1 although devices are the same.
Maybe it's because of a misconfiguration on my side but i will debug that later tomorrow.
-
- Posts: 24
- Joined: Tuesday 17 October 2017 19:38
- Target OS: NAS (Synology & others)
- Domoticz version: 4.10603
- Contact:
Re: sub slave devices
Is it possible to use this also for Ikea Tradfri Bulb's ?
I tried but it returned an error.
2019-04-25 19:56:05.357 Status: dzVents: Error (2.4.18): Ikea GU10 Comp Nis Slave: An error occured when calling event handler Computer NIS Slave
2019-04-25 19:56:05.357 Status: dzVents: Error (2.4.18): Ikea GU10 Comp Nis Slave: ...scripts/dzVents/generated_scripts/Computer NIS Slave.lua:21: attempt to concatenate field 'color' (a nil value)
Is that because Tradfri lights don't actual have a color option?
I tried but it returned an error.
2019-04-25 19:56:05.357 Status: dzVents: Error (2.4.18): Ikea GU10 Comp Nis Slave: An error occured when calling event handler Computer NIS Slave
2019-04-25 19:56:05.357 Status: dzVents: Error (2.4.18): Ikea GU10 Comp Nis Slave: ...scripts/dzVents/generated_scripts/Computer NIS Slave.lua:21: attempt to concatenate field 'color' (a nil value)
Is that because Tradfri lights don't actual have a color option?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: sub slave devices
I am afraid not. I don't own Ikea bulbs but understand they are managed by a plugin.schumi2004 wrote: ↑Thursday 25 April 2019 19:59 Is it possible to use this also for Ikea Tradfri Bulb's ?
Yes. The script can only work if both source use the color field. Maybe you can ask the developer of the plugin if this master / slave function can be implemented ?Is that because Tradfri lights don't actual have a color option?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Google [Bot] and 1 guest