Rotary-encoder en Domoticz

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

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 = '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

frankverd
Posts: 4
Joined: Sunday 18 March 2018 16:27
Target OS: -
Domoticz version:
Contact:

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

frankverd
Posts: 4
Joined: Sunday 18 March 2018 16:27
Target OS: -
Domoticz version:
Contact:

Re: Rotary-encoder en Domoticz

Post by frankverd » Tuesday 19 June 2018 13:34

Hi Roland.

Maybe you can give me a hint after playing arround for weeks without results connecting a rotary switch to my ESP8266 for dimming function.
The rotery switch is counting up and down in my esp8266 and dimer is working via the slider using you script thank you for that.
But how do i implement the rotary swicth to controle the dimmer funtion.

Thanks in advanced.

I'm using Domoticz

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests