mad_announcement:
  alias: Der er mad
  sequence:
    - service: sonos.snapshot
      data:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse
        with_group: true
    - service: media_player.media_stop
      target:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse
    - service: scene.turn_on
      target:
        entity_id: scene.n22_spisetid
    - service: scene.turn_on
      target:
        entity_id: scene.stue_annes_favorit
    - choose:
        - conditions:
            - condition: state
              entity_id: person.claus_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_claus_iphone_15pro
              data:
                message: >-
                  {% set meal = states('sensor.dagens_aftensmad') %}
                  {% if meal and meal not in ['unknown','unavailable','Ingen planlagt'] %}
                    Der er mad! I dag: {{ meal }}
                  {% else %}
                    Der er mad!
                  {% endif %}
    - choose:
        - conditions:
            - condition: state
              entity_id: person.anne_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_annes_iphone_14_pro
              data:
                message: >-
                  {% set meal = states('sensor.dagens_aftensmad') %}
                  {% if meal and meal not in ['unknown','unavailable','Ingen planlagt'] %}
                    Der er mad! I dag: {{ meal }}
                  {% else %}
                    Der er mad!
                  {% endif %}
    - choose:
        - conditions:
            - condition: state
              entity_id: person.andreas_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_andreas_iphone_12
              data:
                message: >-
                  {% set meal = states('sensor.dagens_aftensmad') %}
                  {% if meal and meal not in ['unknown','unavailable','Ingen planlagt'] %}
                    Der er mad! I dag: {{ meal }}
                  {% else %}
                    Der er mad!
                  {% endif %}
    - choose:
        - conditions:
            - condition: state
              entity_id: person.daniel_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_daniels_iphone_13_mini
              data:
                message: >-
                  {% set meal = states('sensor.dagens_aftensmad') %}
                  {% if meal and meal not in ['unknown','unavailable','Ingen planlagt'] %}
                    Der er mad! I dag: {{ meal }}
                  {% else %}
                    Der er mad!
                  {% endif %}
    - service: media_player.volume_set
      target:
        entity_id:
          - media_player.alrum
          - media_player.kokken
          - media_player.andreas
          - media_player.daniel
          - media_player.sovevaerelse
          - media_player.badevaerelse
      data:
        volume_level: 0.3
    - service: tts.speak
      target:
        entity_id: tts.google_ai_tts
      data:
        media_player_entity_id:
          - media_player.alrum
          - media_player.kokken
          - media_player.andreas
          - media_player.daniel
          - media_player.sovevaerelse
          - media_player.badevaerelse
        message: >-
          {% set meal = states('sensor.dagens_aftensmad') %}
          {% if meal and meal not in ['unknown','unavailable','Ingen planlagt'] %}
            Der er mad! I dag spiser vi {{ meal }}
          {% else %}
            Der er mad!
          {% endif %}
    - delay: "00:00:10"
    - service: sonos.restore
      data:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse

tv_hygge_announcement:
  alias: TV hygge
  sequence:
    - service: sonos.snapshot
      data:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse
        with_group: true
    - service: media_player.media_stop
      target:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse
    - service: script.receiver_tv_mch_stereo
    - service: scene.turn_on
      target:
        entity_id: scene.n22_tv
    - service: scene.turn_on
      target:
        entity_id: scene.stue_annes_favorit
    - choose:
        - conditions:
            - condition: state
              entity_id: person.claus_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_claus_iphone_15pro
              data:
                message: Der er TV hygge
    - choose:
        - conditions:
            - condition: state
              entity_id: person.anne_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_annes_iphone_14_pro
              data:
                message: Der er TV hygge
    - choose:
        - conditions:
            - condition: state
              entity_id: person.andreas_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_andreas_iphone_12
              data:
                message: Der er TV hygge
    - choose:
        - conditions:
            - condition: state
              entity_id: person.daniel_schusler_dethlefsen
              state: home
          sequence:
            - service: notify.mobile_app_daniels_iphone_13_mini
              data:
                message: Der er TV hygge
    - service: media_player.volume_set
      target:
        entity_id:
          - media_player.alrum
          - media_player.kokken
          - media_player.andreas
          - media_player.daniel
          - media_player.sovevaerelse
          - media_player.badevaerelse
      data:
        volume_level: 0.3
    - service: tts.speak
      target:
        entity_id: tts.google_ai_tts
      data:
        media_player_entity_id:
          - media_player.alrum
          - media_player.kokken
          - media_player.andreas
          - media_player.daniel
          - media_player.sovevaerelse
          - media_player.badevaerelse
        message: Der er TV hygge
    - delay: "00:00:10"
    - service: sonos.restore
      data:
        entity_id:
          - media_player.stue
          - media_player.andreas
          - media_player.daniel
          - media_player.kokken
          - media_player.alrum
          - media_player.badevaerelse
          - media_player.sovevaerelse
          - media_player.lille_badevaerelse