[Brainstorming] Homie MQTT specification implementation #724
Replies: 1 comment 2 replies
-
I thought about it for a few minutes, here's my idea for a hybrid system, which shares code between the two implementations but that does require a refactor of the current MQTT codebase. Filesystem structure for a few examples:
MqttPropertyHandlerThis class is implemented for each piece of information provided by each capability. It contains the Homie property attributes. It also handles retrieving and setting the value in question from/into the capability. CapabilityMqttHandlerThis class is implemented for each capability. The implementation will return the home assistant component autodiscovery payload, as well as the Homie node attributes. All Since Hass likes JSON, the CapabilityMqttHandler will collect all the data from the properties, put it in a single JSON and publish it; subscribe to the command MQTT topic and pass any changes to the properties. Since Homie hates JSON, it won't do anything: each property will subscribe to its own value (on both valetudo and mqtt sides) and publish/set values accordingly. MqttControllerThis class is a singleton. It will instantiate all the CapabilityMqttHandlers available for the current robot, provide the autodiscovery config for the main Each base class will provide methods to automatically set up the boilerplate topics when possible (most of the homie attributes can be set once on start and then forgotten about, except for presets which may need a little special handling). On the Hass side, MqttController and CapabilityMqttHandler will both provide Hass components, the former will provide "vacuum" and the latter may provide whatever best fits. |
Beta Was this translation helpful? Give feedback.
-
I'd like to start this early since the MQTT support is still at very early stages and it can still be changed fairly easily. I'd like to introduce the Homie specification for MQTT autodiscovery: https://homieiot.github.io/
I know the hass.io integration is being worked on, but I do not use hass (and I actually really dislike it).
I use OpenHab which technically does have support the hass protocol, but it is very limited since it maps very poorly to OpenHab's rich object-oriented home automation semantic model (JSON payloads and OpenHAB don't get along very well)
In this discussion I'd like to brainstorm ideas on how to implement it.
One idea could be to implement it in each
CapabilityBasedAttributeMqttHandler
, which should be easy for most caps that handle only one piece of information (i.e. fan speed).However, for more complex data (such as the wi-fi configuration) that is currently published as a JSON object, each value has to be split into its own topic (see example in the website's homepage).
Another idea would be to have separate implementations for the hass-style and homie-style topic providers.
What do you guys think?
Beta Was this translation helpful? Give feedback.
All reactions