Code: Select all
-- LED dimmer script script using ESPEasy
commandArray = {}
DomDevice = 'ESP_dimmer';
IP = 'xxxx';
PIN = "xx";
if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
print ("OFF dim = "..uservariables['dimmer']);
CalcValue = 0;
else if(devicechanged[DomDevice]=='On') then
DomValue = uservariables['dimmer'];
print ("ON dim = "..uservariables['dimmer']);
CalcValue = DomValue;
else
print("Other");
DomValue = otherdevices_svalues[DomDevice];
CalcValue = math.floor(DomValue / 100 * 1023);
commandArray['Variable:dimmer'] = tostring(CalcValue);
print ("dim Level = "..uservariables['dimmer']);
end
end
runcommand = "curl 'http://" .. IP .. "/control?cmd=PWM," ..PIN.. "," .. CalcValue .. "'";
os.execute(runcommand);
print("PWM value= "..CalcValue);
end
return commandArray
However, if I power off and then power on the ESP8266, the LED strip remains off, even though Domoticz shows the dimmer as on (and at its last dim value).
Is there any way in LUA (or dzVents) to change the device state on power on?