I have buttons which, when pressed, send a message over the 433 MhZ channel. These messages are intercepted by a RF-MQTT bridge which publishes to rfbridge/in the received message.
I am starting to use Home Assistant in order to move away from my own orchestrator, which when a message was published to rfbridge/in, was taking decisions about what to do (toggle a specific switch for instance).
I am now planning to use App Daemon to handle this, with HA as the foundation to configure the devices (lights, switches, etc.).
How and where should such a button be defined?
in HA? If so, how will App Daemon know that it was triggered? (and how to define it in the first place in HA)
in App Daemon? In such a case the logic of the “listen to MQTT”/“act upon messages in specific topics” will be coded there - which I feel to be some kind of disconnect with HA as other devices (lights for instance) will be defined in HA.
Bonus question, in case it is to be defined in HA (first case above): these buttons, for reasons I do not understand, send different messages on subsequent presses. It is usually a changing prefix and a stable suffix (123999, 456999, …). Is it possible to match such a pattern? (similar to .endswith() in Python)
Currently, I use this automation in HA to generate an event, which I detect in appdaemon to do processing on, because AD has not had the ability to handle MQTT messages for long. Eventually, I will probably just detect it in AD to avoid the trip through HA, but its not a high priority. I really don’t see what the ‘disconnect’ would be.
@gpbenton Thank you for your response. I have a few questions if you do not mind:
How do you detect this even in AppDaemon?
Out of curiosity, why didn’t you handle MQTT in AppDaemon via a relevant module such as paho-mqtt?
What I meant here is that all the devices would be defined in HA and I address them via their HA names, except this one button which would be handled in AppDaemon. I would prefer (for maintainability and general aesthetics) to have everything defined in HA and the pure orchestration done in AppDaemon.
How do you differentiate between two buttons which send a different signal? You hold it in payload and use it (=make relevant decisions) in AppDaemon?
That would be hard work. I would need to create a separate thread to listen for subscriptions, and all the management involved in that. Much easier to let HA do that as it was listening anyway.
There isn’t really a device type in HA for this. Its just an MQTT message received that is acted upon, so it doesn’t really matter where its handled. You could define an MQTT sensor that updated its state according to the incoming MQTT message, but I don’t see that would achieve very much.