Page 1 of 1
Increase or decrease value
Posted: Friday 03 February 2017 15:40
by VHK17
I want to set the value of a dimmer dependent on the measured lux of a sensor
How can i Increase or decrease value of the value of the dimmer ?

- Naamloos.jpg (40.3 KiB) Viewed 1374 times
Re: Increase or decrease value
Posted: Friday 03 February 2017 15:47
by Egregius
Blockly can't do calculations. Use a lua/php/... script.
Re: Increase or decrease value
Posted: Friday 03 February 2017 16:19
by Toulon7559
With Blocky a (rather rude) approach would be to apply a series of IF-DO-statements to divide the control range in some steps, like you have started to do in your question.
For a 'fluent/smooth' solution, Egregius' response is applicable.
Re: Increase or decrease value
Posted: Saturday 04 February 2017 14:26
by VHK17
In Blockly i have it running, but indeed is not smooth.
Now trying to get it done in lua.
But i am a noob in lua.
What is wrong ?
Code: Select all
commandArray = {}
if (devicechanged['Pir_keuken'] == 'on' and otherdevices['Lux_keuken'] < '130') then
commandArray['Dimmer_erker']='On' --'On FOR 15'
commandArray['Variable:Dimmer_erker']= uservariables["Set_lux_keuken"]
commandArray['Variable:Set_lux_keuken']= tostring(uservariables["Set_lux_keuken"] +1)
elseif (devicechanged['Pir_keuken'] == 'on' and otherdevices['Lux_keuken'] > '130') then
commandArray['Dimmer_erker']='On' --'On FOR 15'
commandArray['Variable:Dimmer_erker']= uservariables["Set_lux_keuken"]
commandArray['Variable:Set_lux_keuken']= tostring(uservariables["Set_lux_keuken"] -1)
end
return commandArray