<commit_before>media_player:
  - platform: onkyo
    host: !secret receiver_ip
    name: receiver
  - platform: spotify
    client_id: !secret spotify_client_id
    client_secret: !secret spotify_client_secret
    aliases:
      70f8bb9a8a5393ef080507a89e4b98d139000d65: home
      126a80ef484035c196dd9f39d0c1a2c9e869810c: receiver
      009e058c883c683e1330228851ecafe3265c8f51: bedroom
  - platform: mpd
    host: !secret host_ip

automation:
- alias: Receiver Volume
  trigger:
    platform: state
    entity_id: input_number.receiver_volume
  action:
    service: media_player.volume_set
    data_template:
      entity_id: media_player.receiver
      volume_level: '{{ states.input_number.receiver_volume.state | float }}'

- alias: Receiver Volume set
  trigger:
    platform: state
    entity_id: media_player.receiver
  action:
    - service: input_number.set_value
      data_template:
        entity_id: media_player.receiver
        value: "{{ state_attr('media_player.receiver', 'volume_level') | float }}"

- alias: Bedroom Volume
  trigger:
    platform: state
    entity_id: input_number.bedroom_volume
  action:
    service: rest_command.set_bedroom_volume

- alias: Bedroom Volume set
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.bedroom_volume
      value: '{{ trigger.to_state.state }}'

- alias: Bedroom Speaker On
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.bedroom_volume', 'selected') }}"
  action:
    - service: switch.turn_on
      entity_id: switch.bedroom_stereo

- alias: Bedroom Speaker Off
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.bedroom_volume', 'selected') == False }}"
  action:
    service: switch.turn_off
    entity_id: switch.bedroom_stereo

- alias: Office Volume
  trigger:
    platform: state
    entity_id: sensor.office_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.office_volume
      value: '{{ trigger.to_state.state }}'

- alias: Office Volume set
  trigger:
    platform: state
    entity_id: input_number.office_volume
  action:
    service: rest_command.set_office_volume

- alias: kitchen Volume
  trigger:
    platform: state
    entity_id: sensor.kitchen_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.kitchen_volume
      value: '{{ trigger.to_state.state }}'

- alias: kitchen Volume set
  trigger:
    platform: state
    entity_id: input_number.kitchen_volume
  action:
    service: rest_command.set_kitchen_volume

- alias: Living Room Speaker On
  trigger:
    platform: state
    entity_id: sensor.living_room_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.living_room_volume', 'selected') }}"
  action:
    - service: script.receiver_stream

sensor:
- platform: rest
  name: Bedroom Volume
  resource: !secret bedroom_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

- platform: rest
  name: Office Volume
  resource: !secret office_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

- platform: rest
  name: Living Room Volume
  resource: !secret living_room_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

rest_command:
  set_bedroom_volume:
    url: !secret bedroom_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.bedroom_volume.state|round }} }'
  set_office_volume:
    url: !secret office_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.office_volume.state|round }} }'
  set_kitchen_volume:
    url: !secret kitchen_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.kitchen_volume.state|round }} }'
  set_living_room_volume:
    url: !secret living_room_speaker_url
    method: PUT
    payload: '{"volume" : 100 }'

input_number:
  bedroom_volume:
    name: Bedroom Volume
    min: 0
    max: 100
    step: 1

  office_volume:
    name: Office Volume
    min: 0
    max: 100
    step: 1

  receiver_volume:
    name: Receiver
    min: 0
    max: 1
    step: 0.01

  kitchen_volume:
    name: Kitchen Volume
    min: 0
    max: 100
    step: 1

script:
  receiver_stream:
    alias: 'receiver stream'
    sequence:
      - service: media_player.turn_on
        data:
          entity_id: media_player.receiver
      - delay: 0:30
      - service: media_player.select_source
        data:
          entity_id: media_player.receiver
          source: 'Video 6'
      - service: rest_command.set_living_room_volume<commit_msg>fix receiver input<commit_after>media_player:
  - platform: onkyo
    host: !secret receiver_ip
    name: receiver
  - platform: spotify
    client_id: !secret spotify_client_id
    client_secret: !secret spotify_client_secret
    aliases:
      70f8bb9a8a5393ef080507a89e4b98d139000d65: home
      126a80ef484035c196dd9f39d0c1a2c9e869810c: receiver
      009e058c883c683e1330228851ecafe3265c8f51: bedroom
  - platform: mpd
    host: !secret host_ip

