Rotary-encoder en Domoticz

Everything about esp8266 and more.
Post Reply
Posts: 181
Joined: Tuesday 24 December 2013 0:36
Target OS: Raspberry Pi
Domoticz version: Newest
Location: Netherlands Helmond

Rotary-encoder en Domoticz

Post by rhendriks » Sunday 20 August 2017 21:19

I run a dimmer-script with an esp-12 in Domoticz dzEvents.
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 = ''					---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));
 	---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));
	---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)));
  return commandArray

Posts: 2
Joined: Sunday 18 March 2018 16:27
Target OS: -
Domoticz version:

Re: Rotary-encoder en Domoticz

Post by frankverd » Monday 19 March 2018 14:17

Hi Rhendriks.
Did you Manage to get it working ?

Kind regars Frank Verdonk

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest