script:
  routine_good_night:
    alias: Routine · Going to sleep
    sequence:
      - service: media_player.media_stop
        entity_id: group.all_sonos

      # Use say_discretely instead of talk, because night mode is already on.
      - service: script.say_discretely
        data:
          message: "Entering night mode. Good night!"

      - service: script.bed_led_on
        data:
          brightness_pct: 40
      - service: light.turn_on
        entity_id: light.bed_led
        data:
          brightness_pct: 40
      - service: fan.turn_on
        entity_id: fan.philips_airpurifier
      - service: input_select.select_option
        entity_id: input_select.purifier_preset_mode
        data:
          option: "sleep"
      - service: homeassistant.turn_off
        entity_id:
          - light.living_room
          - light.master_bedroom
          - light.kitchen
          - light.hallway
          - media_player.nvidia_shield
          - media_player.living_room_tv
          - switch.titanium
          - group.all_radiators
      - service: script.dashboards_light_down
