rvdbreemen / OTGW-firmware

A ESP8266 devkit firmware for the Nodoshop version of the Opentherm Gateway (OTGW)
MIT License
145 stars 34 forks source link

Domoticz Error log gives MQTT error every 5 minutes #153

Closed 0crap closed 1 year ago

0crap commented 1 year ago

In Domoticz I use the Hardware interface "MQTT Auto Discovery Client Gateway with LAN interface" to collect all the boiler sensors from my OTGW. This works great with one exception. The Domoticz Error log shows every 5 minutes the following error: Error: MQTT: Climate device invalid/unknown mode received! (otgw-C8C9A35AC425-thermostat: ON)

This seems to happen repeatedly on the exact moment the OTGW sends the otgw-firmware uptime.

Domoticz every 5 minutes MQTT-Explorer

I don't need the otgw-firmware uptime in Domoticz anyway, so a simple solution might be not sending this MQTT message? In Domoticz at "Setup -> Devices", where all MQTT boiler devices are shown, there is no otgw-firmware uptime discovered. Maybe that has something to do with this issue?

Thanks for your time looking into this. 👍

rvdbreemen commented 1 year ago

@0crap thanks for reporting the issue with Domoticz. I looked into this, every 5 minutes a couple of things are posted. Among that is the uptime, but to be honest I don't think that's the problem here.

I use the Home Assistant MQTT auto discovery feature for this firmware. Which can be found here: https://www.home-assistant.io/integrations/mqtt/

In there is the Last Will Message explanation, it talks about updating the status of the device. I do this also on the 5 minute moment. I think that is what Domoticz is complaining about here. The "ON" message to make sure we can actually validate that would you be so kind to do one more logging of the situation.

On the firmware you can turn ON the MQTT logging (off by default, because of the sheer number of message). You do this by going to the debug port, with telnet on port 23, and then hit the '3'. That should turn on the MQTT messages.

I would be interested to see if we can correlate the error in Domoticz to a specific message.

Thanks for you help, Robert

0crap commented 1 year ago

Sure thing, had to hit Print screen quickly. Hope the message you are looking for is in the screenshot.

MQTT-debug

0crap commented 1 year ago

When I look at this WITHOUT ANY programming knowledge, I do notice two things around the timestamp in question.

But of course I don't want to jump to conclusions. :-)

rvdbreemen commented 1 year ago

@0crap thanks for thinking out loud. I looked in the code, this is it down below:

void do5minevent(){
  sendMQTTuptime();
  sendMQTTversioninfo();
  sendMQTTstateinformation();
  if (bCheckOTGWPICupdate) {
    bCheckOTGWPICupdate = false;
    checkOTWGpicforupdate();
  }
}

It sends the uptime of the ESP8266, also it sends the version information and state information.

Then in the state information:

/*
Publish state information of PIC firmware version information to MQTT broker.
*/
void sendMQTTstateinformation(){
  sendMQTTData(F("otgw-pic/boiler_connected"), CCONOFF(bOTGWboilerstate)); 
  sendMQTTData(F("otgw-pic/thermostat_connected"), CCONOFF(bOTGWthermostatstate));
  sendMQTTData(F("otgw-pic/gateway_mode"), CCONOFF(bOTGWgatewaystate));
  sendMQTTData(F("otgw-pic/otgw_connected"), CCONOFF(bOTGWonline));
  sendMQTT(CSTR(MQTTPubNamespace), CONLINEOFFLINE(bOTGWonline));
}

The last line of this is actually updating the status of the ESP8266, that way the Home Assistant knows about the status. It sends online or offline status, so that Home Assistant can determine the status of the ESP8266 (device).

Now having said this, it seems that Domoticz seems to want ON or OFF and not online or offline. If that is the case, then Domoticz is not implementing the keywords correctly.

Now I have no way of validating this myself... Hmmm, wonder how we could test this assumption from my end that this is the explanation.

0crap commented 1 year ago

Anything I can type on the OTGW telnet command line, to see if Domoticz gives an error or not? Domoticz is running on a Raspberry Pi, so that command line shell is also available...

~~One thing that crossed my mind is that you could make a Domoticz on/off checkbox, under Advanced -> OTGW Settings, that disables sending the sendMQTTstateinformation block. To me it seems Domoticz does nothing with it and only spits out an error message....~~

Forget the above, I do see a sensor boiler connected and thermostat connected.

rvdbreemen commented 1 year ago

I could also be a bug in Domoticz you know ;-) #bughunting

0crap commented 1 year ago

Sure. More then happy to open a ticket on the Domoticz side of it.

Are you sure this sendMQTT(CSTR(MQTTPubNamespace), CONLINEOFFLINE(bOTGWonline)); is the trouble maker? And how should Domoticz respond in your opinion? If I open a Domoticz ticket I want to have as much info as I can, to get it solved.

On the other hand, it seems just a "simple" thing not to send that line in case Domoticz is used. For example, in the OTGW Settings, if MQTT Home Assistant prefix is set to "Domoticz" not send that line? Just being creative here for a quick fix.

Writing this, the item MQTT Home Assistant prefix should be renamed to something like MQTT Auto Discovery Prefix. Because that is exactly what it is, and the OTGW can be used with any Home automation software using MQTT.

rvdbreemen commented 1 year ago

I agree with renaming the prefix, just know that when I wrote this there was no other system supporting Autodiscovery. Home Assitant created the "standard" and by now most other home automation copied the method.

Well, and I think the sendMQTT is causing Domoticz not to expect it. They should just parse it, and deal with it. That's the way devices communicate their status (online/offline).

Yeah, but you do want the detection of your device. If it's online or not. So even though I would consider a quick fix, it's not that there is anything wrong with the message sent, so why is there an error.

0crap commented 1 year ago

Fair enough.

I'll open an issue on the Domoticz side of it and see what they can do. For the prefix renaming I'll open a separate issue, so you can easily keep track of it.

Thx.

0crap commented 1 year ago

I solved this differently.

On the OTGW I disabled MQTT and no longer receive the OTGW messages through this way in Domoticz. (My Domoticz already uses a MQTT broker to receive other sensors, that's why I tried this first.)

Instead I added the OTGW to Domoticz by adding a "OpenTherm Gateway with LAN interface". This works fine, however it does give a little less sensors vs the MQTT way of doing it. Like, for example, the OTGW counters like "Pump starts, Burner hours, ..." and so on are missing. (Edit: The PS=1 command line output Domoticz asks for does contain these items.) Not really a big issue. (OTmonitor still shows these values if I want to see them.)

The result is I no longer receive the error log issues like reported in the opening post. Thanks for looking into this, I'll close this issue.