Time sensor automation occasionally not triggering

Hello,

I have occasional problems with my cover automation. It is supposed to roll up at the time of my alarm sensor from my phone.

I created an extra automation that logs the current sensor value at 8am. Today it logged 6:15 (8:15, UTC+2):

So this way I know the phone sends correct data to HA.

Next, my alarm rung and 8:15 of local time and the cover did not go up. This happens once a week on average.
I looked at the automation trace and there was no trigger for today morning, only my evening alarm. You can even see 10-minute snoozes on 22nd triggered correctly:

I have ruled out TZ issue as this works most days.

What next steps should I take in debugging this issue?

So our problem is, if you think this is acting up, how can we help if we can’t see the code? It would help if you could to provide some code so we can see what you’ve done so far…
How to help us help you - or How to ask a good question.

@zeratul021: Post your automation as YAML code by use of the three dots in the top right corner. Otherwise it is not possible to help you.

@Sir_Goodenough , @LutzDe
Sorry guys, my bad. I thought I attached it in the original post.
Here are the YAMLs for cover (second target, enabled, position 70):

alias: Bedroom open shutters with alarm
description: ""
triggers:
  - at: sensor.sm_s926b_next_alarm
    trigger: time
conditions: []
actions:
  - target:
      entity_id:
        - cover.guest_room
    data:
      tilt_position: 50
    enabled: false
    action: cover.set_cover_tilt_position
  - target:
      device_id: b0e4e6b223198b8fedc5ee3101cef9ac
    data:
      position: 70
    action: cover.set_cover_position
mode: single

and for logging the sensor time sent from my HA companion app:

alias: Log alarm time
description: ""
triggers:
  - trigger: time
    at: "08:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
conditions: []
actions:
  - action: system_log.write
    metadata: {}
    data:
      level: info
      message: "Alarm sensor state: {{states('sensor.sm_s926b_next_alarm')}}"
  - action: system_log.write
    metadata: {}
    data:
      level: info
      message: "Alarm sensor state2: {{states.sensor.sm_s926b_next_alarm.state}}"
mode: single

FYI both were generated by HA (setup via HA GUI).
I have latest version of HAOS.

Share the history of sensor.sm_s926b_next_alarm during that time. That would be the only reason it doesn’t trigger.

@petro Thanks for the idea. I think this shows a problem. And my hypotheses this is a concurrency issue:

  1. Sensor value is set to 8:15 at 3:14am on 23rd
  2. At 8:15 alarm rings and HA should execute the automation
  • This does not happen because phone updates the sensor value at 8:14:59.56 to the next alarm at 18:10, probably due to current alarm starting and thus becoming obsolete
  1. After 18 seconds of ringing, I snooze the alarm and the sensor value is updated to 8:25 (+10min snooze)
  2. After 10 minutes I kill snoozed alarm and the sensor value is updated to the next evening alarm 18:10
  • the 144ms premature setting happens here as well, that is why the snoozed alarm did not raise the cover too
  1. Evening alarm at 18:10 sets the sensor value to 8:15 correctly, this time 456ms after the alarm time

I will think about some workaround, but I think the reporting from interface between companion app and phone should never update time sensors early, possibly introduce some minor delay.

Just add a 15 second offset to the time trigger

There is a long history of Samsung phones not working well with the next_alarm sensor.

@petro I can try a negative offset. I imagine positive offset would suffer the same fate.
@Didgeridrew true - I hit that earlier this year and fixed it quickly by clearing “Routines” storage thanks to this gentleman’s comment.
This was however obviously a phone issue as the new alarm values were not visible in the companion app.

Quick confirmation.
I have set -5 second offset 3 weeks ago and I haven’t noticed a single missed automation since then.