A button device that triggers an event

Hi all, I’m looking for a device that’s just a simple button that triggers an event. So the event should just be something that signifies “button was pressed”. Not a sustained state. Just a trigger.

Anyone know if this kind of thing exists and if there’s a commercial product I can find? Wifi or Zigbee are both fine.

Xiaomi buttons are zigbee.

1 Like

If you want this button to be battery powered, it will likely use ZigBee or 433MHz RF because they are more energy efficient than Wi-Fi.

Philips Hue Dimmer Switch is one example of a ZigBee-based device with 4 pushbuttons. There are similar devices from Ikea (Tradfri) and Xiaomi.

For 433MHz RF there’s a wide variety of pushbutton devices including key fobs.

1 Like

I have a few of these and they work great. Zigbee.

1 Like

Do those need a smartthings hub or can they be paired directly to a HUSBZB-1 zigbee stick?

And do they only do single press or do they support double click/long press?

They can be paired directly to the stick and three types of presses are recognized: press, double press, and long press.

1 Like

@brandont, I have the Sonoff version of this device which also provides the same set of actions, but only works on the sonoff app. In Home Assistant, it gets states which are sustained:

  • Single Press = Off
  • Double Press = On
  • Long Press = Off

So in HA, once it’s On, then you can’t use Double Press again as the state is already On and won’t change and won’t trigger another event. You have to Single Press to change the state to Off, then Double Press will work again.

I’m afraid of these other devices having the same behavior. Have you actually the Samsung one and confirmed it actually works as expected? Or is there a different event I should be monitoring in HA?

@Cheesenwine the button events are stateless. When the button is pressed, you’ll receive one of three zha events: button_single, button_double, or button_hold.

I use both Node Red and the native HA Automations to capture and respond to presses (or double press, holds) directly.

Ah ok that looks like where I’m going wrong then.
@brandont where do I get the device_ieee? what is that?

Once you pair the button with Zigbee, you get the device_ieee from the Events part of Developer Tools (just press the button and you’ll capture it from the zha_events). Here is what I used as a guide:

I have a button that does that too.

I fixed it by setting the state back to ‘none’ one second after it goes to ‘single’ or ‘double’:

- alias: LC Reset Aqara Click State
    trigger:
      - platform: state
        entity_id: sensor.aqara_click
        to: 'single'
      - platform: state
        entity_id: sensor.aqara_click
        to: 'double'
    action:
      - delay: '00:00:01'
      - service: python_script.set_state
        data_template:
          entity_id: sensor.aqara_click
          state: none

it uses a python script to actually do the work:

#==================================================================================================
#  python_scripts/set_statev2.py 
#==================================================================================================

#--------------------------------------------------------------------------------------------------
# Set the state or other attributes for the entity specified in the Automation Action
#--------------------------------------------------------------------------------------------------

# service:
# python_script.set_statev2
# {"entity_id": "light.keukeneiland","state":"on","icon":"mdi:door","friendly_name":"test"}

inputEntity = data.get('entity_id')
if inputEntity is None:
    logger.warning("===== entity_id is required if you want to set something.")
else:    
    inputStateObject = hass.states.get(inputEntity)
    inputState = inputStateObject.state
    inputAttributesObject = inputStateObject.attributes.copy()

    for item in data:
        newAttribute = data.get(item)
        logger.debug("===== item = {0}; value = {1}".format(item,newAttribute))
        if item == 'entity_id':
            continue            # already handled
        elif item == 'state':
            inputState = newAttribute
        else:
            inputAttributesObject[item] = newAttribute
        
    hass.states.set(inputEntity, inputState, inputAttributesObject)

I don’t remember where I got the script but it wasn’t my invention.

Have you considered NFC tags I have several but have not integrated yet but seems like an alternative and the benefit of no need for power as they are passive and cheap to boot