Openhab-> MQTT-> EasyESP-> LED Dimmer

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ultraschall81
New user
Posts: 3
Joined: 18 Feb 2016, 20:31

Openhab-> MQTT-> EasyESP-> LED Dimmer

#1 Post by ultraschall81 » 22 Feb 2016, 09:33

Hi,

this weekend I startet with openhab (on RPI) and easyESP. I really like this software and after playing around I have some usefull applications in my mind.
I use an ESP-01 connected to a proto-board with DS18b20 (GPIO 0) and LED (GPIO 2) and are able to read and display the temperature and switch the LED on/off.
Now, I want to implement the dimming function over mqtt messages.
fyi: Later I want to control an Aquarium-LED and want to simulate the sunrise / sunset.
Is this possible with the easyESP-SW?
If yes, how is the mqtt command for the pwm value?
Something like:
Dimmer AQUALED1 "Dimmer [%s %%]" {mqtt=">[localbroker:/aqualed/gpio/2:command:PWM:<value>]"}

Thanks for your help.

br
Christian

ultraschall81
New user
Posts: 3
Joined: 18 Feb 2016, 20:31

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#2 Post by ultraschall81 » 24 Feb 2016, 13:15

Nobody????

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#3 Post by tozett » 25 Feb 2016, 08:14

i searched the forum for "mqtt" and "pwm" and found some hints.
seems that mqtt cannot control pwm on an ESPeasy..
my you have a look yourself?

http:+pwm:
http://www.esp8266.nu/index.php/GPIO

http+pwm-fade:
http://www.esp8266.nu/forum/viewtopic.p ... +pwm#p4315

mqtt:
http://www.esp8266.nu/forum/viewtopic.p ... 3601#p3601

mqtt more detail:
http://www.esp8266.nu/forum/viewtopic.p ... +pwm#p4199

Martinus

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#4 Post by Martinus » 25 Feb 2016, 08:40

ultraschall81 wrote:Nobody????
You should be able to replace "gpio" with "pwm". So instead of this sample:

Code: Select all

Switch MQTTLED {mqtt=">[localbroker:/openhabdemo/gpio/2:command:ON:1],>[localbroker:/openhabdemo/gpio/2:command:OFF:0]"}
It should be:

Code: Select all

Switch MQTTLED {mqtt=">[localbroker:/openhabdemo/pwm/2:command:ON:512],>[localbroker:/openhabdemo/pwm/2:command:OFF:0]"}

Current version only supports gpio and pwm commands.
Next ESP edition will likely have the option to provide a full command, just like with the http protocol.
So with that edition, you can do stuff like this:

Code: Select all

Switch MQTTLEDPULSE {mqtt=">[broker:/openhabdemo/cmd:command:ON:pulse,2,0,500],>[broker:/openhabdemo/cmd:command:OFF:pulse,2,0,500]"}

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#5 Post by tozett » 25 Feb 2016, 15:12

just only to clarify the mqtt topic. (dont know openhab enough),
but if i do it with another mqttclient,

this

Code: Select all

Switch MQTTLED {mqtt=">[localbroker:/openhabdemo/gpio/2:command:ON:1],>[localbroker:/openhabdemo/gpio/2:command:OFF:0]"}
should look like this:

Code: Select all

mosquitto_pub -q 1 -d -t /esp3/GPIO/14 -m "0";
http://www.esp8266.nu/forum/viewtopic.p ... +pwm#p4097

or like this:

Code: Select all

mosquitto_pub -q 1 -d -t "/esp-sysname/gpio/2:command:ON:1"
edit2, found new post with this:

Code: Select all

Yes, it is possible.
I use:
esp GPIO:
sysname/pwm/2 with payload: 0-255
pca9685 GPIO
sysname/pcapwm/2 with payload: 0-4095
Top
http://www.esp8266.nu/forum/viewtopic.p ... read#p4538

