Samsung sleep mode and next alarm

When accessing the next alarm sensor on a Samsung device that has enabled the sleep mode schema, the companion app picks the sleep mode start time rather than the actual clock alarm.

Anyone also having this problem?

1 Like

Anyone who uses a Samsung app with the next alarm sensor will have the issue. Samsung apps are known to misbehave here .

It was not a problem until one of the family members discovered the sleep mode ā€œfeatureā€ recently.
Poor design not to use a separate counter for the sleep mode and re-use the alarm counter :frowning:

This time I could mitigate with a time condition in the automation and thereby ignore the sleep mode next_alarm start time.

yea samsung and xiaomi apps are particularly bad about this, some of their apps even set alarms for the calendar.

1 Like

My long term solution has been to check the source of the alarm, and use that in a template sensor
sensor.erikas_mobil_next_alarm is the HA Companion sensor used as an input

% if is_state_attr(ā€˜sensor.erikas_mobil_next_alarmā€™,ā€˜Packageā€™,ā€˜com.google.android.deskclockā€™) %}

1 Like

Hi,
as I am a newbie to home assisstant, I actually donā€™t get, what you didā€¦ I have a Samsung S21 FE and use the sleep mode every day, but not the alarm. So how do I check the source of the alarm and create a specific own sensor for it, just like your sensor.erikas, I would like to have a sensor.basti :slight_smile:

The trick is to identify the android alarm package, this can be found by looking up the companion app sensor in the Developer Tool > States, example below from two different Samsung devices

The companion app reports whatever current alarm package that is valid for the next alarm, once you know what is the correct one for your device you can use that in a template helper, Settings > Devices > Helpers > Template

{% set source=0 %}
{% set larmtid2=states('input_datetime.erika_rullgardin_senaste_tid')|today_at %}
{% if is_state_attr('sensor.erikas_mobil_next_alarm','Package','com.google.android.deskclock')  %}
{% set larmtid1=states('sensor.erikas_mobil_next_alarm') %}
{% set source=1 %}
{%- else -%}
{% set source=2 %}
{%- endif %}
{% if source==1 %}
{% if as_timestamp(larmtid1) > as_timestamp(larmtid2) %}
{% set larmtid=larmtid2 %}
{%- else -%}
{% set larmtid=larmtid1 %}
{%- endif %}
{%- else -%}
{% set larmtid=larmtid2 %}
{%- endif %}
{{ larmtid }}
1 Like

Hi, whatā€™s package on tour companion check you to work well ?

Samsung seems to use different package names, might be related to releases of Android, so you have to set an alarm time on you device and check the Next alarm sensor in developer tool.