Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here it is -- mqtt items and discovery.
I have just submitted a pull request that adds mqtt item support as well as mqtt discovery as defined by
Home Assistant. Full documentation is found in mqtt_items.pm, but I summarize here.
mqtt_items.pm:
managing all messages associated with that device.
from the device and publish command topics to the device. This
supports Tasmota, IOT4, and likely ESPurna devices
misterhouse item and will publish state messages and receive command messages
for that existing item
well as other topics such as the brightness topic for dimmable devices. I have not yet added support for colour lights, but if someone can point me at a good MH implementation of a light with colour, I will take a look.
defining the objects statically can be tedious. See discovery below.
mqtt_discovery.pm:
mqtt devices. Most mqtt devices have some support for discovery as
defined by Home Assistant. Usually it needs to be turned on on
the device (eg. Tasmota -- setOption19 1).
Misterhouse items are created (mqtt_RemoteItem) for
the discovered devices. These items can be written to a .mht file
so the next time misterhouse is run, they will appear as first class
misterhouse items.
allowing misterhouse items to be discovered by Home Assistant, or by another
instance of misterhouse or anything else that can consume discovery messages.
much more broadly.
MQTT_DISCOVERED_ITEM item type for discovered items written to a .mht
file by mqtt_Discovery::write_discovered_items().
mqtt.pm:
including the existing mqtt_item class, but there have been some
bug fixes and small enhancements made to support the new functionality:
- multiple mqtt broker support has been fixed. The code was there,
but it shared a receive buffer across brokers which didn't work very well :-)
- enhanced debugging support with debug levels 1-3
- the ability for an object to listen to a list of topics or topic patterns.
(thanx Gilles for the topic pattern support!)
- I had to remove Gilles' short circuit when an object was found matching
a message topic because there are cases where multiple objects receive the
same topic
- optionally unloaded the set function, with the addition of a new object
method $obj->receive_mqtt_message(). This makes the item code more understandable.
- added methods for managing retained topics
Enjoy. Open to any and all feedback or suggestions.