Homie / openHAB 2.4 autodiscover compatibility

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Homie / openHAB 2.4 autodiscover compatibility

#1 Post by HarpieC » 26 Feb 2019, 19:30

Dear All,

I currently start my home automation new from scratch. The "old" system was based on openHAB 1.8 and mosquitto MQTT server and a lot of openHAB code. I waited a wile until openHAB 2.x settled. Recently I discovered that with Version 2.4 openHAB committed to MQTT by integrating a MQTT server inside as a binding. In a blogpost from December it is explained that even if generic MQTT devices are supported the MQTT implementation is based on the Homie spec beside Homeassistant. With some rules and a little mod of the MQTT-import plugin to receive true and false payloads It is possible to get sensors and actors running ESPeasy autodiscovered and running with no line of code or conf files.

https://www.openhab.org/blog/2018-12-16 ... cture.html
https://homieiot.github.io/

To make the "magic" happen a few definitions have to be sent to the mqtt broker describing the "thing" and the channels.
  • the definitions should be sent with the retained flag set
  • first a few description of the "thing" here ESP8266 running ESPEasy
  • some definitions for each sensor/actor
  • a definition of every value provided by each sensor
  • The receive definition is different from the CMD structure (only writing to the same topic with /set appended)
So I had the idea to write a protocol plugin to do all of this automatically.
  • Send the description messages
  • for every device send appropriate definitions of things (device) and channels (value)
  • handle received messages
  • handle erasing and changing devices. This is necessary because if the retained flag is set not used devices will stay and will be detected as not working. Could be solved if it will be possible to erase all old definition if the ESPeasy firmware comes up again and refresh the above information
my test system works with the homie standard, but perhaps the the homeassistant is better because it carries more information in JSON formatted messages instead many simple topic/payload combinations.

So my questions are
  • is something like this already in the works and I will waste my time?
  • are there any traps I should consider - beside reading the wiki?
  • anybody with the same demand for making ESPeasy homie and/or homeassistant compatible?
  • or is there a existing way I not found or thought of?
Why I want to do this, autodiscover is for newbies? I like to have my openHAB implementation free from openHAB code and use node-red instead as my scripting engine. After finishing a big Job using node-red I found it very appealing to have a visual representation of all things and code probing arround as I like. Then why openHAB at all. Using a few "of the shelf" components I appreciate the huge support for all the proprietary protocols out there together with ice UIs and a huge community.

Let me know what you think and thank you for all the work - your system is by far the most versatile and flexible of all I tested so far.

Chris

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Homie / openHAB 2.4 autodiscover compatibility

#2 Post by TD-er » 26 Feb 2019, 21:07

As far as I know, nobody has started development yet.
Do you have a bit more information about this discovery process?
Then it may be easier to determine what may be needed here.

My first guess would be to include this in the OpenHab controller.
A plugin can be set to a controller, so then you can use the existing mechanism to determine what should be made available to this discovery and what not.

You may also have a look at the Domoticz helper class, which already helps to output plugin data in a very specific format needed by Domoticz.
I don't know what is needed, but I can imagine plugins may also need to have extra information like defining the unit of measure for each output value.

I guess this would be useful to discuss on GitHub, since I'm not on the forum every day.
There is already a number of issues about discovery:
https://github.com/letscontrolit/ESPEasy/issues/977
https://github.com/letscontrolit/ESPEasy/issues/1314

HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Re: Homie / openHAB 2.4 autodiscover compatibility

#3 Post by HarpieC » 27 Feb 2019, 09:48

Hi, thank you for your quick reply.

so I head over to issue 1314 on github ...

Olbi
New user
Posts: 4
Joined: 16 Oct 2017, 12:37

Re: Homie / openHAB 2.4 autodiscover compatibility

#4 Post by Olbi » 02 Apr 2019, 12:36

Hi,
it would be nice if ESPEasy would support homie 3.0 directly. Currently I have tinkered it with the rules. Unfortunately, this works only with the sending of sensor data, not with the receiving ... :cry:

if someone wants to rebuild that, here are the rules:

Code: Select all

// Homie 3.0 Struktur senden

on MQTT#Connected do
 timerSet,1,60
 Publish homie/%mac_int%/$homie,3.0
 Publish homie/%mac_int%/$name,%sysname%
 Publish homie/%mac_int%/$stats/interval,60
 Publish homie/%mac_int%/$stats,uptime,signal,cpuload,freeheap
 Publish homie/%mac_int%/$nodes,DHT
 Publish homie/%mac_int%/DHT/$name,DHT22
 Publish homie/%mac_int%/DHT/$properties,Temperature,Humidity
 Publish homie/%mac_int%/DHT/Temperature/$name,Temperatur
 Publish homie/%mac_int%/DHT/Temperature/$unit,°C
 Publish homie/%mac_int%/DHT/Temperature/$datatype,float
 Publish homie/%mac_int%/DHT/Humidity/$name,rel. Luftfeuchtigkeit
 Publish homie/%mac_int%/DHT/Humidity/$unit,%rel.H
 Publish homie/%mac_int%/DHT/Humidity/$datatype,float
 Publish homie/%mac_int%/$state,ready
endon

On Rules#Timer=1 do
 Publish homie/%mac_int%/$state,ready
 timerSet,1,60
endon
PS: it seems, there is a Bug in openHAB: the autodiscovered Thing works fine till openHAB restarts, then it will show only "online" but the Values are "NaN" ...

(used google translator)
ESP Easy Mega - Controllers.png
ESP Easy Mega - Controllers.png (77.62 KiB) Viewed 5000 times
ESP Easy Mega - Rules.png
ESP Easy Mega - Rules.png (92.83 KiB) Viewed 5000 times
ESP Easy Mega - Devices - Generic System Info.png
ESP Easy Mega - Devices - Generic System Info.png (68.03 KiB) Viewed 5000 times
ESP Easy Mega - Devices - Enviroment DHT11 12 22.png
ESP Easy Mega - Devices - Enviroment DHT11 12 22.png (59.55 KiB) Viewed 5000 times

HarpieC
Normal user
Posts: 22
Joined: 20 Mar 2016, 20:33

Re: Homie / openHAB 2.4 autodiscover compatibility

#5 Post by HarpieC » 12 May 2019, 10:17

A controller plugin for the Homie MQTT convention is available. Documentation can be found here: Read the Docs ...
This is an early Beta version! Would be nice if anybody can give it a try.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests