Increase or decrease value

Moderator: leecollings

Post Reply
VHK17
Posts: 11
Joined: Tuesday 31 January 2017 9:10
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Increase or decrease value

Post 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
Naamloos.jpg (40.3 KiB) Viewed 1353 times
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Increase or decrease value

Post by Egregius »

Blockly can't do calculations. Use a lua/php/... script.
Toulon7559
Posts: 849
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Increase or decrease value

Post 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.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
VHK17
Posts: 11
Joined: Tuesday 31 January 2017 9:10
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Increase or decrease value

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest