I am toy-ing with a ESP8266 and want to set the PWM functionality from Domoticz.
After a few hours (ahum) i scratched this lua script together:
Code: Select all
local Url_espdimmer ='192.168.0.107'
commandArray = {}
if (devicechanged['Virtual2']~=nil) then --Test for checking only this device
--The ESP have a range from 0 to 1024 so multiply with 10.24
print(" ==> Virtual2 " .. tostring(devicechanged['Virtual2']) .. " state )")
local dvalue = tonumber(otherdevices_svalues['Virtual2'])
dvalue = dvalue * 10.24
print(" ==> to change for dimmer " .. tostring(dvalue) .. " new value )")
commandArray['OpenURL']='http://' .. Url_espdimmer.. '/control?cmd=PWM,2,' .. tostring(dvalue) .. ' '
end
return commandArray
Every time i set a new level with Virtual2 the PWM is updated....
Only when i switch on (no Set Level) the level value = 0 while in the GUI there is still 30% for example.
So how can i get the previous level (in the web interface the level stay's visible).
Can it be done without creating uservariables ?
Tnx in advance,
Stefan.