Samsung Sleep Mode injecting next_alarm with com.sec.android.app.clockpackage – package filter no longer working

Hey everyone,

I want to automate my bathroom heating based on my actual wake-up alarm on my Samsung S25. Simple goal, but Samsung makes it surprisingly painful.

The problem:
Samsung Routines (Bixby Routines) injects its trigger times into the Android AlarmManager, which the HA Companion App picks up as next_alarm. This means every single Routine that has a time-based trigger pollutes the next_alarm sensor — including the Sleep Mode start time — making it completely unreliable for my use case.

The sensor currently shows the Sleep Mode start time, not my actual wake-up alarm. The Package attribute is com.sec.android.app.clockpackage for both the real alarm and the injected Routine times, so there’s no way to tell them apart.

What I tried:

I came across this thread where the suggested fix was a Template Helper filtering by package:

{% if is_state_attr('sensor.my_phone_next_alarm', 'Package', 'com.google.android.deskclock') %}
  {{ states('sensor.my_phone_next_alarm') }}
{% else %}
  unavailable
{% endif %}

This approach (and the Allow List setting in the Companion App) only works if you use Google Clock. Samsung Routines injects under com.sec.android.app.clockpackage — a different package than Google Clock — so in theory switching to Google Clock for alarms only should fix it, since the filter would then cleanly separate real alarms from Routine injections.

However, I heavily rely on Samsung Routines for time-based automations and don’t want to install a separate app just for alarms if avoidable. I also can’t confirm whether Samsung Routines would still bleed into next_alarm even if I switched to Google Clock, since I haven’t tested it.

My setup:

  • Samsung S25, One UI, Android 16
  • HA Companion App up to date
  • next_alarm Package: com.sec.android.app.clockpackage
  • Sensor reflects Sleep Mode start time, not actual alarm

Two questions for anyone who’s dealt with this:

  1. If you use Google Clock for alarms while keeping Samsung Routines active — does Samsung Routines still inject into next_alarm, or does the package filter cleanly solve it?
  2. Is there any solution that doesn’t require switching clock apps at all?

Any help appreciated!

Hey, wanted to share how I ended up solving this without switching clock apps.

The key insight: instead of filtering by package, I use the Local Time attribute of the sensor directly (which gives correct local time, unlike the UTC state) and filter by time window. My Sleep Mode routine starts at night, so anything outside 03:00-12:00 gets ignored - real morning alarms pass through, Routine injections don’t.

On top of that I added a last_triggered check so the automation only fires once per day even if the sensor updates multiple times.

The setup has three automations:

Automation 1 - Calculate preheat time:

alias: Preheat Time Calculate
triggers:
  - entity_id: sensor.YOUR_next_alarm
    trigger: state
conditions:
  - condition: template
    value_template: >
      {% set s = trigger.to_state.state %}
      {% if s in ['unknown', 'unavailable', 'none', ''] %}
        false
      {% else %}
        {% set local_str = trigger.to_state.attributes.get('Local Time', '') %}
        {% if local_str == '' %}
          false
        {% else %}
          {% set t = strptime(local_str, '%a %b %d %H:%M:%S GMT%z %Y') %}
          {% if not (3 <= t.hour <= 12) %}
            false
          {% else %}
            {% set last = this.attributes.get('last_triggered') %}
            {{ last == None or as_datetime(last).date() < now().date() }}
          {% endif %}
        {% endif %}
      {% endif %}
actions:
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.YOUR_preheat_datetime
    data:
      datetime: >
        {% set local_str = trigger.to_state.attributes.get('Local Time', '') %}
        {% set t = strptime(local_str, '%a %b %d %H:%M:%S GMT%z %Y') %}
        {{ (t - timedelta(minutes=10)).strftime('%Y-%m-%d %H:%M:%S') }}
mode: single

Automation 2 - Start heating:

alias: Start Heating
triggers:
  - at: input_datetime.YOUR_preheat_datetime
    trigger: time
conditions: []
actions:
  - action: input_boolean.turn_on
    target:
      entity_id: input_boolean.YOUR_heating_boolean
mode: single

Automation 3 - Timer and reset:

alias: Heating Reset
triggers:
  - trigger: state
    entity_id: input_boolean.YOUR_heating_boolean
    to: "on"
conditions: []
actions:
  - data:
      duration: >-
        {{ (states('input_number.YOUR_duration_minutes') | float(0) * 60) | int }}
    action: timer.start
    target:
      entity_id: timer.YOUR_timer
  - delay:
      minutes: "{{ states('input_number.YOUR_duration_minutes') | float(0) }}"
  - action: input_boolean.turn_off
    target:
      entity_id: input_boolean.YOUR_heating_boolean
mode: restart

Just replace the YOUR_ placeholders with your actual entity IDs. The time window (03:00-12:00) and the offset (10 minutes) can be adjusted to your needs.

Important caveat: This approach only works if all your Routine trigger times fall outside your defined time window. If you have Routines firing during the night or in the early morning hours before your actual wake-up time, those will still pollute the sensor and break this solution. In that case you need to narrow down the time window further to exclude those specific times as well. In my case Sleep Mode starts around 22:30 so there’s no overlap with the 03:00-12:00 window.

Happy to answer any questions!