which syntax is right for which firmware?
(meanwhile i try to check the source... :( )

ultraschall81
New user
Posts: 3
Joined: 18 Feb 2016, 20:31

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#6 Post by ultraschall81 » 26 Feb 2016, 08:10

Hi,

yesterday I tried : Switch MQTTLED {mqtt=">[localbroker:/openhabdemo/pwm/2:command:ON:512],>[localbroker:/openhabdemo/pwm/2:command:OFF:0]"}
which was not working at all. The led was always off.
On the Weekend, I will try the new command: sysname/pwm/2 with payload: 0-255

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#7 Post by tozett » 26 Feb 2016, 08:10

i checked the source, :shock: but i am somehow a coding noob and cant see anything :oops:

as far as i see, all possible MQTT output commands are hidden in each plugin separately. under the plugin_write section. or not?

so i think i cant find them at one place in the code.
if this is true for this archtectural decision,
i could be helpful for a normal user to have a serial-cmd
which iterates over the plugins and shows the user a list of possible (MQTT) output commands as a actual valid list.

Or am i wrong, somehow? :roll:

edit:
:mrgreen: if this would be working the MQTT-way with the IR-Send plugin from the Playground, it would be gorgoius! :mrgreen:

dabe5
New user
Posts: 6
Joined: 28 Feb 2016, 20:17

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#8 Post by dabe5 » 28 Feb 2016, 20:48

I got my ESP8266 RGB LED Dimmer running this way with OpenHAB:


in the .items File:

Code: Select all

/* RGB ESP8266 */
Number	RGB_OG05_2r		"LED rot [%s]"		<dimmer>		(gOG_S, Lights) { mqtt=">[dsbroker:/ESP-OG01-S/pwm/14:command:*:default]" }
Number	RGB_OG05_2g		"LED grün [%s]"		<dimmer>		(gOG_S, Lights) { mqtt=">[dsbroker:/ESP-OG01-S/pwm/12:command:*:default]" }
Number	RGB_OG05_2b		"LED blau [%s]"		<dimmer>		(gOG_S, Lights) { mqtt=">[dsbroker:/ESP-OG01-S/pwm/13:command:*:default]" }
Color	RGB_OG05_2		"Empire State"		<slider>		(gOG_S, Lights)
(Do not use the Item "Dimmer" here because it only accepts Values from 0 to 100 - we need to send up to 1000 so we use the "Number" item)


in the .rules File:

Code: Select all

    var HSBType hsbValue

    rule "Set RGB value"
    when
            Item RGB_OG05_2 changed
    then
            hsbValue = RGB_OG05_2.state as HSBType

			sendCommand( RGB_OG05_2r, hsbValue.red.intValue * 10)
			sendCommand( RGB_OG05_2g, hsbValue.green.intValue * 10)
			sendCommand( RGB_OG05_2b, hsbValue.blue.intValue * 10)
    end
was quite hard to get that running - and I am not a noob - I am in business since over 25 years. I like what's going on with esp/openhab and other IOT-stuff, but missing useful documentation for beginners/starters

Now I have it running with KNX - openHAB - MQTT - ESPEasy
btw: I have 12V drivers at the GPIO's that invert the GPIO signal, so maybe you have to invert the output somwhere else

Daniel

danielcdchen
New user
Posts: 4
Joined: 30 Jan 2016, 04:24

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#9 Post by danielcdchen » 12 Mar 2016, 09:48

Hi dabe5,

I got stuck here, can you show me the codes in .sitemap file?

Thanks.

dabe5
New user
Posts: 6
Joined: 28 Feb 2016, 20:17

Re: Openhab-> MQTT-> EasyESP-> LED Dimmer

#10 Post by dabe5 » 12 Mar 2016, 15:01

Well my .sitemap is allmost empty ;) :

Code: Select all

sitemap demo label="EFH"
{
	Frame {
		Group item=gOG label="Obergeschoss" icon="firstfloor"
		Group item=gEG label="Erdgeschoss" icon="groundfloor"
		Group item=gUG label="Keller" icon="cellar"	
	}
}
but you need to define a Room in the .items file:

Code: Select all

Group gOG_S		"Zimmer links"			<smiley> 	(gOG)
But this is all OpenHAB stuff.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests