automation:
  - alias: Living room · Opple
    id: living_room_opple
    use_blueprint:
      path: oppo_6_btn_switch.yaml
      input:
        action_sensor: sensor.opple_2_action

        button_1_single:
          - service: light.turn_off
            entity_id: light.living_room

        button_2_single:
          - service: light.turn_on
            entity_id: light.living_room

        button_1_double:
          - service: light.turn_off
            entity_id: light.living_room_main

        button_2_double:
          - service: light.turn_on
            entity_id: light.living_room_main

        button_1_triple:
          - service: light.turn_off
            entity_id: light.living_room_ambient

        button_2_triple:
          - service: light.turn_on
            entity_id: light.living_room_ambient

        button_2_release:
          - service: scene.turn_on
            entity_id: scene.living_room_ambient_neon

        button_3_single:
          - service: media_player.media_play_pause
            entity_id: media_player.living_room

        button_3_double:
          - service: script.sonos_join_tv

        button_3_triple:
          - service: script.sonos_join_bedroom

        button_3_release:
          - service: media_player.play_next
            entity_id: media_player.living_room

        button_4_single:
          - service: script.music_play

        button_4_double:
          - service: script.music_play
            data:
              playlist: 'Starred'

        button_4_triple:
          - service: script.music_play
            data:
              playlist: 'Retro'

        button_5_single:
          - service: climate.turn_off
            entity_id: climate.toshiba_ac

        button_5_double:
          - service: climate.set_temperature
            entity_id: climate.toshiba_ac
            data_template:
              temperature: "{{ state_attr('climate.toshiba_ac', 'temperature') | int -1}}"

        button_6_single:
          - service: script.toshiba_ac_toggle

        button_6_double:
          - service: climate.set_temperature
            entity_id: climate.toshiba_ac
            data_template:
              temperature: "{{ state_attr('climate.toshiba_ac', 'temperature') | int +1}}"

        button_6_triple:
          - service: automation.turn_off
            entity_id: automation.tv_sonos_join_tv_on_google_cast

          - service: media_player.joing
            entity_id: media_player.master_bedroom
            data:
              group_members:
                - media_player.kitchen
                - media_player.bathroom

          # Music play, without the join
          - service: media_player.volume_set
            entity_id: media_player.master_bedroom
            data:
              volume_level: 0.2
          - service: media_player.shuffle_set
            entity_id: media_player.master_bedroom
            data:
              shuffle: true
          - service: media_player.select_source
            entity_id: media_player.master_bedroom
            data:
              source: "Evening Chill"

          - delay: 00:01:00
          - service: automation.turn_on
            entity_id: automation.tv_sonos_join_tv_on_google_cast
