This works great.
Now I would create an Rotary-encoder on the esp-12 for a wall dimmer ,then I can dim not only with an IPad.
I have connect the Rotary-encoder to the esp and I can see the values in the espeasy-menu.
How can I implement this that it's work with Domoticz?
Code: Select all
ommandArray = {}
DomDevice = 'dimmer_1' ---naam van de dimmer zoals deze in domoticz staat
IP = '192.168.1.101' ---ip adres van de esp
Port ='16' ---port van de esp
fade_time ='100' ---laat het dimmen gelijdelijk gaan
DomValue = (otherdevices_svalues[DomDevice]);
---Als in Domoticz op de uit knop gedrukt gaat de waarde van de esp naar 0
if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then DomValue = 0;
print ("Turning off " .. DomDevice);
os.execute('curl -s '..(IP)..'/control?cmd=PWM,'..(Port)..',0',(fade_time));
end
---Als in Domoticz op de aan knop gedrukt gaat de waarde van de esp naar 1
if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='On') then DomValue = 1;
print ("Turning on " .. DomDevice);
os.execute('curl -s '..(IP)..'/control?cmd=PWM,'..(Port)..',1',(fade_time));
end
---Als in Domoticz met de slider wordt bewogen veranderd de dimwaarde
---Calcvalue = waarde van 0 tot 1023
---DomValue = waarde van de slider 0 tot 100%
if devicechanged[DomDevice] then
CalcValue = DomValue ^ 1.5051; ---- DomValue ^ logaritmische waarde om de overgang natuurlijker te maken
print ("Write value to IP-adres " ..(IP).." Port " ..(Port).." ")
print ("Value received from Domoticz was " .. (DomValue) .." ");
print ("Calculated value for ESP is " .. (CalcValue) .." ");
print ("Dimming " .. (DomDevice) .. " to " .. (CalcValue) .. " ");
print ("Dimming " .. (DomDevice) .. " in " .. (fade_time) .. " msec");
print( os.execute('curl -s '..(IP)..'/control?cmd=PWM,'..(Port)..','..(CalcValue)..','..(fade_time)));
end
end
end
return commandArray