Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domoticz Controller sends non JSON Format #869

Closed
jannnfe opened this issue Feb 14, 2018 · 17 comments
Closed

Domoticz Controller sends non JSON Format #869

jannnfe opened this issue Feb 14, 2018 · 17 comments

Comments

@jannnfe
Copy link

jannnfe commented Feb 14, 2018

Steps to reproduce

If I activate the controller Domoticz MQTT and want to send my temperature and humidity from the DHT22 sensor or PPM from the MQ-9 sensor to Domoticz, a "Connected" or "Connection Lost" in "domoticz/out" will be sent in non JSON format. This causes problems with the use of the Homebridge plugin eDomoticz because it does not work as long as the MQTT topic does not contain all messages in the JSON format. This message is sent every time the controller connects or breaks the connection. I do not know if that is the case with other plugins, but I noticed with these two plugins:
Environment - DHT11/12/22 and Analog input - internal

Please have a look at this Issue from eDomoticz.

Expected behavior

There should be no status message when connecting or disconnecting in non JSON format in the "domoticz/out" topic.

Actual behavior

The controller sends a "Connected" or "Connection Lost" to the "domoticz/out" topic in non JSON format, which causes an error with the use of the Homebridge plugin eDomoticz.

System configuration

Hardware:
ESP8266 Wemos D1 Mini
DHT22
MQ-9 Gas Sensor

Software or git version:
mega-20180114
P005 & P025
Domoticz MQTT Controller

@TD-er
Copy link
Member

TD-er commented Feb 14, 2018

Does this also apply to other MQTT controllers, like OpenHAB?

So should we add a check mark to force json on all messages?

@jannnfe
Copy link
Author

jannnfe commented Feb 14, 2018

I looked into the Messages with different Controllers with:

mosquitto_sub -v -t '#'

Tested with OpenHAB Controller (First Line) and Domoticz Controller (Second Line):

ThermostatSensor/status Connected
domoticz/out Connected

For example Sonoff-Tasmota sends a different MQTT message for this "Debug" message (Online, Offline instead of Connected, Connection Lost):

tele/Thermostat/LWT Online

Maybe this could be a possible solution but a checkbox to force JSON output messages could solve the problem as well (i hope :D).

@TD-er
Copy link
Member

TD-er commented Feb 15, 2018

Just to make sure I get it... Does Tasmota send to a different topic? Or is it just that they send another word?

@TD-er
Copy link
Member

TD-er commented Feb 15, 2018

Is it possible the Offline message of Tasmota is not a regular message, but a "Last Will and Testament" message sent by the broker?

@jannnfe
Copy link
Author

jannnfe commented Feb 15, 2018

I'm sorry, I'm not sure, but I think it's a "Last Will Testament", because that's what it's called "tele/Thermostat/LWT". I do not know exactly yet with MQTT and I'm still learning about things, etc., but noticed the problem with the non JSON format and wanted to know if there might be a solution for it. Sorry, please keep me up to date if there is any news on this topic.

@TD-er
Copy link
Member

TD-er commented Feb 15, 2018

I was just reading about MQTT (all a bit new to me too) and saw this on the TASMOTA wiki.
Tasmota uses several topic prefixes like

  • cmnd
  • tele
  • stat

And given that the "LWT" part is still part of the topic (separated with a '/' thus still part of the topic), to what topic(s) are you subscribed?
Maybe we should send the controller status to a "LWT" (sub)topic?

Currently we don't have support for LWT, but that's probably not too hard to implement.

@jannnfe
Copy link
Author

jannnfe commented Feb 15, 2018

Yes the Controller Status by example Topic: devicename/controller/LWT
And the sensors as they are now, so that only messages in JSON format are sent.
Sorry for my beginners expressionist but you probably know better how to do it best! 👍

@TD-er
Copy link
Member

TD-er commented Feb 15, 2018

Well I don't know a lot about MQTT, also just learning. It appeared asking google for "MQTT essentials" is quite a good keyword ;)

@jannnfe
Copy link
Author

jannnfe commented Feb 15, 2018

But you will still look for the problem? I would be glad!
In the meantime, what can I do myself to temporarily solve the problem? Is it possible to switch off the statuses somewhere? Thank you!

@TD-er
Copy link
Member

TD-er commented Feb 16, 2018

I still working on it ;)
And I found some other issue as well.

There will be a pull request within the hour I guess and not sure when @psy0rz will start merging, but I guess he will do that tomorrow evening so it will be in the next build (Saturday morning) I guess.
But if you can build it yourself, you could try to build the PR I will make.

@jannnfe
Copy link
Author

jannnfe commented Feb 16, 2018

Okay Nice thank you for your quick help. Thats super cool! :)

TD-er added a commit to TD-er/ESPEasy that referenced this issue Feb 16, 2018
… CPU load

See letscontrolit#869 for discussion on Last Will Topic.
Also changed the way it tried to reconnect to make it return a lot faster when connection is not (yet) possible and call the PubSubClient::loop() at a much slower pace to reduce CPU usage. (See letscontrolit#847)
This higher CPU load was probably introduced when fixing letscontrolit#683.
@TD-er
Copy link
Member

TD-er commented Feb 16, 2018

You can test it if you like.
I created a PR based on branch v2.0
@psy0rz will merge it later on to the Mega branch.

@jannnfe
Copy link
Author

jannnfe commented Feb 16, 2018

Thank you for your help. I will try it tomorrow :)

psy0rz pushed a commit that referenced this issue Feb 16, 2018
* [issue #869] Added 'LWT' to last will topic and improved CPU load

See #869 for discussion on Last Will Topic.
Also changed the way it tried to reconnect to make it return a lot faster when connection is not (yet) possible and call the PubSubClient::loop() at a much slower pace to reduce CPU usage. (See #847)
This higher CPU load was probably introduced when fixing #683.

* [MQTT] Fix error reporting success status with longer payloads

Applied PR https://github.com/knolleary/pubsubclient/pull/360/files

* made MQTT_CALLBACK_SIGNATURE for esp32 functional

Applied PR knolleary/pubsubclient#336
@jannnfe jannnfe closed this as completed Feb 19, 2018
@TD-er
Copy link
Member

TD-er commented Feb 19, 2018

Closing the issue, so I can conclude the fix works as expected?

@jannnfe
Copy link
Author

jannnfe commented Feb 19, 2018

Oh yes sorry, my fault. It works perfectly!
Thanks for your nice work :)

@1043717432
Copy link

@jannnfe hi,How does mq9 intervene in espeasy, what do you choose in Devices?

@jannnfe
Copy link
Author

jannnfe commented Apr 26, 2018

@1043717432 Hello, i use it with the Analog Input Device. Check out Google or take a look at this post: http://www.letscontrolit.com/forum/viewtopic.php?t=681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants