Homie Auto-dicover with OpenHAB3?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Homie Auto-dicover with OpenHAB3?

#1 Post by rmhoutz » 21 Apr 2021, 15:11

Hi ESP Easy Friends

Is anyone using the Controller Homie MQTT convention with Openhab version 2.5 or 3?

I recently installed some TP-Link switches in my home and found Openhab picked them up without me telling it to look.
After that it took very little additional configuration to get them integrated into the system.
It was exactly as described in ESP Easy documentation for the Homie Controller.
https://espeasy.readthedocs.io/en/lates ... omie#setup
Screenshot 2021-04-21 090508.png
Screenshot 2021-04-21 090508.png (99.18 KiB) Viewed 5517 times
I believe this is still in testing if I'm not mistaken, I'd like to help the development anyway I can.
I'm not a programmer but I can test and report back my findings.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Homie Auto-dicover with OpenHAB3?

#2 Post by rmhoutz » 22 Apr 2021, 14:11

I'm really hoping I'm not the only one using this firmware with OpenHAB, the silence isn't very reassuring. :?
I'm following the troubleshooting steps found in the Homie MQTT convention page.
https://espeasy.readthedocs.io/en/lates ... omie#setup
I've setup a syslog server to monitor the devices from boot. Here is the log info I'm seeing from boot to first uptime message.

Code: Select all

4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy:      : Rebooting...
4/22/2021 7:43 AM,Error,192.168.2.52,ESP-B11D69-2 EspEasy: MQTT : Connection lost, state: Disconnected
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: UDP : Start listening on port 65314
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: firstLoopConnectionsEstablished
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: NTP  : NTP replied: delay 10 mSec Accuracy increased by 0.131 seconds
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: Time set to 1619091805.131 Time adjusted by 984.82 msec. Wander: 0.27 msec/second
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: Local time: 2021-04-22 07:43:25
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: EVENT: WiFi#Connected
4/22/2021 7:43 AM,Error,192.168.2.52,ESP-B11D69-2 EspEasy: MQTT : Intentional reconnect
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: MQTT : Connected to broker with client ID: ESP_B11D69
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: Subscribed to: homie/ESP_B11D69/%tskname%/%valname%/set
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: EVENT: Time#Set
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: EVENT: MQTT#Connected
4/22/2021 7:43 AM,Notice,192.168.2.52,ESP-B11D69-2 EspEasy: WD   : Uptime 1 ConnectFailures 0 FreeMem 23056 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
Can anyone tell me if I should be seeing the C014 : autodiscover information?
I only have 1 device setup on the ESP.
Does anyone have any advice how I can troubleshoot this further?

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

Re: Homie Auto-dicover with OpenHAB3?

#3 Post by TD-er » 22 Apr 2021, 15:11

I don't have OpenHAB running here, so sadly I cannot help you there.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Homie Auto-dicover with OpenHAB3?

#4 Post by rmhoutz » 22 Apr 2021, 19:46

Hi TD-er

No problem I understand.
But can you tell me per the docs should I be seeing a message sent
from the ESP showing the nodes or configured devices from the Devices Tab?
Screenshot 2021-04-22 134239.png
Screenshot 2021-04-22 134239.png (31.03 KiB) Viewed 5496 times

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

Re: Homie Auto-dicover with OpenHAB3?

#5 Post by TD-er » 22 Apr 2021, 20:37

I really don't know as I have not written that piece of code and also not used it my self.

The log entry you quoted is generated here:
https://github.com/letscontrolit/ESPEas ... #L477-L491

To be honest, I have had a few looks at the code of C014 and it really is a HUGE file full with lots and lots of copy/paste code.
So it really can benefit a lot from some TLC, but for now, I also need to look into the code to see what 'nodeCount' represents.

Here 'nodeCount' is incremented: https://github.com/letscontrolit/ESPEas ... #L292-L311
But I really don't know why as it is counting the number of GPIO pins that are flagged to send their pin boot state (why!?!?!?!)

The next part is where it loops over all tasks to find an enabled "Homie Receiver" task (apparently you need one????) which is not set to "send" data (????) and increments the 'nodeCount' on each task value of this Homie Receiver task which has a variable name.
This "send data" flag is only used for tasks that are shared among nodes via the p2p protocol, but apparently the Homie controller does also use it? (not sure how well that will work along with the ESPEasy p2p protocol)


The next step is to increment the 'nodeCount' for all tasks set to "send" data. One increment per task value with a set name.


The "deviceCount" is really tricky here as there is a global variable with the same name.
This is a strange count as it is initialized to 1 and before anything is done with it, it is incremented (to 2)
How this value is incremented does take a bit too long to dive into as this code really is not well structured with lots and lots of nested ifs, for loops etc.

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

Re: Homie Auto-dicover with OpenHAB3?

#6 Post by Ath » 22 Apr 2021, 20:42

