3 Zigbee remotes in 1 automation

Hello!

It there way to do these in 1 automation, and not to do 3 different per zigbee remote controllers:
I have 3 different rooms with remote controllers ( 4 button ones ) and Sonos speaker. I do exactly same thing to remotes (plays music) but every room remote start playinig music in that room where they are mounted. So do i still haveto write own automations to every remote or is there way to do it in 1 automation what understand what remote was pressed and after that knows where music wanted to play?

Thank you!

The best way to do this is with a blueprint. You can then configure (easily) an instance of the blueprint for each room and it will use the same code but be configured differently.

Thanks for quick reply :slight_smile:
Is there any ready made blueprint for this case already? I have only played whit automations and scripts :slight_smile:

Wouldn’t a blueprint be the same thing as an automation. And creating three blueprints is just the same thing as three automations?

I would believe it’s quite easy to template.
You have the device_id that triggered the automation, this can be used to template what room to play in.
But we can’t really help you since you have not really posted anything that we can help you with.

There are a lot of blueprints for things like the IKEA remotes, so my guess is there are. I haven’t done any blueprints myself, though, so I’m not actually sure.

One automation with three triggers (one for each remote)? Give each trigger an ID, then choose in the action section based on the trigger id.

This is what i know. But there is three triggers ( 3 philips hue remotes what each has 4 button) + 2 sonos speakers in dirfferent rooms. So each remote what control sonos speaker in same room. But now i just haveto make tons of automations to evert remote ( i copy paste and change targers and entities ).
i was just asking is there better and easier way to do this :slight_smile:

There is, but we need something to help you.
It’s of no good if we just make a generic automation that you need to adapt and fail with and then we are back on square one again.
Just post what the events are, and what the service calls are.
Just some of it, that way we can post what you need and how you adapt it.

Of course, sorry miss understood :slight_smile:

Here is info:
3 rooms: Toilet, Hallway and Livingroom ( future too Kitchen and Bedroom )
3 Remotes ( Philips Hue 4 button new gen zigbee swiches connected to ZHA in HA )
3 Sonos Speakers, 1 in every room.

Toilet:
Remote id: d98889e6d082abe7214101f43022341d
Remote name: Musakaukosaadin WC
Sonos: media_player.sonos_toilet_roam

Livingroom:
Remote id: 902d41bf75f576541eb21e4e62ad3b27
Remote name: Philips Hue - MUSAKYTKIN OLOHUONE
Sonos: media_player.sonos_arc_livingroom

Hallway:
Remote id: 19992b09e7e4037397b0b9eba9fb2cdb
Remote name: Musakaukosaadin Eteinen
Sonos: media_player.sonossonos_hallway

And picture is now only to this Hallway Remote / Speaker. There is 1,2,3 and 4 clicks per button so 16 different automatios per remote control.

Personally, I would setup one automation per remote since there are 16 actions per remote. That way, you have just one automation that contains all the triggers for your remote. Assign each trigger item a trigger ID (3 button menu > Edit ID) and give it a descriptive name. Then in the “Then Do” section, add a Choose block and choose “Other Conditions > Triggered By” as your option and add as many options as you need. Then you pick the ID and add the actions you want to take if that particular trigger was executed.

I use this method for various remotes I have around the house.

1 Like

I make one automation per remote. Blueprints may sound smart but then you want one remote to be a little different and you can spend a month getting a blueprint to work for all.

But one automation that handles all the buttons - yes that is useful.

I use deconz so the triggers are events. But you can surely use this example as inspiration.

- id: 'Living_Room_Dimmer'
  alias: 'Living Room Dimmer'
  initial_state: 'on'
  mode: queued
  max_exceeded: silent
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: living_room_switch
  action:
    - choose:
      # Normal ON scene
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event == 1002 }}"
        sequence:
          - service: scene.turn_on
            entity_id: scene.living_room_normal
      # Long press full brightness
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event == 1001 }}"
        sequence:
            - service: light.turn_on
              data:
                entity_id:
                  - light.living_room
                brightness_pct: 100
      # Increase
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event == 2001 }}"
        sequence:
          - service: deconz.configure
            data:
              entity: light.living_room
              field: "/action"
              data: {"bri_inc":254, "transitiontime":50}
      # Decrease
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event == 3001 }}"
        sequence:
          - service: deconz.configure
            data:
              entity: light.living_room
              field: "/action"
              data: {"bri_inc":-254, "transitiontime":50}
      # Stop increase/decrease 
      - conditions:
          - condition: template
            value_template: > 
              {{ trigger.event.data.event == 2003 or
                 trigger.event.data.event == 3003 }}
        sequence:
          - service: deconz.configure
            data:
              entity: light.living_room
              field: "/action"
              data: {"bri_inc":0}
      # Off
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event == 4002 }}"
        sequence:
          - service: light.turn_off
            data:
              entity_id:
                - light.living_room

      #default:

Note that in this example I use the same feature as Philips Hue does to increase and decrease the light. Instead of flooding the Zigbee network with small incremental changes you start an increase or descrease with long transition time when you press down the +/- buttons long pressed and when you release the button, a new command is sent that stops the transition. That gives a smooth and reliable function. And it is was the Philips Hue hub also does

1 Like

Here is a quick example.

You need to change the “command” to what the event is for play and pause buttons, or if that is the same button and you use the toggle service.

description: ""
mode: single
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: d98889e6d082abe7214101f43022341d
      command: play
    id: toilet_play
  - platform: event
    event_type: zha_event
    event_data:
      device_id: d98889e6d082abe7214101f43022341d
      command: pause
    id: toilet_pause

  - platform: event
    event_type: zha_event
    event_data:
      device_id: 902d41bf75f576541eb21e4e62ad3b27
      command: play
    id: livingroom_play
  - platform: event
    event_type: zha_event
    event_data:
      device_id: 902d41bf75f576541eb21e4e62ad3b27
      command: pause
    id: livingroom_pause
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "{{ 'toilet' in trigger.id}}"
        sequence:
          - service: "media_player.media_{{ trigger.id.split('_')[1]}}"
            metadata: {}
            data: {}
            target:
              entity_id: media_player.sonos_toilet_roam

      - conditions:
          - condition: trigger
            id: "{{ 'livingroom' in trigger.id}}"
        sequence:
          - service: "media_player.media_{{ trigger.id.split('_')[1]}}"
            metadata: {}
            data: {}
            target:
              entity_id: media_player.sonos_arc_livingroom
1 Like