Alarmclock sunrise with music and summary with open ia

Hi all,

I created an alarmclock with use of different scrips and 1 automation.
As i’am still a beginner and trying to learn I was thinking maybe some one can take a look help me streamline it a bit more or help me to make it more reliable.

alias: Wekker Met Muziek En Overzicht Van De Dag
description: ""
trigger:
  - platform: time
    at: input_datetime.wekker
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.bed_bezet_deur
        state: "on"
      - condition: state
        entity_id: binary_sensor.bed_bezet_kast
        state: "on"
    enabled: true
  - condition: or
    conditions:
      - condition: state
        entity_id: input_boolean.weekend_wekker
        state: "on"
      - condition: state
        entity_id: input_boolean.vakantie_wekker
        state: "on"
      - condition: state
        entity_id: binary_sensor.werkdagen
        state: "on"
    enabled: true
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id:
        - switch.adaptive_lighting_slaapkamer_verlichting
        - switch.adaptive_lighting_sleep_mode_slaapkamer_verlichting
        - switch.adaptive_lighting_adapt_color_slaapkamer_verlichting
        - switch.adaptive_lighting_adapt_brightness_slaapkamer_verlichting
  - service: media_player.volume_set
    data:
      volume_level: 0
    target:
      entity_id: media_player.slaapkamer_apple_homepod_mini
    enabled: true
  - service: media_player.play_media
    target:
      entity_id: media_player.slaapkamer_apple_homepod_mini
    data:
      media_content_id: >-
        media-source://media_source/local/Muziek/Sounds Of Nature - Amazon
        Rainforest - Anton Hughes.mp3
      media_content_type: audio/mpeg
    metadata:
      title: Sounds Of Nature - Amazon Rainforest - Anton Hughes.mp3
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
        - media_content_type: ""
          media_content_id: media-source://media_source/local/Muziek
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - parallel:
      - service: script.1688551121988
        data:
          lampBrightnessScale: zeroToOneHundred
          easingTypeInput: auto
          endBrightnessPercent: 42
          endBrightnessEntityScale: zeroToOneHundred
          minimumStepDelayInMilliseconds: 120
          isDebugMode: false
          light: light.slaapkamer_verlichting
          transitionTime:
            hours: 0
            minutes: 20
            seconds: 0
          autoCancelThreshold: 10
      - service: script.wakker_met_muziek
        data:
          target_volume: 0.36
          curve: logarithmic
          target_player: media_player.slaapkamer_apple_homepod_mini
          duration: 1200
        enabled: true
  - delay:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
  - service: switch.turn_on
    data: {}
    target:
      entity_id:
        - switch.adaptive_lighting_slaapkamer_verlichting
        - switch.adaptive_lighting_adapt_color_slaapkamer_verlichting
        - switch.adaptive_lighting_sleep_mode_slaapkamer_verlichting
        - switch.adaptive_lighting_adapt_brightness_slaapkamer_verlichting
  - service: automation.trigger
    data:
      skip_condition: true
    target:
      entity_id: automation.new_automation1
mode: queued
max: 10


Hopefully somebody can share some tips and tricks, now it happens sometime that the light won’t come on or the music wordt start with the morning announcement

the first script : Ashley’s Light Fader

 - service: script.1688551121988
        data:
          lampBrightnessScale: zeroToOneHundred
          easingTypeInput: auto
          endBrightnessPercent: 42
          endBrightnessEntityScale: zeroToOneHundred
          minimumStepDelayInMilliseconds: 120
          isDebugMode: false
          light: light.slaapkamer_verlichting
          transitionTime:
            hours: 0
            minutes: 20
            seconds: 0
          autoCancelThreshold: 10

the second script:

alias: Wakker Worden Met Muziek
mode: restart
fields:
  target_player:
    name: Target media player
    description: Target media player of volume fade.
    required: true
    example: media_player.slaapkamer_apple_tv
    selector:
      entity:
        domain: media_player
  target_volume:
    name: Target volume
    description: Volume the media play will be at the end of the fade duration.
    required: true
    default: 0.4
    example: "0.5"
    selector:
      number:
        max: 1
        min: 0
        step: 0.01
        mode: slider
  duration:
    name: Fade duration
    description: Length of time in seconds the fade should take.
    required: true
    default: 20
    example: "5"
    selector:
      number:
        mode: box
        min: 0
        max: 100000
        unit_of_measurement: s
  curve:
    name: Fade curve algorithm
    description: Shape of the fade curve to apply.
    required: true
    default: logarithmic
    example: logarithmic
    selector:
      select:
        options:
          - logarithmic
          - bezier
          - linear
variables:
  steps_per_second: 10
  total_steps: "{{ (steps_per_second * duration) | int(0) }}"
  start_volume: "{{ state_attr(target_player, 'volume_level') | float(0) }}"
  start_diff: "{{ (target_volume - start_volume) | float(0) }}"
