Finished: H801 RGBWW control with openhab2 and mqtt

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Finished: H801 RGBWW control with openhab2 and mqtt

#1 Post by sledge » 22 Jan 2017, 20:25

Hi,

i´m trying to control rgbww stripes with the H801 rgbww controller from aliexpress: https://www.aliexpress.com/item/H801-Wi ... 79464.html
As i´m really new to espeasy i will use this thread to ask some questions and keep this first post updated to help others building a similar setup.
User Dev0 is developing a very promising plugin to controll rgb lights. Maybe this thread is a little help for him to get feedback and some documentation to get his plugin up and running.

Ok, lets go

1. Install latest Arduino Ide and prepare for esp8266
http://www.letscontrolit.com/wiki/index ... are_Upload

For the h801 i used this settings:
Board: Generic ESP8266 Module
Flash Mode: DIO
Flash Frequency: 40Mhz
CPU Frequency: 80 MHz
Flash Size: 1M (64K SPIFFS)
Upload Speed: 115200

2. build and flash espeasy with ESPEasy-Plugin-Lights

Download espeasy sources from http://www.letscontrolit.com/downloads/ ... 47_RC8.zip and extract
Download ESPEasy-Plugin-Lights and extract https://github.com/ddtlabs/ESPEasy-Plugin-Lights

Kopie _P123_LIGHTS.ino to ESPEasy_R147_RC8\Source\ESPEasy Folder

Open ESPEasy.ino with Arduino and flash to h801 (1 powered the h801 with 12V on the VCC and Ground Connector and just connected gnd, rx and tx to the ftdi programmer. Short the jumper on the h801 on startup to bring it in bootloader mode)

2a Use precompiled Image from Waldmensch

If you don´t want to compile yourself you can just flash the Image from Waldmensch. Thank you for compiling and uploading Waldmensch.
The Image is based on ESPEasy_R147_RC8 with ESPEasy-Plugin-Lights 1.0.4
You can get the image here https://forum.fhem.de/index.php/topic,6 ... #msg566916
But be careful, it seems that some h801 came with only 512kb Flash. This Image is only for Versions with 1024kb Flash size

3. Setup espeasy for first use
After successful flashing the h801 will open an access point called ESP_0
Connect to it and open browser pointed to 192.168.4.1/setup (i used my android cause laptop didn´t open the setup page)
Set your ssid and password and submit. The board will now connect to your wlan

Open Browser and go to the ip shown in last step or use http://devicename where devicename is the name you put in config (default: newdevice)

4. Setup mqtt credentials

under config set
Protocol: Openhab mqtt
locate controller: use hostname
controller hostname: hostname where your mqtt broker (mosquitto) is running
port: 1883

5 Setup ESPEasy-Plugin-Lights Plugin

Go to Devices and hit Edit button on first task

Set with
Device: Lights
Name: PWM
Delay: 0
IDX / Var: 0

Check "Enable RGB Channels"
Red Gpio: 15
Green Gpio: 13
Blue Gpio: 12

If you have a rgbw stripe check "Enable WW Channel"
WW Gpio: 14
WW Color Temp (Kelvin): 2000 //This depends on your leds but 2000 should be fine for warm white

If you have a rgbww stripe also check "Enable CW Channel"
CW Gpio: 4
CW Color Temp (Kelvin): 6000 //This depends on your leds but 6000 should be fine for cold white


6 Manually send mqtt command to test setup

Open putty and connect to your mosquitto server
Send a testcommand:

Code: Select all

 mosquitto_pub -t "/newdevice/cmd" -m "lights,rgb,00ff00"
This should set a nice solid green (assuming your device name is still "newdevice" otherwise change it to what your device name is)

7 Openhab settings
This are the settings for one h801 in openhab:

Sitemap:

Code: Select all

sitemap demo label="Main Menu"
{
	Frame label="Bath Light" {
		Slider		item=Bath_L_level
		Slider		item=Bath_L_temp
		Colorpicker	item=Bath_L_RGB	icon="slider"
	}
}
Items:

Code: Select all

Color  Bath_L_RGB	  "Color Select"	<slider>
Dimmer  Bath_L_level  "White Level [%s %%]" 
Dimmer  Bath_L_temp   "White Temperature [%s %%]"
//String gets update in Rule and sends Command to Device Name, e.G. newdevice
String Bath_L_CMD	{ mqtt=">[mosquitto:/newdevice/cmd:state:*:default]" }
Rules:

Code: Select all

import org.eclipse.smarthome.core.library.types.HSBType

rule "Bath Light "
when
	Item Bath_L_RGB received update
then
	var HSBType hsbValue = Bath_L_RGB.state as HSBType
	var String redpwmString = Integer::toHexString(hsbValue.red.intValue*255/100)
	var String greenpwmString = Integer::toHexString(hsbValue.green.intValue*255/100)
	var String bluepwmString = Integer::toHexString(hsbValue.blue.intValue*255/100)
	var String rgb_cmd = ("00"+redpwmString).substring(redpwmString.length()) + ("00"+greenpwmString).substring(greenpwmString.length()) + ("00"+bluepwmString).substring(bluepwmString.length());
    rgb_cmd = "lights,rgb," + rgb_cmd + ",1"
	Bath_L_CMD.postUpdate(rgb_cmd)	
end

rule "Bath Light Level"
when
	Item Bath_L_level received update
then
	Bath_L_CMD.postUpdate("lights,pct," + (Bath_L_level.state as DecimalType).intValue +",1")
end

rule "Bath Light Temperature"
when
	Item Bath_L_temp received update
then
	Bath_L_CMD.postUpdate("lights,ct," + ( (2000 + (Bath_L_temp.state as DecimalType).intValue * 40)) + ",1") // Sets The Range of Color Temperature (2000 + 0-100 * 40) gives a range from 2000 to 6000. Change this according your led´s color temperatures or leave defaults
end
This gives you a sidemap with 2 Sliders to set White Color Temperature und Level and a Colorpicker to set a Color
Last edited by sledge on 23 Jan 2017, 22:45, edited 6 times in total.

Waldmensch
Normal user
Posts: 11
Joined: 28 Nov 2016, 17:12

Re: H801 RGBWW control with openhab2 and mqtt

#2 Post by Waldmensch » 22 Jan 2017, 22:46

There is a little bug in Line 245 of lights plugin which avoids addressing the pins defined in webform

Replace:

Code: Select all

Plugin_123_pins[PinIndex].PinNo = ExtraTaskSettings.TaskDevicePluginConfigLong[PinIndex];
by:

Code: Select all

Plugin_123_pins[PinIndex].PinNo = Settings.TaskDevicePluginConfig[event->TaskIndex][PinIndex];
and re-compile/flash

mrwee
Normal user
Posts: 225
Joined: 31 Aug 2016, 12:52

Re: H801 RGBWW control with openhab2 and mqtt

#3 Post by mrwee » 22 Jan 2017, 22:57

Fantastic! Thanks for your post, I've been starting on the excact same project :).
Did you manage to implement a color-picker in OH2 working over MQTT?

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: H801 RGBWW control with openhab2 and mqtt

#4 Post by sledge » 23 Jan 2017, 00:03

Thank you Waldmensch,

i recompiled but it doesn´t work. Can you switch the leds with mqtt? How does an example command looks like? Which part is topic and wich part is message? Btw. bist du der Waldmensch von der fpv-community?

In my devices web log i see this:

Code: Select all

1146 : WIFI : Connecting... 1
8152 : WIFI : Connected!
8152 : INIT : I2C
8152 : INIT : SPI not enabled
8155 : INIT : Lights [RGB noWW noCW FADING CONSTBRI PON]
8169 : MQTT : Connected to broker
8172 : Subscribed to: /newdevice/#
8172 : INIT : Boot OK
8172 : INIT : Cold Boot
38173 : WD : Uptime 0 ConnectFailures 0 FreeMem 26344
247284 : INIT : Lights [RGB noWW noCW FADING CONSTBRI PON]
248699 : WD : Uptime 2 ConnectFailures 0 FreeMem 24664
278700 : WD : Uptime 3 ConnectFailures 0 FreeMem 26200
308701 : WD : Uptime 3 ConnectFailures 0 FreeMem 26184
334286 : FLASH: Settings saved
334352 : FLASH: Settings saved
338702 : WD : Uptime 4 ConnectFailures 0 FreeMem 26184
368703 : WD : Uptime 4 ConnectFailures 0 FreeMem 26032
395647 : Lights: Set 0/0/0/0/0
398704 : WD : Uptime 5 ConnectFailures 0 FreeMem 26168
The entry 395647 : Lights: Set 0/0/0/0/0 appears as soon as i put this mqtt command to mosquitto: mosquitto_pub -t "/newdevice" -m "lights,rgb,ff0000"
I think mqtt basically works. But i don´t know if the topic and message has the right form

mrwee yes i have a colorpicker that puts my colors on mqtt. I wrote a little spagetti sketch for the h801 and can control all leds fine but i want to use espeasy as it is much more powerful.

my rule looks like this:

Code: Select all

import org.eclipse.smarthome.core.library.types.HSBType

var String redpwmString
var String greenpwmString
var String bluepwmString
var HSBType hsbValue
var String alltogether

rule "Theme lights"
when

	Item RGBSelect received update
	or
	Item RGBDimmer received update
then
	
	hsbValue = RGBSelect.state as HSBType // sets hsbValue to some kind of variable (int/float?) 
	
	redpwmString = (10*hsbValue.red.intValue).toString// grabs just the red value out of hsbValue and multiplies it time 10 so that it has a scale of 0-1000 for the PWM
	//PWM15.postUpdate(redpwmString)// posts the value above in the MQTT message
	
	greenpwmString = (10*hsbValue.green.intValue).toString//same as in red
	//PWM13.postUpdate(greenpwmString)
	
	bluepwmString = (10*hsbValue.blue.intValue).toString //same as in red
	//PWM12.postUpdate(bluepwmString)
	
	alltogether = redpwmString + ";" + greenpwmString + ";"+ bluepwmString + ";"+ RGBDimmer.state.toString
	PWM.postUpdate(alltogether)
end
and the items like this

Code: Select all

//Item itemName 					{ mqtt="<direction>[<broker>:<topic>:<type>:<trigger>:<transformation>]" }
Color  RGBSelect	"RGB Select"	<slider>

Dimmer  RGBDimmer  "RGB Dimmer [%s %%]"

String PWM	{ mqtt=">[mosquitto:/openhab/PWM:state:*:default]" }
This aktually puts the values to mqtt in a manner my dirty little sketch understands. But it won´t work for the lights plugin. I will document the openhab side as soon as i get this thing working here.

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: H801 RGBWW control with openhab2 and mqtt

#5 Post by sledge » 23 Jan 2017, 01:35

Lol i´m a noob :)

I set some debug code here and there and found out you have to put devicename/cmd as topic. Now it works!
mosquitto_pub -t "/newdevice/cmd" -m "lights,rgb,00ff00" sets a nice solid green

I will report back as soon as my openhab gives right commands over mqtt

Waldmensch
Normal user
Posts: 11
Joined: 28 Nov 2016, 17:12

Re: H801 RGBWW control with openhab2 and mqtt

#6 Post by Waldmensch » 23 Jan 2017, 07:27

Ja bin ich :D

I only use the FHEM Modul without mqtt. The Bug mentioned above is general because I found that all rgb gpio are addressed as gpio 0 when set the PWM. So this issue is only related to communication between webform setup and running code.
Related to mqtt I have no clue whether the plugin is foreseen to work with. Could be that it doesn't because it's proof of concept which usually means "before alpha"
What I understand is that dev0 is coding a different project in the meantime.

Waldmensch
Normal user
Posts: 11
Joined: 28 Nov 2016, 17:12

Re: H801 RGBWW control with openhab2 and mqtt

#7 Post by Waldmensch » 23 Jan 2017, 10:30

The mentioned fix is in Git now - thx @dev0

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: H801 RGBWW control with openhab2 and mqtt

#8 Post by sledge » 23 Jan 2017, 15:13

The mqtt kommunication works. This is the big advantage of the great espeasy framework. Just select the protocol and be happy. I just missed to add "cmd" to the topic.

Althougth dev0 says this plugin is prove of concept it works really nice and does what it should. In fact with things like colortemperature and fading it does more than expected. The only thing missing is some color correction as the blue and green leds are much brighter than the red one. But my 5050 led stripe makes an akzeptable white with FFFFFF. For a better white there are 2 spare channels for ww and cw leds, so everything is nice :)

I also managed to setup openhab to send the right commands over mqtt when changing a value in the colorpicker. I will update the openhab part in the evening.

Waldmensch
Normal user
Posts: 11
Joined: 28 Nov 2016, 17:12

Re: H801 RGBWW control with openhab2 and mqtt

#9 Post by Waldmensch » 23 Jan 2017, 17:11

For all who are not able to compile themself: here you find a Binary for 1M (64kB SPIFFS) Please check the flash chip right beside ESP Chip. The 25Q80 has a flashsize of 1024. There are also H801 in wildlife with 512k flashsize. Don't use the image for these H801!!!

The Plugin works very well for me too. I only use the RGB pins

PS: 300k Attachments are to large for this forum, that's why I have linked to the Post in FHEM Forum instead attaching directly :evil:

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: H801 RGBWW control with openhab2 and mqtt

#10 Post by sledge » 23 Jan 2017, 22:11

Openhab config updated and Waldmensch´s Image linked in first Post. Everything works like a charm and i´m very happy with my new Toy. Big Thx to Dev0 and Waldmensch for your Support.

mrwee
Normal user
Posts: 225
Joined: 31 Aug 2016, 12:52

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#11 Post by mrwee » 24 Jan 2017, 08:41

Very well done Guys! Thanks for your efforts :)

mrwee
Normal user
Posts: 225
Joined: 31 Aug 2016, 12:52

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#12 Post by mrwee » 24 Jan 2017, 21:32

Hi,

I've now flashed a H801 with 147RC8 + the latest P123_lights. I've got a RGB led strip connected. Using OH2+MQTT + the items/rules examples provided, it works fine for a while by using the color picker. After a while it suddenly it stop updating, and load goes to 100% on the H801.

I can see that the MQTT bus is completely quiet, but the log on ESP Easy continues with e.g.:

Code: Select all

845970 : MQTT : Payload: lights,rgb,2819ff,1
845976 : Lights: Set 160/100/1023/-203360/-203360
851104 : MQTT : Topic: /newdevice/cmd
851104 : MQTT : Payload: lights,rgb,4419ff,1
851109 : Lights: Set 272/100/1023/-203360/-203360
856911 : MQTT : Topic: /newdevice/cmd
856911 : MQTT : Payload: lights,rgb,4c1cff,1
856916 : Lights: Set 304/112/1023/-203360/-203360
Only after a reboot, can I get it to work :(

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#13 Post by sledge » 25 Jan 2017, 15:07

Hm strange. I have to design a lamp to install the h801 and test it in a long term. But i did let it run over night and everything was fine.
Make sure your mqtt bus is really clean. Try to listen to all messages with mosquitto_sub -d -t /#
If you edit settings in openhab it will take a while until all files are updated. If you do change colors in the meanwhile in a nervous manner openhab will fire all commands over mqtt as soon as new configuration is loaded. Maybe your poor esp gets confused about that and uses some kind of queue to handle all commands.

mrwee
Normal user
Posts: 225
Joined: 31 Aug 2016, 12:52

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#14 Post by mrwee » 30 Jan 2017, 19:39

Well, it seems like it's only the iOS app which seems to somehow bring H801 to it's knees. It happens if you 'float' your finger around on the color-picker.. Strange.

ewas
New user
Posts: 2
Joined: 04 Mar 2017, 00:27

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#15 Post by ewas » 04 Mar 2017, 00:34

Why do I get this feat log?

1984739 : WD : Uptime 33 ConnectFailures 0 FreeMem 25896
2014740 : WD : Uptime 33 ConnectFailures 0 FreeMem 25896
2044741 : WD : Uptime 34 ConnectFailures 0 FreeMem 25896

Does anyone connect the H801 to OpenHab?

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#16 Post by sledge » 04 Mar 2017, 02:11

Erm did you read first post? The connection to openhab is well explained. Your log is normal it shows no error.

ewas
New user
Posts: 2
Joined: 04 Mar 2017, 00:27

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#17 Post by ewas » 07 Mar 2017, 11:56

Still server does not receive messages. Log beginning as follows:
260 : INIT : Booting Build nr:147
1147 : IP : Static IP :192.168.1.148
1147 : WIFI : Connecting... 1
4652 : WIFI : Connected!
4652 : INIT : SPI not enabled
4655 : INIT : Lights [RGB WW CW FADING CONSTBRI PON]
4668 : MQTT : Connected to broker
4671 : Subscribed to: /H801/#
4671 : INIT : Boot OK
4671 : INIT : Normal boot

JayJay
New user
Posts: 6
Joined: 01 Jan 2017, 12:26

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#18 Post by JayJay » 16 Mar 2017, 21:13

Had the same problem, wanted to use home assistant and mqtt.
But whatever I tried I was unable to get them to talk to eachother, so I did abandon esp easy and used a simpler script found on the internet.
The difficulty for newbies trying to solve things and getting stuck is that most people who get it running or who wrote the code, are way further in understanding evrything that the connection with newbies is hard.
This module in esp easy was easy to access via a browser command but never ran from HASS and mqtt.

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#19 Post by sledge » 17 Mar 2017, 00:54

Ewas, you log looks good so far. Try to send a mqtt command manually in linux console: mosquitto_pub -t "/H801/cmd" -m "lights,rgb,00ff00"

fraeggle
Normal user
Posts: 21
Joined: 20 Nov 2017, 20:12

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#20 Post by fraeggle » 24 Nov 2017, 11:41

JayJay wrote: 16 Mar 2017, 21:13 Had the same problem, wanted to use home assistant and mqtt.
But whatever I tried I was unable to get them to talk to eachother, so I did abandon esp easy and used a simpler script found on the internet.
The difficulty for newbies trying to solve things and getting stuck is that most people who get it running or who wrote the code, are way further in understanding evrything that the connection with newbies is hard.
This module in esp easy was easy to access via a browser command but never ran from HASS and mqtt.
Hi Jayjay.. What do you use for RGB right now and how do you control it. Have the same Prob. It does not send its Name and Values to MQTT. I use Iobroker.

Peter

mastamx
New user
Posts: 2
Joined: 02 Apr 2018, 03:18

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#21 Post by mastamx » 02 Apr 2018, 03:31

Thanks to sledge for posting.

I have currently ESPEasy v2.0 running together with openhab 2.2 via mosquitto 1.4.15 (native build). I compiled with atom (platformio) and uploaded with flash download tools V3.6.2.2.

Everything is wonderful, except openhab colorpicker always sends values like: EA,60,05, which distort the plugin when using white channels (WW and CW is enabled in my setup)

So, I decided to post my "solution" for this "misbehavior", because I don't like bright ww or cw LED when I expect colour

items:

Code: Select all

Color  H801_1_RGB	  "Color Select"	<slider>
Dimmer  H801_1_level  "White Level [%s %%]" 
Dimmer  H801_1_temp   "White Temperature [%s %%]"

//String gets update in Rule and sends Command to Device
String H801_1_CMD	{ mqtt=">[broker:H801_1/cmd:state:*:default]" }

sitemap:

Code: Select all

sitemap demo label="Main Menu"
{

	
	Frame label="H801_1" {
		Slider		item=H801_1_level
		Slider		item=H801_1_temp
		Colorpicker	item=H801_1_RGB	icon="slider"
	}
}
rules:

Code: Select all

import org.eclipse.smarthome.core.library.types.HSBType

rule "H801_1"
when
	Item H801_1_RGB received update
then
	var HSBType hsbValue = H801_1_RGB.state as HSBType
	
	var intred 		= hsbValue.red.intValue*255/100
	var intgreen 	= hsbValue.green.intValue*255/100
	var intblue 	= hsbValue.blue.intValue*255/100
		
	var newintred = intred
	var newintgreen = intgreen
	var newintblue = intblue
	
	if ((intred <=	intgreen) 	&& (intred <= intblue)) newintred = 0
	if ((intgreen < intred) 	&& (intgreen < intblue)) newintgreen = 0
	if ((intblue <=	intred) 	&& (intblue <= intgreen)) newintblue = 0
	
	var String redpwmString = Integer::toHexString(newintred)
	var String greenpwmString = Integer::toHexString(newintgreen)
	var String bluepwmString = Integer::toHexString(newintblue)

	
	var String rgb_cmd = ("00"+redpwmString).substring(redpwmString.length()) + ("00"+greenpwmString).substring(greenpwmString.length()) + ("00"+bluepwmString).substring(bluepwmString.length());
    rgb_cmd = "lights,rgb," + rgb_cmd + ",1"
	H801_1_CMD.postUpdate(rgb_cmd)	
	
end

rule "H801_1 Level"
when
	Item H801_1_level received update
then
	H801_1_CMD.postUpdate("lights,pct," + (H801_1_level.state as DecimalType).intValue +",1")
end

rule "H801_1 Temperature"
when
	Item H801_1_temp received update
then
	H801_1_CMD.postUpdate("lights,ct," + ( (2000 + (H801_1_temp.state as DecimalType).intValue * 40)) + ",1")
	// Sets The Range of Color Temperature (2000 + 0-100 * 40) gives a range from 2000 to 6000.
	//Change this according your led´s color temperatures or leave defaults
end

mastamx
New user
Posts: 2
Joined: 02 Apr 2018, 03:18

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#22 Post by mastamx » 02 Apr 2018, 06:50

Another Question

If we send more than one new "RGB" command to H801, it will get clogged. Color Picker in Openhab is more like one value per 300ms. Is there a solution for this?

sledge
Normal user
Posts: 17
Joined: 20 Jan 2017, 20:42

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#23 Post by sledge » 02 Apr 2018, 13:54

Hi, you can set a timer to prevent openhab from spamming rgb values. eg. wait for 2 sec bevore sending actual color

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#24 Post by zupy666 » 22 Aug 2020, 08:55

Hi, I'm wondering if you could provide me with a link where I could download a newer version of the FW .ino file for the H80 based on "ESPEasy v2.0"?
So far I have used "Build 148" but it no longer works with OH 2.5.5.1 :(

On the OH side, I have the following configuration.

things:

Code: Select all

Thing topic nH801_1 "nH801_1" @ "Living" {
	Channels:
        Type string : H801_1_CMD  [ stateTopic="/nH801_1/cmd" , commandTopic="/nH801_1/cmd" ]
}
items:

Code: Select all

/*RGB_led - Living*/
Color H801_1_RGB            "Color Select"	<slider>
Dimmer H801_1_level         "White Level [%s %%]"
Dimmer H801_1_temp          "White Temperature [%s %%]"
//String gets update in Rule and sends Command to Device
String H801_1_CMD           { channel="mqtt:topic:komar:nH801_1:H801_1_CMD" }
sitemap:

Code: Select all

Frame label="RGB - H801_1 - Living" {
	Slider		item=H801_1_level
	Slider		item=H801_1_temp
	Colorpicker	item=H801_1_RGB		    icon="slider"
}
rules:

Code: Select all

import org.eclipse.smarthome.core.library.types.HSBType

rule "H801_1"
when
	Item H801_1_RGB changed
then
	var HSBType hsbValue = H801_1_RGB.state as HSBType
	var intred 		= hsbValue.red.intValue*255/100
	var intgreen 	= hsbValue.green.intValue*255/100
	var intblue 	= hsbValue.blue.intValue*255/100
		
	var newintred = intred
	var newintgreen = intgreen
	var newintblue = intblue
	
	if ((intred <=	intgreen) 	&& (intred <= intblue)) newintred = 0
	if ((intgreen < intred) 	&& (intgreen < intblue)) newintgreen = 0
	if ((intblue <=	intred) 	&& (intblue <= intgreen)) newintblue = 0
	
	var String redpwmString = Integer::toHexString(newintred)
	var String greenpwmString = Integer::toHexString(newintgreen)
	var String bluepwmString = Integer::toHexString(newintblue)

	var String rgb_cmd = ("00"+redpwmString).substring(redpwmString.length()) + ("00"+greenpwmString).substring(greenpwmString.length()) + ("00"+bluepwmString).substring(bluepwmString.length());
	H801_1_CMD.postUpdate("Lights,rgb," + rgb_cmd + ",1")
end

rule "H801_1 Level"
when
	Item H801_1_level changed
then
	H801_1_CMD.postUpdate("Lights,pct," + (H801_1_level.state as DecimalType).intValue +",1")
end

rule "H801_1 Temperature"
when
	Item H801_1_temp changed
then
	H801_1_CMD.postUpdate("Lights,ct," + ( (2000 + (H801_1_temp.state as DecimalType).intValue * 40)) + ",1")
	// Sets The Range of Color Temperature (2000 + 0-100 * 40) gives a range from 2000 to 6000.
	//Change this according your led´s color temperatures or leave defaults
end
In case I send the same command to the mqtt broker via the console or MQTT.fx, the command reaches the node and executes it correctly.

OH log:

Code: Select all

09:25:52.269 [INFO ] [smarthome.event.ItemStateChangedEvent] - H801_1_CMD changed from Lights,rgb,549300,1 to Lights,rgb,4c9300,1
H801 log:

Code: Select all

6159569 : WD : Uptime 102 ConnectFailures 0 FreeMem 20488
6161116 : Lights: Set 0/0/0/0/0
6161173 : Lights: Set 0/0/0/0/0
6162174 : Lights: Fade down complete
6189570 : WD : Uptime 103 ConnectFailures 0 FreeMem 20264

thanks for the help
Last edited by zupy666 on 22 Aug 2020, 11:51, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#25 Post by Ath » 22 Aug 2020, 10:50

Latest version of ESPEasy is always available at the Github releases page: https://github.com/letscontrolit/ESPEasy/releases
Not sure about that H801 controller, but it looks like it's a 1 MB ESP8266 based device. Please make a proper backup of any rules/scripts/configuration before upgrading, there have been many improvements and changes to the firmware since R148, but it should all be backward compatible.

After an initial 'wired' update, it should be possible do do OTA (over the air) updates, when running on a 4 MB device you can always easily do an OTA update of the device. For 1 MB devices you need a 2-step procedure, first uploading a minimal-OTA version, and after that the desired updated version. I'd settle with one of the 'Normal' 1M builds for ESP8266.
/Ton (PayPal.me)

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#26 Post by zupy666 » 22 Aug 2020, 11:16

Ath wrote: 22 Aug 2020, 10:50 Latest version of ESPEasy is always available at the Github releases page: https://github.com/letscontrolit/ESPEasy/releases
Not sure about that H801 controller, but it looks like it's a 1 MB ESP8266 based device. Please make a proper backup of any rules/scripts/configuration before upgrading, there have been many improvements and changes to the firmware since R148, but it should all be backward compatible.

After an initial 'wired' update, it should be possible do do OTA (over the air) updates, when running on a 4 MB device you can always easily do an OTA update of the device. For 1 MB devices you need a 2-step procedure, first uploading a minimal-OTA version, and after that the desired updated version. I'd settle with one of the 'Normal' 1M builds for ESP8266.
Hi Ath,

As far as I know H801 is not included in ESP_Easy_mega_20200812_normal_ESP8266_1M.bin and uses the plugin https://github.com/letscontrolit/ESPEas ... 5_RGBW.ino

To this end, I ask if anyone has already managed to compile a working sketch based on ESPEasy v2.0. Unfortunately, I don't have enough knowledge to just run the compiler successfully :(

Thanks for the help and reply

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#27 Post by Ath » 22 Aug 2020, 11:43

Aha, no, plugin P105 (RGBW MiLight) is only available in the plugin playground, and didn't make it into an official plugin yet.

As the implementation of plugins has been slightly adapted over the last years (last change to this plugin was > 2 years ago), it's likely it will need some adjustments before it can be incorporated.

Other than being 'up to date', what is your reason to update your device? I assume it currently works as it should?
/Ton (PayPal.me)

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#28 Post by zupy666 » 22 Aug 2020, 11:47

Ath wrote: 22 Aug 2020, 11:43 Aha, no, plugin P105 (RGBW MiLight) is only available in the plugin playground, and didn't make it into an official plugin yet.

As the implementation of plugins has been slightly adapted over the last years (last change to this plugin was > 2 years ago), it's likely it will need some adjustments before it can be incorporated.

Other than being 'up to date', what is your reason to update your device? I assume it currently works as it should?
The reason for the FW upgrade on the node is the inactivity in with OH.
For once, I can't find a reason on the OH side why he doesn't send me a command to the mqtt broker. Do you have any idea?

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#29 Post by Ath » 22 Aug 2020, 11:58

Must assume you checked all the obvious possible errors, like bad WiFi connection (not likely as it can receive commands), changed password (or other settings) on the MQTT broker, change on the OH side so it doesn't understand the MQTT messages H801 is sending?
/Ton (PayPal.me)

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#30 Post by zupy666 » 22 Aug 2020, 12:01

Finally again the thing works like it used to :)
The reason for the non-operation is my small superficiality :) in the rules.

