Hello people,
I am using HA for my house, with Arduino Mega controllers on a wired network as endpoints for the actual control entities:
- switches for relays
- lights for both relays and dimmers
- covers to control my sunscreens
- locks to control my door locks
- binary sensors for my pir sensors and magnet switches
All of these I have managed to integrate with the MQTT discovery mechanism (as do the Tasmotized wifi controllers I use), with a lot of trial and error. I have got it working now, which means I only have to setup my controller, and all the items (switches, lights, binary_sensors, covers, locks) are generated automatically in HA.
The only item on my list are the buttons I use to control the lights in my house. I could use a binary sensor, but that only gives me on/off behaviour. I also want things like âlong pressâ to be exposed.
At the moment I use my automations to read from a MQTT topic, while my Arduino code sends a âbutton0â or âbutton0_longâ message, but I saw in the MQTT discovery documentation there is also a âdevice triggerâ (https://www.home-assistant.io/integrations/device_trigger.mqtt/) method I could use.
Reading the docs I am at a loss: the way to generate this seems similar to the other items, but I cannot understand how it works: Do I set up a âdevice triggerâ for each type of button press I want first, and then send output on the topic I just defined? And what command should I output then? In the setup I give the following config:
{"automation_type":"trigger","topic":"domus/test/uit/button","type":"button_short_press","subtype":"button_1","dev":{"ids":["domus_test_json"],"cns":[["ip","192.168.178.79"],["mac","F0:01:02:03:04:4B"]],"name":"Domus Mega Test","mdl":"Mega 2560","mf":"Arduino"}}
But nothing gets defined when I look at the integrations screen, where all the other items do show up.
What would be helpful is an example of both the setup of the discovery phase and an automation which uses this âdevice triggerâ.
Thanks for all the help in advance,
Peter Mansvelder