Issue with Sonos Night mode

I don’t seem to be able to get night mode or speech enhance to activate. I don’t think this is an issue with the state being reflected in the app, as the audio doesn’t change when the settings are ran.

I’ve check the templates and they seem valid, I’ve also tried calling the service directly through the UI, I’m using HA 0.62.1

- alias: "Night toggles Sonos night mode"
  trigger:
    - platform: state
      entity_id: media_player.living_room_2
    - platform: time
      at: '22:00:00'
  action:
    service: media_player.sonos_set_option
    data_template:
      entity_id: media_player.living_room_2
      night_sound: >
        {% if (states.sensor.time.state > "22:00") or (states.sensor.time.state < "6:00") %}
          true
        {% else %}
          false
        {% endif %}
      speech_enhance: >
        {% if (states.sensor.time.state > "22:00") or (states.sensor.time.state < "6:00") %}
          true
        {% else %}
          false
        {% endif %}

Did you figure it out? I am also not able to change the night_sound or speech_enhance for my Playbase.

This works fine for me.

- platform: template
  switches:
    night_sound:
      friendly_name: "Night Sound"
      value_template: "{{ state_attr('media_player.livingroom', 'night_sound') }}"
      turn_on:
        service: media_player.sonos_set_option
        data:
          entity_id: media_player.livingroom
          night_sound: true
      turn_off:
        service: media_player.sonos_set_option
        data:
          entity_id: media_player.livingroom
          night_sound: false
    speech_enhance:
      friendly_name: "Speech Enhance"
      value_template: "{{ state_attr('media_player.livingroom', 'speech_enhance') }}"
      turn_on:
        service: media_player.sonos_set_option
        data:
          entity_id: media_player.livingroom
          speech_enhance: true
      turn_off:
        service: media_player.sonos_set_option
        data:
          entity_id: media_player.livingroom
          speech_enhance: false
5 Likes

This works great for me, thank you very much for this!