In older versions than OH 2.2 it was enough if you sent the command "postUpdate" now you have to execute another "sendCommand".

Code: Select all

import org.eclipse.smarthome.core.library.types.HSBType

rule "H801_1"
when
	Item H801_1_RGB changed
then
	var HSBType hsbValue = H801_1_RGB.state as HSBType
	var intred 		= hsbValue.red.intValue*255/100
	var intgreen 	= hsbValue.green.intValue*255/100
	var intblue 	= hsbValue.blue.intValue*255/100
		
	var newintred = intred
	var newintgreen = intgreen
	var newintblue = intblue
	
	if ((intred <=	intgreen) 	&& (intred <= intblue)) newintred = 0
	if ((intgreen < intred) 	&& (intgreen < intblue)) newintgreen = 0
	if ((intblue <=	intred) 	&& (intblue <= intgreen)) newintblue = 0
	
	var String redpwmString = Integer::toHexString(newintred)
	var String greenpwmString = Integer::toHexString(newintgreen)
	var String bluepwmString = Integer::toHexString(newintblue)

	var String rgb_cmd = ("00"+redpwmString).substring(redpwmString.length()) + ("00"+greenpwmString).substring(greenpwmString.length()) + ("00"+bluepwmString).substring(bluepwmString.length());
	H801_1_CMD.postUpdate("Lights,rgb," + rgb_cmd + ",1")
	H801_1_CMD.sendCommand("Lights,rgb," + rgb_cmd + ",1")
