Automation using button actions and "options"

Hi I am a bit new to Home Assistant - coming from openHAB and tried to simplify things as much as possible. My old (openHAB) setup was fairly complex with a lot of Jython scripting and whatnot. In the end I realized it made the setup into a big ship I couldn’t steer anymore. Before setting up everything from scratch in openHAB, I decided to give HA a spin, but I am struggling with (maybe) easy things.

I am using the latest version 2023.04 in a docker container - and want to stick with “UI” centric setups. Currently, if possible, I don’t want to go the scripting / python / … route yet.

What I am trying to do is the following:

  • Using my existing Zigbee2MQTT setup (done)
  • Integrating MQTT into HA as devices & entities (done)
  • Trying to launch an automation for a IKEA Tradfri remote (which uses “action”) in a single (!) automation (failed)

Why am I doing that? I want to bundle the button inside one automation using “options” to trigger something based on different actions, while being as generic (in terms of the different button actions) as possible. It should work in theory, but it doesn’t.

The “state” was entered by hand. The UI didn’t had some sort of drop-down, as I thought it had. I also tried entering the “state” with quotes, but that didn’t to the trick either. I tripple checked the spelling after copying the string from the “log”.

The trigger gets “triggered”. At least that works. :slight_smile:
Maybe you can give me a hint? Thank you!

alias: "Fernbedienung: Küche"
description: Reagiert auf Eingaben durch eine Fernbedienung.
trigger:
  - platform: state
    entity_id:
      - sensor.zigbee_tradfri_remote_03_action
    attribute: action
condition: []
action:
  - choose:
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: sensor.zigbee_tradfri_remote_03_action
                attribute: action
                state: arrow_right_click
              - condition: state
                entity_id: sensor.zigbee_tradfri_remote_03_action
                attribute: action
                state: arrow_left_click
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.wohnzimmer
            data:
              media_content_id: media-source://tts/google_translate?message=This+worked%21
              media_content_type: provider
            metadata:
              title: This worked!
              thumbnail: https://brands.home-assistant.io/_/google_translate/logo.png
              media_class: app
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://tts
                - media_content_type: provider
                  media_content_id: media-source://tts/google_translate?message=This+worked%21
mode: single

Not familiar with Tradfri, but could this be the problem?

Hi there and thank you. It’s working fine with openHAB (2+3) and the “action” is reported fine in the log, so I guess it must be something else. Plus, I am not using the Tradfri integration, but Zigbee2MQTT.

If I use the “action” (left, right, toggle, …) as the “trigger” it also works well. But not the way I want to use it. (In a more generic way.)

Mh. So I guess this is only possible using some advanced scripting. :slight_smile:
I will try my best.