Page 1 of 1

Set value of Dimmer without turning the switch on

Posted: Friday 07 June 2024 22:26
by lnrdnl
Hi all,

Does anybody know if it is possible to set the level of a dimmer without switching the device on?

It seems properties of the dimmer (or switch) object in DzVents are readonly. So the only possible way to mutate them is by using the corresponding methods. So this does not work:

Code: Select all

dimmer.level = 20
This does:

Code: Select all

dimmer.setLevel(20)
dimmer.dimTo(20)
I think mutating properties with methods is very convenient and good practice. BUT! I would like to set the level without switching the device on. The reason I want to do this is because I would like to keep the "switching" logic in one script. And the "value" logic in another (based on sensor values from lux sensors).

What I tried so far is:

Code: Select all

dimmer.level = 20
--
dimmer.setLevel(20).silent()
--
dimmer.dimTo(30).afterSec(4)
dimmer.cancelQueuedCommands()
Any ideas? Thanks in advance!

Re: Set value of Dimmer without turning the switch on

Posted: Friday 07 June 2024 22:38
by waltervl
It is the same with the normal user interface. As soon as you change the dimmer setting the device will switch on. So probably no way to override.

So you have to overthink your logic and merge the scripts....

Re: Set value of Dimmer without turning the switch on  [Solved]

Posted: Friday 07 June 2024 22:42
by lnrdnl
I think it is not possible. I use Zigbee2MQTT to control the actual device and even there it is not possible.

So now I solved it by storing the LevelToSet as a Domoticz variable. From the "value" logic scripts I update the Domoticz variable. And in the "switching" scripts I use

Code: Select all

dimmer.setLevel(domoticz.variables('LevelToSet').value)
Tradeoff is that I need a little more logic for switching on and off because I can't use

Code: Select all

dimmer.toggleSwitch()
anymore.

Re: Set value of Dimmer without turning the switch on

Posted: Friday 07 June 2024 23:50
by HvdW
Let the value of the dimmer be read by another switch.

Re: Set value of Dimmer without turning the switch on

Posted: Saturday 08 June 2024 0:31
by waltervl
Why not just have the lux sensor trigger the lights on/off including dimmer level?
I have a script like this running without issues.

Re: Set value of Dimmer without turning the switch on

Posted: Saturday 08 June 2024 10:13
by lnrdnl
waltervl wrote: Saturday 08 June 2024 0:31 Why not just have the lux sensor trigger the lights on/off including dimmer level?
I have a script like this running without issues.
Because for this specific light I want a motion sensor and a simple switch to trigger it (not auto switching). But I want the value based on the lux sensor. I could make a specific script for only this device, but I would rather keep the logic seperated. The way I solved it now is working perfectly. Case closed.

I now have the Lux sensor script reading and evaluating all lux sensors and switching dummies and setting the variable: LevelToSet.
Dummies:
IsLightInside
IsLightOutside
IsLightGarage

One script for handling all the motion sensors.

And one script for handling all the switches (including the dummies).