Zigbee2MQTT [Z2M] - Samsung SmartThings Button

Blueprint to support the Samsung SmartThings Button using Zigbee2MQTT.
Built starting with the ZHA version by johnny5w

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Supported actions:

  • Single press
  • Double press
  • Hold

samsung-smartthings-button

Blueprint:

blueprint:
  name: Zigbee2MQTT [Z2M] - Samsung SmartThings Button
  description: Automate your Samsung SmartThings button using Zigbee2MQTT.
  domain: automation
  input:
    samsung_smartthings_button:
      name: Samsung SmartThings Button
      description: The Samsung SmartThings button to use
      selector:
        entity:
          integration: mqtt
          domain: sensor
    remote_button_short_press:
      name: Single Press
      description: Action to run on single press
      default: []
      selector:
        action: {}
    remote_button_double_press:
      name: Double Press
      description: Action to run on double press
      default: []
      selector:
        action: {}
    remote_button_hold_press:
      name: Hold Press
      description: Action to run on hold
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
trigger:
  - platform: state
    entity_id: !input "samsung_smartthings_button"
action:
  - variables:
      press_type: "{{ trigger.to_state.state }}"
  - choose:
      - conditions:
          - "{{ press_type == 'single' }}"
        sequence: !input "remote_button_short_press"
      - conditions:
          - "{{ press_type == 'double' }}"
        sequence: !input "remote_button_double_press"
      - conditions:
          - "{{ press_type == 'hold' }}"
        sequence: !input "remote_button_hold_press"
1 Like

Hi ImplaleAle22

Thanks very much for this blueprint. I cant figure out, how to get the SmartThings Button to switch the state of a ligth. I have tried setting the automation up via the UI and the blueprint, but i get this error message.

“Error: UndefinedError: ‘dict object’ has no attribute ‘to_state’”

I am very new to the HA-scene and i cant seem to find any information, which can help solve my problem. Can anybody point me in the rigth direction? I will be very grateful.

My Automation Config is the following:

> mode: restart
> max_exceeded: silent
> trigger:
>   - platform: state
>     entity_id: sensor.knap_b_action
>     attribute: action
> action:
>   - variables:
>       press_type: '{{ trigger.to_state.state }}'
>   - choose:
>       - conditions:
>           - '{{ press_type == ''single'' }}'
>         sequence:
>           - type: toggle
>             device_id: 956fc7f9878e24e6864ca6657d10d933
>             entity_id: light.0x00178801082cd644
>             domain: light
>           - type: toggle
>             device_id: 61df5498cc083802392c1bf41cc259c5
>             entity_id: light.loftlampe_ved_skrivebordet
>             domain: light
>       - conditions:
>           - '{{ press_type == ''double'' }}'
>         sequence: []
>       - conditions:
>           - '{{ press_type == ''hold'' }}'
>         sequence: []
> id: '1660161786337'
> alias: Knap B - Hyggestuen
> description: '

And my blueprint config the following

> id: '1660161786337'
> alias: Knap B - Hyggestuen
> description: ''
> use_blueprint:
>   path: ImpaleAle22/zigbee2mqtt-z2m-samsung-smartthings-button.yaml
>   input:
>     samsung_smartthings_button: sensor.knap_b_action
>     remote_button_short_press:
>       - type: toggle
>         device_id: 956fc7f9878e24e6864ca6657d10d933
>         entity_id: light.0x00178801082cd644
>         domain: light
>       - type: toggle
>         device_id: 61df5498cc083802392c1bf41cc259c5
>         entity_id: light.loftlampe_ved_skrivebordet
>         domain: light

I have this same issue, did you ever get it figured out?

Wondering if you able to figure this out as I am having the same issue with this blueprint

This blueprint was working flawlessly. But then since I switched from Conbee2 to ZBDongle-P, it stops working.
I also changed to a new battery as well, but I don’t think it’s relevant here.
Somehow the automation never got triggered.

Migrated to z2m and used this blueprint and had no issues the first day. Then updated HA and not sure why, but my buttons aren’t working anymore. I see the button update the logs but the blueprint doesn’t trigger.

Edit, not sure why this template stopped working, but recreated it by hand using the right actions and setting trigger IDs

I was encountering the same problems. Now works for me!

I figured it was something to do with the triggering. Made a local copy off blueprint. Now works after commenting out attribute: action in trigger:

   attribute: action 

Can comment or delete line in trigger portion of blueprint.

trigger:
  - platform: state
    entity_id: !input samsung_smartthings_button
#    attribute: action

found referenced at Zigbee2MQTT - Tuya 4-button Scene Switch (TS0044) - #54 by just.bondarenko

1 Like

Ok. I just updated the YAML in my original blueprint post to remove attribute: action. I think that should fix the blueprint when imported.

1 Like

I updated to the just-released Zigbee2MQTT 2.0.0 today and now this automation is not working.

It is probably something to do with action trigger breaking changes in 2.0.0 as referenced in below GitHub discussion:

Zigbee2MQTT 2.0.0 breaking changes · Koenkk/zigbee2mqtt · Discussion #24198

All action sensors are now disabled by default (sensor.*_action entities). It’s recommended to use the MQTT device trigger instead. In case you really need the action sensors, add the following to your configuration.yaml.

homeassistant:
  legacy_action_sensor: true

and points to this

https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html#via-mqtt-device-trigger-recommended

In zigbee2mqtt/configuration.yaml adding legacy_action_sensor: true and restarting Zigbee2MQTT Add-on indeed got the automation working again.

homeassistant:
  enabled: true
  legacy_action_sensor: true

However I plan to explore ways to migrate automation to use MQTT device trigger, as is now recommended, or event entity, as THAT will be the 2.0.0 recommendation, as described here:

https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html#via-home-assistant-event-entity-experimental

Via Home Assistant event entity (experimental)

Note: event entity is experimental and may break in the future.

This method work by responding to the state change of an event entity. The specific event can be targetted via the event_type attribute. This will become the recommended method with 2.0.0

I was able to successfully create an automation with event entity. I leveraged outline from the existing one. It seems to respond more snappily to button presses as well.

Found that I needed to use experimental_event_entities: true in the z2m conf in the 2.0.0 release version so that the event entity would appear in HA.

Blueprint yaml and the configuration reference: