Different actions depending on trigger data value

I’d like to have an automation trigger different actions depending on state (ideally scene state, but there’s no such thing so I’ll use a device from that scene instead).

What I’m thinking of doing is to create two versions of the automation and add conditions that check the state of the device to both. Is there a better way or will this work fine?

The objective is that during Movie mode, rotating the Xiaomi cube should control volume instead of light brightness.

I have a dumb receiver so I’ve mapped the IR codes for volume up and down to a Broadlink switch’s on and off commands.

Now, how do I check based on the trigger value to turn on or off the switch?

Have a look at the template in the last example in the documentation for harmony remote.

It uses a data template - if you need to call different services, you can use a service template too.

1 Like

Service Template is what I was looking for. Thanks! Now, the Xiaomi cube can turn down the volume on my receiver, if it’s on.

  - alias: Cube Dimmer (Volume)
trigger:
  platform: event
  event_type: cube_action
  event_data:
    entity_id: binary_sensor.cube
    action_type: rotate
condition:
  condition: state
  entity_id: switch.avr_power
  state: 'on'
action:
  service_template: >
      {% if trigger.event.data.action_value | float > 0 %}
        switch.turn_on
      {% else %}
        switch.turn_off
      {% endif %}
  entity_id: switch.avr_volume
1 Like