# data:
#  volumennat  (fx 0.5 om natten og 0.8 om dagen)
#  volumendag  (fx 0.5 om natten og 0.8 om dagen)
#  lydfil   (fx doorbell-shortened-100308.mp3)
#  lampe    (fx light.pendle1 og light.raket
#  tekst    (Det ringer på bagdøren)

doorbell:
  alias: Dørklokke
  sequence:
    - parallel:
      - sequence:
        - choose:
          - conditions:
            - condition: time
              after: '20:00:00'
              before: '06:00:00'
            sequence:
            - service: media_player.volume_set
              data:
                volume_level: "{{ volumennat }}"
              target:
                entity_id: media_player.lille_badevaerelse
            - service: media_player.play_media
              target:
                entity_id: media_player.lille_badevaerelse
              data:
                media_content_id: media-source://media_source/local/doorbell-shortened-100308.mp3
                media_content_type: audio/mpeg
              metadata:
                title: doorbell-shortened-100308.mp3
                thumbnail:
                media_class: music
                children_media_class:
                navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://media_source
          default:
          - service: media_player.volume_set
            data:
              volume_level: "{{ volumendag }}"
            target:
              entity_id: media_player.lille_badevaerelse
          - service: media_player.play_media
            target:
              entity_id: media_player.lille_badevaerelse
            data:
              media_content_id: media-source://media_source/local/doorbell.mp3
              media_content_type: audio/mpeg
            metadata:
              title: doorbell.mp3
              thumbnail:
              media_class: music
              children_media_class:
              navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://media_source
      - sequence:
        - service: media_player.volume_set
          data:
            volume_level: "{{ volumendag }}"
          target:
            entity_id: media_player.andreas
        - service: media_player.play_media
          target:
            entity_id: media_player.andreas
          data:
            media_content_id: media-source://media_source/local/doorbell.mp3
            media_content_type: audio/mpeg
          metadata:
            title: doorbell.mp3
            thumbnail:
            media_class: music
            children_media_class:
            navigateIds:
            - {}
            - media_content_type: app
              media_content_id: media-source://media_source
      - sequence:
        - service: media_player.volume_set
          data:
            volume_level: "{{ volumendag }}"
          target:
            entity_id: media_player.daniel
        - service: media_player.play_media
          target:
            entity_id: media_player.daniel
          data:
            media_content_id: media-source://media_source/local/doorbell.mp3
            media_content_type: audio/mpeg
          metadata:
            title: doorbell.mp3
            thumbnail:
            media_class: music
            children_media_class:
            navigateIds:
            - {}
            - media_content_type: app
              media_content_id: media-source://media_source
      - sequence:
        - service: tts.speak
          target:
            entity_id: tts.google_ai_tts
          data:
            media_player_entity_id: media_player.alrum
            message: "Der er nogen der ringer på bagdøren"
      - sequence:
        - service: notify.mobile_app_claus_iphone_15pro
          data:
            message: '{{ tekst }}'
        - service: notify.mobile_app_annes_iphone_14_pro
          data:
            message: '{{ tekst }}'
      - sequence:
        - service: scene.create
          data:
            scene_id: before
            snapshot_entities:
            - light.pendle1
        - service: light.turn_on
          data:
            entity_id: light.pendle1
            brightness: 255
            rgb_color: [255, 0, 0]
            flash: long
        - delay: 2
        - service: scene.turn_on
          entity_id: scene.before
    - service: media_player.volume_set
      data:
        volume_level: "{{ volumennat }}"
      target:
        entity_id: media_player.lille_badevaerelse
    - service: media_player.volume_set
      data:
        volume_level: "{{ volumennat }}"
      target:
        entity_id: media_player.daniel
    - service: media_player.volume_set
      data:
        volume_level: "{{ volumennat }}"
      target:
        entity_id: media_player.andreas
    - service: media_player.select_source
      data:
        entity_id: media_player.denon_avr_x2300w
        source: TV Audio