automation:
- alias: Receiver Volume
  trigger:
    platform: state
    entity_id: input_number.receiver_volume
  action:
    service: media_player.volume_set
    data_template:
      entity_id: media_player.receiver
      volume_level: '{{ states.input_number.receiver_volume.state | float }}'

- alias: Receiver Volume set
  trigger:
    platform: state
    entity_id: media_player.receiver
  action:
    - service: input_number.set_value
      data_template:
        entity_id: media_player.receiver
        value: "{{ state_attr('media_player.receiver', 'volume_level') | float }}"

- alias: Bedroom Volume
  trigger:
    platform: state
    entity_id: input_number.bedroom_volume
  action:
    service: rest_command.set_bedroom_volume

- alias: Bedroom Volume set
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.bedroom_volume
      value: '{{ trigger.to_state.state }}'

- alias: Bedroom Speaker On
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.bedroom_volume', 'selected') }}"
  action:
    - service: switch.turn_on
      entity_id: switch.bedroom_stereo

- alias: Bedroom Speaker Off
  trigger:
    platform: state
    entity_id: sensor.bedroom_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.bedroom_volume', 'selected') == False }}"
  action:
    service: switch.turn_off
    entity_id: switch.bedroom_stereo

- alias: Office Volume
  trigger:
    platform: state
    entity_id: sensor.office_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.office_volume
      value: '{{ trigger.to_state.state }}'

- alias: Office Volume set
  trigger:
    platform: state
    entity_id: input_number.office_volume
  action:
    service: rest_command.set_office_volume

- alias: kitchen Volume
  trigger:
    platform: state
    entity_id: sensor.kitchen_volume
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.kitchen_volume
      value: '{{ trigger.to_state.state }}'

- alias: kitchen Volume set
  trigger:
    platform: state
    entity_id: input_number.kitchen_volume
  action:
    service: rest_command.set_kitchen_volume

- alias: Living Room Speaker On
  trigger:
    platform: state
    entity_id: sensor.living_room_volume
  condition:
    - condition: template
      value_template: "{{ state_attr('sensor.living_room_volume', 'selected') }}"
  action:
    - service: script.receiver_stream

sensor:
- platform: rest
  name: Bedroom Volume
  resource: !secret bedroom_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

- platform: rest
  name: Office Volume
  resource: !secret office_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

- platform: rest
  name: Living Room Volume
  resource: !secret living_room_speaker_url
  method: GET
  json_attributes: ["id","name","selected","volume"]
  value_template: "{{ value_json.volume }}"
  scan_interval: 10

rest_command:
  set_bedroom_volume:
    url: !secret bedroom_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.bedroom_volume.state|round }} }'
  set_office_volume:
    url: !secret office_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.office_volume.state|round }} }'
  set_kitchen_volume:
    url: !secret kitchen_speaker_url
    method: PUT
    payload: '{"volume" : {{ states.input_number.kitchen_volume.state|round }} }'
  set_living_room_volume:
    url: !secret living_room_speaker_url
    method: PUT
    payload: '{"volume" : 100 }'

input_number:
  bedroom_volume:
    name: Bedroom Volume
    min: 0
    max: 100
    step: 1

  office_volume:
    name: Office Volume
    min: 0
    max: 100
    step: 1

  receiver_volume:
    name: Receiver
    min: 0
    max: 1
    step: 0.01

  kitchen_volume:
    name: Kitchen Volume
    min: 0
    max: 100
    step: 1

script:
  receiver_stream:
    alias: 'receiver stream'
    sequence:
      - service: media_player.turn_on
        data:
          entity_id: media_player.receiver
      - delay: 0:30
      - service: media_player.select_source
        data:
          entity_id: media_player.receiver
          source: 'video6'
      - service: rest_command.set_living_room_volume
{'fraction_non_alphanumeric': 0.09200633161851998, 'fraction_numerical': 0.023149980213692124, 'mean_word_length': 3.465106007067138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2955700', 'n_tokens_mistral': 3462, 'n_tokens_neox': 3288, 'n_words': 718}