Getting SmartThings Button to work?

Hi. Apologies for this noob question, but I’m having trouble following some of the advice on the forum ( … because I’m a noob with HASS).

I’m trying to get the SmartThings button to work. I’ve been following some of the advice … but I’m not sure if I’ve done things correctly. I haven’t been able to get the button to work through HASS. I’m using it through my SmartThings hub (… same for pretty much all my zigbee devices)

The automation script I’m using is:

- id: 'xxxxxx'
  alias: Bedroom 1 - Push Button to toggle Bedside Lamps
  trigger:
  - event_data:
      device_ieee: xx:xx:xx:xx:xx:xx:xx:xx
      command: button_single
    event_type: zha_event
    platform: event
  condition: []
  action:
  - data:
      entity_id: group.bedside_lamps
    service: light.toggle

Now I’ve assumed the device_ieee is the zigbee ID. Is this correct?
Is there anything I’m missing from the script?
Is there anything else I need to add to my config?

This is how I have mine setup. The only thing I see different is that you have a ‘-’ before event_data and I don’t. Could be enough to break it…

- id: MasterColorChange
  alias: Master Bedroom Light Flux
  trigger:
    platform: event
    event_type: zha_event
    event_data:
      device_ieee: xx:xx:xx:xx:xx:xx:xx:xx
      command: button_single
  action:

I used the HASS GUI to create the automation. It’s the same format as the others, so I doubt that’s it.

Do you use the SmartThings hub to control your devices?

Since it sounds like you are using the button via the SmartThings Integration, and not via a Zigbee USB stick, you’ll want to the the event_type of smartthings.button instead of zha_event. Instead of a command field, you’ll define a value of pushed, held, or double, and instead of the device_ieee you can use the friendly name of the button from SmartThings.

2 Likes

Awesome. Thank you!

Something I tried earlier was to use another method as descibed here: https://www.home-assistant.io/components/smartthings/#events

That didn’t work, but the problem seems to have been that I had the wrong event_type. Having an event_type of smartthings.button seems to have done the trick. It’s all working now.

I’m going straight through my zwave stick. Sorry. I missed the part about going through the smartthings hub. apop seems to have you covered in post 4.

No worries. That pointed out now, I realise how I misread the documentation. Now that that’s been clarified, it’ll help me in the future. It’s a steep learning curve, but I’m getting the hang of it. :smile:

Hi guys, I’m kinda new at this, but having troubles with my Aqara buttons via SmartThings. I can set up a NodeRed flow to turn a light on and off with an Aqara door reed switch fine. The button shows as per the image below in HA, but the only sensor is the battery. Is this normal? Or is something wrong with the device handler in ST. Should I reinstall?

I have some events coming through intermittently from the Aqara buttons when I tell it to listen to smartthings.button as below. It only works like 1 in 10 times though.

Has anyone else seen this? Is it working as designed? If I can’t find an Entity for the button, how do I get the event in NodeRed? Thanks!

hey, can you share the final example code please?

ignore, got it working.
i had to find the unique id which was buried inside: \config.storage\core.entity.registry (find the “button” and look for the id there, mine was for a button temp sensor))

this works for button pressed once and then twice

- id: LivingRoomButtonPressedOnce
  alias: Living Room Button Pressed Once
  trigger:
    platform: event
    event_type: smartthings.button
    event_data:
      device_id: 22a026b9-8b93-423e-xx-xx
      value: pushed
  action:
  - data_template:
      entity_id: light.study_back_light
    service_template: light.turn_on

- id: LivingRoomButtonPressedTwice
  alias: Living Room Button Pressed Twice
  trigger:
    platform: event
    event_type: smartthings.button
    event_data:
      device_id: 22a026b9-8b93-423e-xx-xxx
      value: double
  action:
  - data_template:
      entity_id: light.study_back_light
    service_template: light.turn_off

also, if you log into your ST Hub, then go to the button and look at hte events.
you can also find the device ID there

3 Likes

Just for future reference, if you use name instead of device_id in your automations, you can use the friendly name of the button.

You can also get the details on the button’s data if you go to Developer Tools, and then Events, and put in smartthings.button as your event to subscribe to. Click start listening, then press your button, and all of the data the event data that gets passed to Home Assistant will display there.

1 Like

hey,
good tip - however how do i apply this sorry?
im not sure what the friendly name of hte button is however, as i dont see the button on its own?
as a temp/battery sensor?

It should be whatever you named it in SmartThings, i.e. “Living Room” in your case it looks like (caveat: it’s been awhile since I’ve used the SmartThings integration as I have since switched to ZHA, but I believe that’s how it worked). But if you want to be sure, you can always go through the Developer Tools process I outlined to get the name that way.

I got single click to work but no double ( using Smartthings )
I can see that in Smartthings event log Button 1 ja Button 2 ( single and double click ) works ok.
Code is here and tried exactly same code, just changed pushed and double.
What could be reason ?

- alias: 'Nappi_testi'
    trigger:
      platform: event
      event_type: smartthings.button
      event_data:
        device_id: e06f0c00-9d3f-4a14-b826-9e040c75exxx
        value: double
    action:
    - service: switch.turn_on
      entity_id: switch.kuisti_valo

Would you share the link to ST Hub, i can’t find how to get there.

hey,
its here: https://graph.api.smartthings.com/

however i dont use that anymore, as ive moved over to a ConBee2, thats a load better overall
with that i just listen to teh deconz event and press a button, it will then give all the info you need

Thanks, i’ll look into this

I haven’t seen a 100% guide on here for getting the button press event working with a SmartThings Hub. I was able to get this working tonight and figured I’d let others know how to do it as well.

My example triggers a smart switch when I press the SmartThings Button

  1. Identify the “Data Payload” for your button, this will look something like this:
{
  "component_id": "main",
  "device_id": "42a16cf2-fef7-4ee8-b4a6-d32cb65474b7",
  "location_id": "2a54b9fa-f66c-42d9-8488-d8f036b980c8",
  "value": "pushed",
  "name": "Scene Button"
}

More documentation on this payload can be found here

To get this payload for your button you’ll need to enable debug logging for the smartthings integration by adding the following to your configuration.yaml and restarting Home Assistant:

logger:
  default: info
  logs:
    homeassistant.components.smartthings: debug

Link to documentation for this as well

Once you’ve got debug logging enabled, head over to “Configuration > Logs > Load Full Home Assistant Log” Then press your smartthings button and refresh the logs. You should see an entry like this:
DEBUG (MainThread) [homeassistant.components.smartthings] Fired button event: {'component_id': 'main', 'device_id': 'your-data-here', 'location_id': 'your-data-here', 'value': 'pushed', 'name': 'Button 1', 'data': {}}

Your “Data Payload” is that entire json blob.

  1. The “Event type” is smartthings.button

When you put it all together you get a trigger for your automation that looks like this:

2 Likes

You win! I could not get this to work. I tried to follow everyone else but this is what finally allowed me to get the stupid button to work. Thanks!

*NB - You can just go to Developer tools > Events > Enter smartthings.button into the “Events to subscribe to” field > Click Start Listening > Press button.

This will get you the information without having to do all that debugging stuff.

2 Likes

Thanks very much to the last two posters.
This needed to be bumped. It is the only thread with the answer to configuring ST buttons using the ST hub, and should definitely be in a HS wiki somewhere.