My HOWTO: Smartthings Zigbee Button

Tags: #<Tag:0x00007f739b276490>

Here’s how I have a Zigbee smartthings button (GP-U999SJVLEAA) working with Home Assistant. You do not need a Smartthings hub or integration! This is a cheap, attractive button that not only provides 3 states (single press, double press, and long press) but also the current room temperature.

You’ll need:

  • Home Assistant
  • MQTT (I use the Hassio addon)
  • Zigbee Adapter (I use the husbz-1)
  • Smartthings Button (the GP-U999SJVLEAA)

Setup:

  1. Add you smartthings button to the zigbee network (Configuration | ZHA | Add Devices) - it should add a zha, binary_sensor, and sensor with “samjin” in the name
  2. Subscribe and listen to “zha_event” in the “Events” section of the developer tools (ex. http://your-ha/dev-event)
  3. Press the smartthings button and write down the “device_ieee” value displayed:
  4. Add the following HA automation, replacing all “<BLAH_HERE>” values accordingly (ex. replace “<YOUR_TOPIC_HERE>” with “buttons/pressed/st1”):
automation:
  - id: <ANY_ID_YOU_WANT_HERE>
    alias: <ANY_ALIAS_YOU_WANT_HERE>
    trigger:
      - event_data:
          command: button_single
          device_ieee: <YOUR_DEVICE_IEEE_HERE>
        event_type: zha_event
        platform: event
      - event_data:
          command: button_double
          device_ieee: <YOUR_DEVICE_IEEE_HERE>
        event_type: zha_event
        platform: event  
      - event_data:
          command: button_hold
          device_ieee: <YOUR_DEVICE_IEEE_HERE>
        event_type: zha_event
        platform: event          
    condition: []
    action:
      service: mqtt.publish
      data_template:
        topic: >
          <YOUR_TOPIC_HERE>
        payload: >
          {{trigger.event.data['command']}}
  1. Add a node-red MQTT listener to your desired flow with the proper server and topic name:
  2. Connect it to a switch, property of msg.payload, and ports “button_single”, “button_double”, and “button_hold”:
  3. Connect the switch ports to your desired nodes (ex. to turn on a light):
  4. You’re done!
6 Likes

Awesome!!! Useless device that was waiting for a solution till your advice!!!

Actually we don’t need MQTT to use it. I was lacking the part of your solution that resides on the trigger of the automation. The IEEE I caught on the states page of HA.

trigger:
  platform: event
  event_type: zha_event
  event_data:
    device_ieee: XX:XX:XX:XX:XX:XX:XX:XX
    command: button_single

You can create other automations using button_double and button_hold … The rest of the automation is up to you …

Thank you! Have a nice day!

1 Like

Awesome, glad to help.

Yes you can skip the mqtt thing and just add actions directly in the automation. But I try to put everything in node red (it’s so much better than ha automations), hence the mqtt to node red.

Just wanted to add that I have mine working via node red listening for the same event without using MQTT. Just use the Events node with a switch looking for device ID before the switch that looks for which type of button press you use. I did run into an issue where the firmware on 2 out of the 3 of my buttons was older and this event was NOT being sent for those until I updated the firmware using the SmarThings hub.

Example flow you can paste in below:

[{"id":"fc592c90.f14fa","type":"server-events","z":"bf70d280.fe9f4","name":"Samsung Button","server":"713b7b8a.d07fd4","event_type":"zha_event","x":100,"y":1160,"wires":[["a592f64.9cf6b08","ed01f1bc.a699f"]]},{"id":"a592f64.9cf6b08","type":"switch","z":"bf70d280.fe9f4","name":"Device ID Office Button","property":"payload.event.device_ieee","propertyType":"msg","rules":[{"t":"eq","v":"28:6d:97:00:01:03:d2:e9","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":1200,"wires":[["daedcd02.523b9"]]},{"id":"daedcd02.523b9","type":"switch","z":"bf70d280.fe9f4","name":"Button Click Type","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"button_single","vt":"str"},{"t":"eq","v":"button_double","vt":"str"},{"t":"eq","v":"button_hold","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":1200,"wires":[["ce85594c.2f9c88"],["28022d21.3bb632"],[]]},{"id":"713b7b8a.d07fd4","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
2 Likes

OMG - This is awesome. I’m going to switch over to your method for both my Samsung buttons and my Aeotec Wallmote. Thanks

I hate the double click option on this button because it makes a single click super slow to respond.

Yea definitely took me a while to figure that one out… Turns out its much easier than I thought. Learning more about node red just about every day. The easiest way to identity the location of the value you want is to click this little button when the debugging output is used.

This little button copies the path for this data:
image

So: payload.event.command

I picked up a Smart Things Button and set it up using your instructions, currently I have 3 separate automatons setup for single tap, double tap & hold.

I have an automation which runs at 11:30 pm each day called Bedtime, how do configure the 3rd automation (hold) to run the bedtime automation?

Thanks in advance

I haven’t used it, but I would try the automation.trigger service. I haven’t used it before, but that is what I see that looks promising in the services tab of the developer tools section of the front end UI.

My guess would be something like this:

  action:
    service: automation.trigger
    entity_id: automation.bedtime

That worked perfectly,

I didn’t think to look for a service called automation trigger

Thank you again

I was trying to import your flow so I can figure out how to use my Smartthings buttons in Node Red but I get the following error. Do you know what I am doing wrong?

I also had some issues with the example JSON that @jcbbas had posted. A lot of the issues were related to the use of fancy double quotes instead of normal double quotes.

Here is what I ended up with once I got everything cleaned up enough to import into Node-RED.

[{"id":"b2633c24.785dc","type":"switch","z":"b5dcf996.1b76b8","name":"Device ID Office Button","property":"payload.event.device_ieee","propertyType":"msg","rules":[{"t":"eq","v":"28:6d:97:00:01:03:d2:43","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":820,"wires":[["6ba69164.e2b4a"]]},
{"id":"6ba69164.e2b4a","type":"switch","z":"b5dcf996.1b76b8","name":"Button Click Type","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"button_single","vt":"str"},{"t":"eq","v":"button_double","vt":"str"},{"t":"eq","v":"button_hold","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":670,"y":820,"wires":[["e4b107f0.b03ce8"],[],[]]},
{"id":"e4b107f0.b03ce8","type":"api-call-service","z":"b5dcf996.1b76b8","name":"Toggle Office Lights","server":"713b7b8a.d07fd4","service_domain":"light","service":"toggle","data":{"entity_id":"group.officel"},"mergecontext":"","output_location":"","output_location_type":"none","x":890,"y":800,"wires":[[]]},
{"id":"3a0139b2.46e756","type":"server-events","z":"b5dcf996.1b76b8","name":"Samsung Button 2","server":"713b7b8a.d07fd4","event_type":"zha_event","x":190,"y":820,"wires":[["b2633c24.785dc"]]}]

Thanks for reply,

I actually figured it, probably the long way lol. I copied the code to note pad then examined the text in the flow to see how I needed to configure the nodes. It took a while but I got there.

Sorry about missing your post! Apparently I failed and did not post the json correctly. I have fixed it in my original post and now can be copied and pasted without dealing with all the quotes.

Thank you,

Appreciate your help

Thank you for posting this!

Thanks guys… I did not use MQTT, nor Node-Red either. Works perfectly.

I have a GoControl CECOMINOD016164 HUSBZB-1 USB Hub that controls both Zigbee and W-Wave on my system. For the Smarthings button I have the Zigbee Home Automation (ZHA) integration installed on HA. From the ZHA section of the HA Configuration menu, I initiated adding a new zigbee device, and once the Smarthings button was into pairing mode (it was new out of the box, and I just pulled the battery tab), ZHA found it.
I then went into the Developers tools section of HA and started listening to “zha_event” in the events/listen to events menu. Once the system is listening, started commands with the buttons (short/double/long presses). Below is what returned:

Event 2 fired 0:00 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "XX:XX:XX:XX:XX:XX:XX:XX",    **Yours will be different**
        "unique_id": "XX:XX:XX:XX:XX:XX:XX:XX",      **Yours will be different**
        "endpoint_id": 1,
        "cluster_id": 1280,
        "command": "button_double",
        "args": {
            "press_type": "double",
            "command_id": 0,
            "args": [
                2,
                0,
                0,
                0

Event 1 fired 0:00 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "XX:XX:XX:XX:XX:XX:XX:XX",    **Yours will be different**
        "unique_id": "XX:XX:XX:XX:XX:XX:XX:XX",      **Yours will be different**
        "endpoint_id": 1,
        "cluster_id": 1280,
        "command": "button_hold",
        "args": {
            "press_type": "hold",
            "command_id": 0,
            "args": [
                3,
                0,
                0,
                0
            ]
        }

Event 0 fired 0:00 PM:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "XX:XX:XX:XX:XX:XX:XX:XX",    **Yours will be different**
        "unique_id": "XX:XX:XX:XX:XX:XX:XX:XX",      **Yours will be different**
        "endpoint_id": 1,
        "cluster_id": 1280,
        "command": "button_single",
        "args": {
            "press_type": "single",
            "command_id": 0,
            "args": [
                1,
                0,
                0,
                0

Then following the above, I created an automation with one of the above as the trigger (example above/below):

trigger:
  platform: event
  event_type: zha_event
  event_data:
    device_ieee: "XX:XX:XX:XX:XX:XX:XX:XX",    **Yours will be different**
    command: button_single        **This can be 3 different triggers - single/double/hold)**

I will be buying more buttons for around the house to control locally.
—Enjoy!

anyway to view battery life? that still shows up as unknown for me

It should just work. One button took a day or so to start working after I paired it. Presumably it was trying to discover the channel or route as button presses didn’t work either. Now it’s fine.