Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Using MQTT Discovery for buttons

$
0
0

@pmansvelder wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles