Adjustable Wake-up to Android alarm

Hello All.

After update to Google alarm App (7.10 (685617841)) yesterday my automations based on this blueprint no longer triggers the intender funktions, i had this problem on android 13 but on android 14 it have been rock solid the last year.
it seems when i look at automation traces that it “chooses” option 1 or 2 But “my” actions is run on option 3 but there is no “choose” options 1 or 2 in the blueprint.
so i think that it maybe some “internal” functions of the blueprint

any help is apricated

Hi @Stephan0815, sorry for the late reply.
under conditions, add Entity and then state, you can try with a schedule helper
Open your Home Assistant instance and show your helper entities. or calendar entity. And it’s state.

hi @martinelv, I just checked my Google alarm version, i am on the exact same version as you are and I even created a new alarm which worked just fine. Things you can check

  • Is your entity helper input_datetime.xxxxx updated? If not check if the sensor in the HA app is enabled
  • Check if your actions run on it’s on, test them in another automation

I noticed one thing, which I need to monitor. That when the alarm has run, it hasn’t update to the next day. But I am not sure when this actually happens. That’s a thing the alarm app does and the home assistant app then updates. Let me montitor this the next few days.

Hi @op00
Thanks for the fast reply.

I rebooted my phone after and also checked the companion app and enabled and disabled some other app in the allowed list.

i made a copy of the my automation with the blueprint and changed the actions to something “testable” and also changed it to the “newish” feature “Take control”

and made a lot of tests last night and discoveret that the automations “both” original and copy also triggers when is change an alarm on the phone i did not know that.

Most of the times Both automations triggered but some times the original with the blueprint didn’t update the last time “run time” when but looking in the traces the both triggede.
but it worked this morning so i will monitor it the followings days and keep you updated
Thanks.

1 Like

Hi @op00

I have now “monitored” the automation for sometime and in the last about 17 days it have failed me 4 times since google released the update to the “alarm app”
every time it fails the automation trace is saying that the automation takes “option1” but it seems that “option1” is something in the blueprint and not my “actions”
it failed these times
1= 31 okt
2= 4 Nov
3= 6 Nov
4= 10 Nov
but it seems random so i have not been able to find the root course other than
the google app update. and before i updated to android 14 i was the same “instability”
but after upgrading to android 14 and before the new google time update it was rock solid.

hope this info is useful

Thanks
/Martin



Hi @martinelv,
when you take control of the blueprints,
image

Then you would see that

option1 is (right star)
When:

  • When alarm changes state or any attributes (except unavailable or unknown)

Then:

  • Set the date time helper to the new time - offset

option2 is: (right star)
When:

  • When alarm changes state to unavailable or unknown

Then:

  • Set the date time helper to 1970-01-01 00:00:00

option3 is: (left star)
When:

  • When current time equals the date time helper

Conditions:

  • your conditions
    Then:
    • your actions

So, these are essentially to 2 modes of this blueprint / automation.

  1. Setting the datetime helper (offset corrected)
    1.1 Error handle [“unknown”,“unavailable”]
  2. Run your configured actions and conditions, when datetime equals helper datetime

In your case (3 Screenshots, the alarm sensor from the app changed and it set a new time). So these are no fails.

  • at 5.30 am 31. Okt it set the alarm to 9.00 am 2. Nov
  • at 5.30 am 31. Okt it set the alarm to 5.30 am 2. Nov (this is weird, i guess your alarm should be 9am)
  • at 5.30 am 4. Nov it set the alarm to 8.59 am 9. Nov

Do you maybe have any conditions configured?

Hi @op00

Then i have mostly figured out how the blueprint works,
the year 1970 now makes more sense… thanks for the detailed explanation.
you are correct in that i have some conditions for the “3” option.

here is the whole automation

 offset: 2
mode: single
triggers:
  - platform: time
    at: input_datetime.mae_mobil_vaeggeur
    id: wake_up
  - platform: state
    entity_id:
      - sensor.mae_zenfone_9_next_alarm
    id: helper_update
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: helper_update
          - condition: template
            value_template: '{{ trigger.to_state.state not in ["unknown","unavailable"] }}'
        sequence:
          - data:
              timestamp: '{{ (as_timestamp(trigger.to_state.state) |int ) - (offset)}}'
            target:
              entity_id: input_datetime.mae_mobil_vaeggeur
            action: input_datetime.set_datetime
      - conditions:
          - condition: trigger
            id: helper_update
          - condition: template
            value_template: '{{ trigger.to_state.state in ["unknown","unavailable"] }}'
        sequence:
          - data:
              datetime: '1970-01-01 00:00:00'
            target:
              entity_id: input_datetime.mae_mobil_vaeggeur
            action: input_datetime.set_datetime
      - conditions:
          - condition: trigger
            id: wake_up
          - condition: and
            conditions:
              - condition: zone
                entity_id: person.martin
                zone: zone.home
        sequence:
          - choose:
              - conditions:
                  - condition: time
                    after: '03:55:00'
                    before: '07:29:00'
                    weekday:
                      - mon
                      - tue
                      - wed
                      - thu
                      - fri
                sequence:
                  - delay:
                      hours: 0
                      minutes: 0
                      seconds: 2
                      milliseconds: 0
                  - data: {}
                    action: script.godmorgen_pa_170
              - conditions:
                  - condition: time
                    after: '07:30:00'
                    before: '09:30:00'
                    weekday:
                      - sat
                      - sun
                sequence:
                  - delay:
                      hours: 0
                      minutes: 0
                      seconds: 2
                      milliseconds: 0
                  - data: {}
                    action: script.godmorgen_pa_170
          - action: script.tander_shelly_dimmer_i_10_min
            metadata: {}
            data: {}
    default: []
id: '1692554426072'
alias: Martins Mobil Android Vægge ur
description:

when i look in the logs of the Time Helper
it seems that google time is updating the helper to both my workday and weekend wake up time inside the same second even on work days when the next logical would be next workday and maybe that is making trouble.

i on purpose have the automation run with an offset of 2 sec and the delayed my actions to try to have “option 3” running before the the helper is updated but my “logic” behind this seem to not work either.

but my companion app it set to only allow google desktop clock app… “aka time”

but i have recently tested an app to disable android Doze and that app used the “alarm manager api” in android and when that app was running the “time helper” was updated every minute even when it was not selected in the companien app…
i do not know if this maybe an issue also

Thanks
/Martin


:tada::tada: V3 released, next version should be reimportable.

Thanks for sharing your work! What’s the best way to upgrade our existing automation? Create a new automation based on the v3?

It should be as simple as just import it via the “import blueprint” link from the first post. It would prompt you to override. Reload “Automation” from the dev tools or restart home assistant should update the created automation.

I forgot to add the source_url in the V2 Version or that was not a feature then. So from V3 onwards it can be done from the blueprint section in HA “re-import blueprint”.

1 Like

The ability to listen only for an alarm from a specific app, already exists, although it’s a bit clunky.

When enabling the alarm sensor in the HA app, just click on “Whitelist” at the bottom and choose the app(s) to listen for. Unfortunately it lists every app installed on your phone (including system apps) with no filter, so there’s a lot to go through.

1 Like

You can use the workday integration for the automations.

In the meantime I created a manual automation.
Used the Hacs m365 calender Integration.
Filter the automation for german holiday, vacation and weekends.
That’s working fine. But thanks for your reply

Hi
I’m testing your Blueprint at the moment to switch on light and digital radio in the morning etc.
I do like it but I’m running into an issue which I cannot solve. The automation runs fine in the morning but it also starts additionally running at midnight which is quite annoying. So there seems to be an event fired at 00:00:00 - possibly from my date&time helper? Any idea what goes wrong here?
Many thanks for helping a newbie. :wink:
Best regards,
Achim

Have you checked the history of your “Phone Next alarm” entity? Is it equal to 00:00:00 sometimes?

If so, did you correctly set the “Allow List” setting of your “Next alarm” sensor in HA > Settings > Companion App?

1 Like

Hi - I’ve checked it (twice now). There is no next alarm set to 00:00.00. The last time the “motorola edge 40 neo Next alarm” changed is a couple of days ago when I tested the automation. The state now is “became unavailable”.
Please see settings of the companion app as well in next message.
Thanks for your support.

Hey, @freekruemel
I am working on V4, which should less complex and not need a helper at all. Let me know if you want to test it?

I don’t quite understand why it runs the actions at midnight in your case. may you share a screenshots of the log book (with the next alarm and helper entity) and the automation trace at midnight.

Yet, I think V4 should fix that too.

I prematurely clicked save on the post, so i guess :slight_smile:

:tada: V4 released

Thanks for the update. I’m about to test V4 and will let you know the results. I do think it is (was) related to the date&time helper.