sequence:
  - repeat:
      while:
        - condition: template
          value_template: "{{ repeat.index < total_steps }}"
        - condition: template
          value_template: >-
            {{ ((state_attr(target_player, "volume_level") - target_volume) |
            abs) > 0.001 }}
      sequence:
        - service: media_player.volume_set
          data_template:
            entity_id: "{{ target_player }}"
            volume_level: >
              {% set t = repeat.index / total_steps %} {% if curve ==
              'logarithmic' %}
                {{ (start_volume + (t / (1 + (1 - t))) * start_diff) | float(0) }}
              {% elif curve == 'bezier' %}
                {{ (start_volume + (t * t * (3 - 2 * t)) * start_diff) | float(0) }}
              {% else %}
                {{ (start_volume + t * start_diff) | float(0) }}
              {% endif %}
        - delay: "00:00:00.5"
  - service: media_player.volume_set
    data_template:
      entity_id: "{{ target_player }}"
      volume_level: "{{ target_volume }}"
icon: mdi:tune-vertical

Last automation that is triggered at the end.
this is a modified automation from Allen’s notify-agent-agenda.

name: Conversation agent agenda notification

description: Conversation agent generates a notification based on the upcoming calendar

agenda, location, and weather.

author: allenporter

domain: automation

input:

notify_time:

name: Notification time

description: Time the automation is triggered to send the notification.

selector:

time: {}

default: 07:00:00

notify_service:

name: Notify service name

description: The name of the notify service where the notification should be

sent.

selector:

text: {}

default: tts.cloud_say

calendar_entity:

name: Calendar

description: The calendar entity to use for finding upcoming calendar events.

selector:

entity:

multiple: false

filter:

- domain:

- calendar

calendar_duration:

name: Calendar event duration

description: How many hours ahead to look for upcoming calendar events.

selector:

duration: {}

default:

hours: 18

weather_entity:

name: Weather entity

description: The weather entity to use for upcoming weather forecast.

selector:

entity:

multiple: false

filter:

- domain:

- weather

zone_entity:

name: Home zone entity

description: The zone entity to use to determine approximate location for understanding

typical weather.

selector:

entity:

multiple: false

filter:

- domain:

- zone

conversation_agent:

name: Conversation agent

description: 'The conversation agent to use for generating the notification

text.

This should be a OpenAI conversation agent for this Blueprint to work.'

selector:

conversation_agent: {}

prompt:

name: Conversation agent prompt

selector:

text:

multiline: true

type: text

default: "Please generate text for a notification that will be sent to the users\nsmartphone

with helpful information.\n\nYou are a helpful personal agent that generates

text for the user:\n- Your answers are helpful, friendly, warm, insightful.\n-

Your answers are not technical, and do not include Home Assistant internal

details such as entities in responses.\n- Your messages help the user prepare

for their day, for example:\n - Making note of unusual weather for the location

and time of year (but not mundane details like \"0% chance of precipitation\")\n

\ - How much time remaining until their first meeting\n - Anything that may

be special or unique, such as celebrating a birthday"

source_url: https://www.home-assistant.io/blueprints/blog/2023-07/notify_agent_agenda.yaml

trigger:

platform: time

at: !input notify_time

action:

- variables:

weather_entity: !input weather_entity

calendar_entity: !input calendar_entity

zone_entity: !input zone_entity

calendar_duration: !input calendar_duration

prompt: !input prompt

- alias: Fetch Calendar Agenda

service: calendar.list_events

data:

duration: !input calendar_duration

target:

entity_id: !input calendar_entity

response_variable: agenda

- alias: Conversation Agent Notification Text

service: conversation.process

data:

text: "Time: {{ now() }}\n{%- if zone_entity is defined %}\nLatitude: {{ state_attr(zone_entity,

'latitude') | round(1) }}\nLongitude: {{ state_attr(zone_entity, 'longitude')

| round(1) }}\n{% endif %}\n\n{%- if weather_entity is defined %}\n{%- set forecast

= state_attr(weather_entity, 'forecast')[0] %}\n{%- set temperature_unit = state_attr(weather_entity,

'temperature_unit') -%}\nWeather: {{ forecast.condition }} ({{ forecast.temperature

}}{{ temperature_unit }}, {{ forecast.precipitation }}% precipitation)\n{%-

endif %}\n\nCalendar \"{{ state_attr(calendar_entity, 'friendly_name') }}\"

events for the next {{ calendar_duration.hours }}:\n{%- if agenda.events %}\n

\ {%- for event in agenda.events %}\n - Summary: {{ event.summary }}\n Start-End:

{% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All

Day{% endif %}\n {%- if event.descripton is defined %}\n Descripton: {{

event.descripton }}\n {% endif -%}\n {%- if event.location is defined

%}\n Location: {{ event.location }}\n {% endif -%}\n {%- endfor %}\n{%-

else %}\n - No upcoming events.\n{%- endif %}\n\n{{ prompt }}"

agent_id: !input conversation_agent

response_variable: agent

- alias: Send notification

service: !input notify_service

data:

entity_id: media_player.slaapkamer_apple_homepod_mini

message: '{{ agent.response.speech.plain.speech }}'