script:
  routine_bedtime:
    alias: Routine · Bedtime
    sequence:
      - service: script.say_discretely
        data:
          message: "Entering bed time."

      # Set master bedroom state
      - 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: light.turn_on
        entity_id: light.bedside
      - service: script.bed_led_on

      - service: light.turn_off
        entity_id: light.master_bedroom_main
      - service: sonos.unjoin
        entity_id:
          - media_player.living_room
          - media_player.kitchen
          - media_player.bathroom
      - service: media_player.volume_set
        entity_id: media_player.master_bedroom
        data:
          volume_level: 0.15

      # Turn off everything else
      - service: media_player.media_stop
        entity_id:
          - media_player.living_room
          - media_player.kitchen
          - media_player.bathroom
      - service: homeassistant.turn_off
        entity_id:
          - media_player.nvidia_shield
          - media_player.living_room_tv
          - light.master_bedroom_main
          - light.living_room_ceiling
          - light.kitchen_main
          - light.kitchen_secondary
          - light.hallway_main
          - light.hallway_entrance
          - switch.titanium
      - service: light.turn_on
        entity_id:
          - light.browser_kitchen
          - light.browser_hallway
        data:
          brightness_pct: 1
