MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

Feature request: simple MQTT

Open flatsiedatsie opened this issue 7 years ago • 20 comments
trafficstars

Currently the MQTT messages that MySensors generates is quite complex. The MQTT path has a lot of details that I don't really need.

Perhaps MySensors could have a simpler MQTT output mode which makes it easier to import/connect in the various controllers? Something like device/sensor/value?

flatsiedatsie avatar Oct 10 '18 15:10 flatsiedatsie

Perhaps the Homie standard could be followed: https://github.com/homieiot/convention

flatsiedatsie avatar Oct 17 '18 14:10 flatsiedatsie

Actually it would be pretty neat if the Homie convention could be followed. OpenHab 2.4 would be able to autodiscover MySensors sensors.

davidgraeff avatar Oct 19 '18 21:10 davidgraeff

Actually it would be pretty neat if the Homie convention could be followed. OpenHab 2.4 would be able to autodiscover MySensors sensors.

Yes! I'm done migrating OpenHAB to the new mqtt binding and I completely agree this is the way to go.

I think this could be done all in the mqtt gateway, even working in paralell with all the actual stuff.

Do you (community) think that this is an effort worth doing? Are there any other interested parties?

Please let me know, we could start tinkering with a fork of the gateway.

Regards

guillebot avatar Dec 18 '18 20:12 guillebot

@guillebot Definatly a approch worth some investigation. This might nearly (ID requests need to be handled) make the MQTT part of my MySensors binding obsolete.

tobof avatar Dec 19 '18 08:12 tobof

Yes, probably the MQTT part, but the logic behind the discovery (which is the most important) not.

Thanks!

On Wed, Dec 19, 2018 at 5:44 AM Tim [email protected] wrote:

@guillebot https://github.com/guillebot Definatly a approch worth some investigation. This might nearly (ID requests need to be handled) make the MQTT part of my MySensors binding obsolete.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mysensors/MySensors/issues/1212#issuecomment-448514565, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF62e7hFpMLAk9T-tQODBCmXJatDFENks5u6fyBgaJpZM4XVju2 .

guillebot avatar Dec 19 '18 10:12 guillebot

Yes, but mysensors doesn't adhere to homie convention.

So we have the following paths as I see it:

  1. Modify mysensors mqtt gateway in order to adhere to homie convention
  2. Convince the guy writing the mqtt binding that mysensors protocol is indeed open enough so he will add/allow the discovery of mysensors-convention 2.1.) Fork thay same binding and do it outside Eclipse Smarthome, as many of the non official bindings.
  3. Continue to add things manually. This is not that bad, it's just a shame thay having a nice documented protocol in mysensors, we have to add them by hand every time. I'm convinced thay the mysensors platform is one of the bests in terms of software quality, and I'm sure that OpenHAB is indee the best. Just struggling to make both work together.

Thanks a lot for your time

guillebot avatar Dec 19 '18 14:12 guillebot

I'm open to a PR that adds mysensors to the MQTT binding. I will just not do it myself, because I'm a bit in a conflict (biased), because I'm also an author of the Homie convention.

I have a developer of HomeAssistant on board, that will soon merge Homie support into HomeAssistant as well. I think, it is generally not bad if all of the IoT community settles on one convention.

davidgraeff avatar Dec 19 '18 15:12 davidgraeff

Good to know. And thankful.

To be clear, I love the homie convention, and for me the ideal scenario would be for mysensors to add a homie-mode. The whole iot/domotic world need standards more than anyhing else.

As I am a poor programmer both in java and arduino, (Electronic Engineer guy here), I will try to decide which way to explore.

guillebot avatar Dec 19 '18 15:12 guillebot

@tekka007 @mfalkvidd Would you accept a change of the mysensors MQTT layout?

davidgraeff avatar Dec 19 '18 15:12 davidgraeff

@tekka007 @mfalkvidd Would you accept a change of the mysensors MQTT layout?

Please guys, at least consider it.

The actual MQTT protocol works, is good, and I'm using it, and I'm thankful for all your effort, but is really a 1:1 map of the serial protocol, which is overkill and innecesary for mqtt iot devices.

Thanks to you all.

guillebot avatar Dec 19 '18 15:12 guillebot

Since a change would break all existing systems, such a change would need to be announced very well in advance, and would require a major release of MySensors (3.0 or 4.0). We should probably reach out to all controller projects that currently support MySensors over MQTT and encourage them to support he new format, and/or help them adapt their code. According to https://docs.google.com/spreadsheets/d/1xQ_654MkTcVmEKyCtcyLd0Tpw8GXRL1fvrUqstN_uNM/edit#gid=471683970 there are currently 8 controllers supporting MQTT but that might not be a complete list.

mfalkvidd avatar Dec 19 '18 15:12 mfalkvidd

So that is: Domoticz | HomeGenie | Home Assistant | MyController.org | MyNodes.NET | nodeRed (FotoFieber) | OpenHAB 2.4 | Vera | MyHouse

With Home Assistant and OpenHAB supporting (or will support) Homie. Still a few controller left.

davidgraeff avatar Dec 19 '18 16:12 davidgraeff

I am not familiar with the mqtt code, but would it be a big difference in development and maintenance to support both the existing format and the homie format and let users selct format by setting a define?

mfalkvidd avatar Dec 19 '18 16:12 mfalkvidd

I agree that is the best solution to allow both.

The file in question is: https://github.com/mysensors/MySensors/blob/development/core/MyGatewayTransportMQTTClient.cpp

Within that file in reconnectMQTT a few static publishes (homie version, name, mySensor node) would need to be done. A "last will" need to be established here as well to handle a disconnect properly.

And for every sensor/log/whatever change in gatewayTransportSend a publish need to done to the corresponding homie topic as well. No need for any receiving part.

davidgraeff avatar Dec 19 '18 16:12 davidgraeff

Why no need for receiving part? mySensors has both sensors and actuators.

guillebot avatar Dec 19 '18 16:12 guillebot

It's called mysensors :D I didn't know the framework can handle actuators as well.

However, someone need to implement this.

davidgraeff avatar Dec 19 '18 17:12 davidgraeff

Yes. great platform, confusing name.

guillebot avatar Dec 19 '18 17:12 guillebot

I just noticed tha Jeedom has mqtt support and Jeedom isn't included in the google spreadsheet.

mfalkvidd avatar Dec 20 '18 09:12 mfalkvidd

Hello, in case anyone is watching this and might be interested. I've taken a different route to trying to build in support for either openhab/ homie or anything else into any of the others and constructed a currently very simple MySensors controller that acts as a gateway to Homie. (in nodejs/ typescript)

It advertises all the MySensors nodes in the network as Homie devices and provides bidirectional comms between the two systems. I've built and tested this using the Homie support in OpenHab 3, and it works well, for where I've got to.

https://github.com/daviddawson/mysensors-homie-bridge

I'll be expanding it out as I add more to my mysensors setup, all I have at the moment is AC relay control.

daviddawson avatar Jan 16 '21 12:01 daviddawson