I've got a ceiling LEDs connected to the ESPEasy and MOSFET. I have a nice slider in Domoticz, that works well.
Code: Select all
-- LED dimmer script script using ESPEasy
commandArray = {}
DomDevice = 'ESP_dimmer';
IP = '192.168.0.108';
PIN = "2";
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 .. ",500'";
os.execute(runcommand);
print("PWM value= "..CalcValue);
end
return commandArray
But there are some bumps:
I try to release the dimming by the TV, but, despite the TV state is discovered well (the log says the tv is on or off), I can't make the dimmer work with that.
I tried a blockly scheme without success. Then I tried a dzVents script, also without succes.
Code: Select all
return {
on = {
devices = {'Telewizor_Philips','ESP_dimmer' }
},
execute = function(domoticz, Telewizor_Philips)
if Telewizor_Philips.state==('On') then
commandArray['Scene:Brighten_LED']='On'
domoticz.log('Light dimmed - TV on ')
else
commandArray['Scene:Dim_LED']='On'
domoticz.log('Light brighten - tv off ')
end
end
}
return commandArray