Confusion regarding dim levels (getting vs setting)

Moderator: leecollings

Post Reply
nillon
Posts: 2
Joined: Friday 21 February 2014 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Confusion regarding dim levels (getting vs setting)

Post by nillon »

I'm just starting out with some Lua scripting for Domoticz...

On thing I would like to do is an event that when a PIR triggers, I want to set a specific dimmer to 100 percent, and when the PIR is no longer active, I want to change the dimmer back to whatever state it was before (usally around 40 percent or off). My idea is a script that when the PIR triggers, write the dimmers state to a text file and then set the dimmer to 100 percent, and when the PIR changes state again, read the previous value from the text file and set it back to that.
However, it seems that when you get the svalues for the device, the dim levels are in 16 steps, from 0-15, but when you set the dim level, you are suposed to set it as a percentage value (0-100)? This seems a little confusing to me... or is there another way to get/set these values?
nillon
Posts: 2
Joined: Friday 21 February 2014 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Confusion regarding dim levels (getting vs setting)

Post by nillon »

I got this working now, I did a kind of ugly workaround:

When the PIR triggers, I save the value of the dimmed device to a text file. When the PIR is no longer active, I load the saved value from the text file and multiply it with 7, and that gives me (kind of) the original value.
I think, however, a better solution would be to use the step values (0-15) when setting dim levels from lua scripts, and only use percentage in the GUI.
Robert
Posts: 16
Joined: Saturday 01 March 2014 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Confusion regarding dim levels (getting vs setting)

Post by Robert »

can you post your script??
Would be interesting!
trixwood

Re: Confusion regarding dim levels (getting vs setting)

Post by trixwood »

You could use an uservariable for that instead of writing a variable to file:

https://www.domoticz.com/wiki/User_variables
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest