How to represent a pushbutton?

Hi there!

I’m currently working on Greg Badros’s excellent Vantage integration, seeing if I can improve it for my setup.

One thing that bugs me – the buttons on Vantage keypads are currently represented as a sensor object. I think it would be better to represent them as something with more semantics, such as a switch or a binary_sensor.

They are usually physically used as switches. You press them, and lights turn on and off. But sometimes they interact with more complex state or trigger arbitrarily complex complex actions on the Vantage system. And all they really are physically are pushbuttons, or momentary contact buttons (if you want to use technical terms…). They just have two states: pressed and released.

switch doesn’t seem to have the right semantics. For something to be a switch, Home Assistant should be able to turn it on and off. And these are purely physical buttons – you can’t turn them on and off from software.

binary_sensor seems perfect. Except… I notice that there is no device class called DEVICE_CLASS_BUTTON for binary_sensor. And none of the existing device classes describe a simple push button. Which makes me wonder… is there another type I’m supposed to be using? Or should I just add a DEVICE_CLASS_BUTTON or DEVICE_CLASS_PUSHBUTTON to binary_sensor?

The modern approach in Home Assistant is to fire an event when a button is pressed. The remote/keypad doesn’t get modelled as an entity at all (since it is stateless, there is no state to represent/track). If battery information is exposed, you could create a sensor entity just for the battery percentage.

Check the deCONZ integration for how this can be handled, including the new device automations available in version 0.100.0.

1 Like