end


rule "H801_1 Level"
when
	Item H801_1_level changed
then
	H801_1_CMD.postUpdate("Lights,pct," + (H801_1_level.state as DecimalType).intValue +",1")
	H801_1_CMD.sendCommand("Lights,pct," + (H801_1_level.state as DecimalType).intValue +",1")
end


rule "H801_1 Temperature"
when
	Item H801_1_temp changed
then
	H801_1_CMD.postUpdate("Lights,ct," + ( (2000 + (H801_1_temp.state as DecimalType).intValue * 40)) + ",1")
	H801_1_CMD.sendCommand("Lights,ct," + ( (2000 + (H801_1_temp.state as DecimalType).intValue * 40)) + ",1")
	// Sets The Range of Color Temperature (2000 + 0-100 * 40) gives a range from 2000 to 6000.
	//Change this according your led´s color temperatures or leave defaults
end
The above rules with correction. I hope someone else gets it right.

Ath thanks for the tips

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#31 Post by Ath » 22 Aug 2020, 13:01

Well, having looked at the source of plugin P105, I'm not sure that's the plugin your ESP is actually using, as I have not found a 'Lights' command there, and also no hexadecimal values are accepted. Is there some other software-layer involved or another plugin used?
/Ton (PayPal.me)

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#32 Post by zupy666 » 22 Aug 2020, 13:31

Ath wrote: 22 Aug 2020, 13:01 Well, having looked at the source of plugin P105, I'm not sure that's the plugin your ESP is actually using, as I have not found a 'Lights' command there, and also no hexadecimal values are accepted. Is there some other software-layer involved or another plugin used?
As already mentioned on the H801 is installed FW espeasy R148 and OH 2.5.5.1, no other physical or software level is in between.

Lights is not a command but a device, I am attaching a configuration on the node for easier explanation.
H8001_device_conf.PNG
H8001_device_conf.PNG (37.96 KiB) Viewed 26253 times

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#33 Post by Ath » 22 Aug 2020, 13:38

Well, in the meantime I've found the plugin, P123, and it is referenced in the first message of this thread (that I hadn't read before... ;) ), it is from an external github repo.

I'll see if I can fix up that one to current 'state of affairs', as it does have the 'lights' commands and hexadecimal input values.
Might be a nice add-on to ESPEasy
/Ton (PayPal.me)

mrwee
Normal user
Posts: 225
Joined: 31 Aug 2016, 12:52

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#34 Post by mrwee » 22 Aug 2020, 13:49

Ath wrote: 22 Aug 2020, 13:38 Well, in the meantime I've found the plugin, P123, and it is referenced in the first message of this thread (that I hadn't read before... ;) ), it is from an external github repo.

I'll see if I can fix up that one to current 'state of affairs', as it does have the 'lights' commands and hexadecimal input values.
Might be a nice add-on to ESPEasy
Would be very nice to have it updated. I'm running it on an old ESPEasy, and it's overall not that stable.

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#35 Post by zupy666 » 22 Aug 2020, 13:53

I apologize for the confusion you're right Plugin 123: Lights is the real one.
And I would be very happy if this plugin was included in one of the newer releases as part of the mega brunch.
At the moment I have not been able to browse from the archive using the .ino file, when I find it I will add it if anything will help.

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Finished: H801 RGBWW control with openhab2 and mqtt

#36 Post by Ath » 22 Aug 2020, 14:35

This P123 plugin is even older, > 4 years old, and thus uses even older 'standards' in the code that since then have been either deprecated or are no longer working. And though I have fixed enough so it compiles without errors, I'm not sure if I should proceed, as I have no such controller, or the required RGBW lightstrip, I won't be able to test the code, so I won't push it to ESPEasy, unless someone would like to donate me a controller and matching lightstrip, as I don't have a proper use for them right now. (I prefer the use of the NeoPixel/WS28xx ledstrips, as they are easier to control IMHO, though I see some nice features in this plugin)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 77 guests