An alarm clock adjusting to Magister iCAL calendar

Is it also possible to get only the time ,so without the date and the +01:00

Hi Frank, Iā€™m assuming you are asking this because you want to show something pretty on your dashboard. My take on this:

image

For the ā€œMorgen 06:50ā€ string, I use this template sensor called sensor.moment_nextup_lesson_magister (to add to your dashboard):

template:
  - trigger:
      - platform: state
        entity_id: sensor.date
      - platform: state
        entity_id: sensor.nextup_lesson_magister
      - platform: state
        entity_id: input_number.magister_offset
    sensor:
    - name: Moment nextup lesson Magister
      unique_id: moment_nextup_lesson_magister
      state: >-
        {% set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
        {% set event = states('sensor.nextup_lesson_magister') | as_timestamp(default=0) %}
        {% set delta = ((event - midnight) / 86400) | int %}
        {% if is_state('sensor.nextup_lesson_magister','') %} Onbekend
        {% elif delta < 0 %} Onbekend
        {% elif delta == 0 %} Vandaag {{ (states('sensor.nextup_lesson_magister')|as_timestamp(default=0) - (states('input_number.magister_offset')|int(default=90) * 60)) |timestamp_custom('%H:%M', true)}}
        {% elif delta == 1 %} Morgen {{ (states('sensor.nextup_lesson_magister')|as_timestamp(default=0) -(states('input_number.magister_offset')|int(default=90) * 60)) |timestamp_custom('%H:%M', true)}}
        {% else %} Over {{ delta }} dagen {{ (states('sensor.nextup_lesson_magister')|as_timestamp(default=0) - (states('input_number.magister_offset')|int(default=90) * 60)) |timestamp_custom('%H:%M', true)}}
        {% endif %}

For your specific question, the template is shown in the last line, check the timestamp_custom.

ok thanks
even in het nederlands maar klopt het als ik dit allemaal opnieuw in mijn template.yaml zet dat ik dan ook even moet wachten voordat ik ook werkelijk de tijden zie? natuurlijk heb ik wel mijn yaml geherladen

If you copy exactly my yaml, you can trigger an update by changing the offset.

ok thanks
i have now seen what was going wrong , the ical intergration name the sensors ical_ical_magister, so i have change that and now its is working
thanks

I have clicked on each and every link within the Magister web app, but I canā€™t find any iCal link. I guess that means calendar sharing is disabled by the school?

Hoi Bart ,
Bij je onder je eigen naam ingelogd of 1 van je kinderen want je moet bij het account kijken van wie magister is anders zie je het kopje agenda delen niet

Aha, ik was als mezelf ingelogdā€¦

I love this with two kids who can never get out of bed :slight_smile:
Iā€™m stuck at triggering the alarm. The automations runs on the right time but never gets past the second condition.
What am i doing wrong?

Hello @efraim, there seems to be nothing wrong with the template. I think you should check out the different elements of the template in Developer Tools > Templates. Copy and paste this and check if it produces expected values:

{{ sensor.nextup_lesson_magister_pien }}
{{ input_number.magister_offset_pien }}
{{ sensor.date }}

One thing that comes to mind: do you have the Time & Date integration configured?