rmhoutz wrote: 22 Apr 2021, 14:11 Can anyone tell me if I should be seeing the C014 : autodiscover information?
I only have 1 device setup on the ESP.
Does anyone have any advice how I can troubleshoot this further?
It looks like the autodiscover messages are sent as system or admin MQTT messages (starting with a $), possibly you need to enable this type of messages to be in the log at the OpenHAB side of the story.
/Ton (PayPal.me)

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

Re: Homie Auto-dicover with OpenHAB3?

#7 Post by Ath » 22 Apr 2021, 20:56

Not sure what your knowledge level of MQTT is, but this guide for me has been very readable and informative: https://www.hivemq.com/mqtt-essentials/

In part 5 you can find more info about topic names, and also the $ special character.
/Ton (PayPal.me)

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Homie Auto-dicover with OpenHAB3?

#8 Post by rmhoutz » 22 Apr 2021, 21:15

Thanks TD-er and Ath

It sounds like this plugin just isn't ready for a user like myself.
That's okay because ESPEasy has been working great for me
the past few years without it.
I'll just set my system up using generic MQTT things in openHAB.

I am going to check out that guide also because I'm just now beginning to understand MQTT
and would like to know more.

Thanks again both of you.

rmhoutz
Normal user
Posts: 36
Joined: 08 Sep 2017, 14:09

Re: Homie Auto-dicover with OpenHAB3?

#9 Post by rmhoutz » 30 Apr 2021, 17:55

Guys I had given up on this but after I got my system back up and running after the OH2.5 to OH3 migration I revisited it this morning.
And I actually figured out the problem.
this guide for me has been very readable and informative: https://www.hivemq.com/mqtt-essentials/
I first watched all 11 videos provided in the link and that for sure helped me understand what's going on better with MQTT.

I was so close to having this configured properly a week or two ago I can't believe I missed it.
The instructions talk like homie works with openHAB MQTT and when I was configuring a custom.h the correct option in my mind was to use option 5.
Since I'm running a OH3 server and OH3 docs mention not needing anything more than the MQTT addon to use homie devices.

Code: Select all

/ --- Default Controller ------------------------------------------------------------------------------
#define DEFAULT_CONTROLLER   true                                          // true or false enabled or disabled, set 1st controller
                                                                            // defaults
#define DEFAULT_CONTROLLER_ENABLED true                                     // Enable default controller by default
#define DEFAULT_CONTROLLER_USER    ""                                       // Default controller user
#define DEFAULT_CONTROLLER_PASS    ""                                       // Default controller Password

// using a default template, you also need to set a DEFAULT PROTOCOL to a suitable MQTT protocol !
#define DEFAULT_PUB         "homie/%sysname%/%tskname%/%valname%"                       // Enter your pub
#define DEFAULT_SUB         "homie/%sysname%/%tskname%/%valname%/set"                                      // Enter your sub
#define DEFAULT_SERVER      "192.168.2.4"                                   // Enter your Server IP address
#define DEFAULT_SERVER_HOST ""                                              // Server hostname
#define DEFAULT_SERVER_USEDNS false                                         // true: Use hostname.  false: use IP
#define DEFAULT_USE_EXTD_CONTROLLER_CREDENTIALS   false                     // true: Allow longer user credentials for controllers

#define DEFAULT_PORT        1883                                            // Enter your Server port value

#define DEFAULT_PROTOCOL     5                                               // Protocol used for controller communications
                                                                            //   0 = Stand-alone (no controller set)
                                                                            //   1 = Domoticz HTTP
                                                                            //   2 = Domoticz MQTT
                                                                            //   3 = Nodo Telnet
                                                                            //   4 = ThingSpeak
                                                                            //   5 = Home Assistant (openHAB) MQTT
                                                                            //   6 = PiDome MQTT
                                                                            //   7 = EmonCMS
                                                                            //   8 = Generic HTTP
                                                                            //   9 = FHEM HTTP
                                                                            
I was attempting to use the Home Assistant (openHAB) MQTT protocol when I should have been using Homie MQTT protocol as seen below.
Screenshot 2021-04-30 114220.png
Screenshot 2021-04-30 114220.png (25.29 KiB) Viewed 5266 times
Does anyone know how I can add that to be an option for the default protocol?

I'm thinking about creating a ESPEasyHOMIE.bin that is ready for use with Homie.
Users will just need to configure devices and personal network settings.
But after that OH3 should detect the device just like it does with TP-Link devices.

Thanks again for all the work you do on this.

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

Re: Homie Auto-dicover with OpenHAB3?

#10 Post by TD-er » 30 Apr 2021, 21:35

The default controller you can set in the Custom.h is the nr of the controller (C005 => 5, etc.)
So if you need the Home 3/4 version, you have to use "14" there.
https://github.com/letscontrolit/ESPEas ... ino#L8-L26

The default controller will be added when generating a new config, like when you start fresh or reset to factory default.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 28 guests