Page 1 of 1
Switch does not switch
Posted: Wednesday 22 October 2025 22:00
by vco1
I have a couple of scripts for NodOn Soft Remotes. They basically just switch on/off several lights based on the button pressed on the remote.
For one of these scripts one ZWave switch is not working anymore. That is, the light does not turn on or off based on the button clicked on the remote. Strange thing is that if I assign another switch (lamp) to this event, everything works as expected. And b.t.w. for this particular light it used to work too.
In the script I have my switches/lights defined as follows.
The Id is correct. And the light is functioning properly from the Domoticz UI as well as through the Alexicz skill. It just doesn't get triggered through the dzVents script.
What am I missing here?
Re: Switch does not switch
Posted: Wednesday 22 October 2025 22:18
by Piacco
local lampBalcony = dz.devices(123)
Re: Switch does not switch
Posted: Thursday 23 October 2025 8:48
by vco1
That's done later in the script.
Problem is that it ain't working for switch with id 123 but it is working for id 456 (a different switch/light).
Id123 does work when testing it through the API, e.g. through Postman.
Re: Switch does not switch
Posted: Thursday 23 October 2025 10:47
by habahabahaba
So
show the full script
Re: Switch does not switch
Posted: Thursday 23 October 2025 16:37
by vco1
So
Code: Select all
local lampReading = 123
local lampBookcase = 456
local lampBalcony = 789
return {
on = {
devices = {
'$NodOn Soft Remote Grey_scene_state_scene_001_0',
'$NodOn Soft Remote Grey_scene_state_scene_001_3',
'$NodOn Soft Remote Grey_scene_state_scene_002_0',
'$NodOn Soft Remote Grey_scene_state_scene_003_0',
'$NodOn Soft Remote Grey_scene_state_scene_004_0'
},
},
execute = function(dz, nodOn)
local function switchSingle(dzLight)
if dzLight.state ~= 'On' then
dzLight.switchOn()
else
dzLight.switchOff()
end
end
local function switchScene(dzScene)
if dzScene.state ~= 'On' then
dzScene.switchOn()
else
dzScene.switchOff()
end
end
if nodOn.name == '$NodOn Soft Remote Grey_scene_state_scene_001_0' then
switchSingle(dz.devices(lampBookcase))
elseif nodOn.name == '$NodOn Soft Remote Grey_scene_state_scene_001_3' then
switchScene(dz.groups('Living Room'))
elseif nodOn.name == '$NodOn Soft Remote Grey_scene_state_scene_002_0' then
switchSingle(dz.devices(lampBalcony))
elseif nodOn.name == '$NodOn Soft Remote Grey_scene_state_scene_003_0' then
switchScene(dz.groups('Living room'))
elseif nodOn.name == '$NodOn Soft Remote Grey_scene_state_scene_004_0' then
switchSingle(dz.devices(lampReading))
end
end
}
lampBalcony is not working. If I replace the Id from lampBalcony by that of another switch, all is working fine. And the actual switch for lampBalcony is also functioning properly from the Domoticz UI as well as via the API of Alexicz.
Re: Switch does not switch
Posted: Thursday 23 October 2025 17:04
by waltervl
Is device lampBalcony the same type of device as the other switches?
Further to that dzvents has the build in toggleSwitch() or toggleGroup() function, no need to write your own switchSingle() function:
https://wiki.domoticz.com/DzVents:_next ... ctor_etc.)
A Domoticz scene can only be switched on, not toggled. A Domoticz group can be toggled or switched on and off.
Re: Switch does not switch
Posted: Thursday 23 October 2025 22:10
by vco1
waltervl wrote: Thursday 23 October 2025 17:04
Is device lampBalcony the same type of device as the other switches?
Yes. They're all on/off switches.
Re: Switch does not switch
Posted: Friday 24 October 2025 6:13
by habahabahaba
What if to replace
dz.devices(lampBalcony) - with exact name of that lamp?
dz.devices('name_of_the_lamp') ?
Re: Switch does not switch
Posted: Friday 24 October 2025 10:06
by FlyingDomotic
Would it be possible to have a screenshoot of lampBalcony device (find it in "switch" tab, click on "Modify" and take the screenshoot)?
What kind of hardware do you have behind it (ZigBee, Wifi,...)?
Do you have some error in log when trying to manually change its state from Domoticz (switch it on and off)?
Re: Switch does not switch
Posted: Friday 24 October 2025 13:12
by waltervl
habahabahaba wrote: Friday 24 October 2025 6:13
What if to replace
dz.devices(lampBalcony) - with exact name of that lamp?
dz.devices('name_of_the_lamp') ?
Indeed: Dzvents cannot handle 2 devices with exactly the same name. The device name should be unique.
Re: Switch does not switch
Posted: Saturday 25 October 2025 9:07
by vco1
waltervl wrote: Friday 24 October 2025 13:12
Indeed: Dzvents cannot handle 2 devices with exactly the same name. The device name should be unique.
And that turned out to be the cause of the issue. I had 2 devices with the same name. Two completely different types of devices - a temperature sensor and a switch - but the same name anyway.
After renaming one, all is fine and dandy again. I thought/hoped that using Id's in scripts would make devices unique. But apparently not.
Thanks for pointing me in the right direction. Problem solved.