Get specific alarm times from Google Nest

Hello everyone,

I bought a Google Nest Hub (2nd gen.) to realise a simple light alarm clock. I would like to send the alarm times (there are different ones) to HomeAssistant so that I can use them to build a light alarm clock.
I also get the following variables via the integration leikoilja/ha-google-home:

I would now like to react differently to specific alarm clocks. With the command

{{ states.sensor.bedroom_alarms.attributes.alarms[0].local_time }}

I get the alarm clocks addressed temporarily. But unfortunately the order of the alarms in the Nest Hub is constantly changing. I would therefore like to reference the ‘alarm_id’. I just don’t know how.

Can you help me with this?

Doesn’t the alarm_id change?

Which one is it you want to retrieve? The one closest in time?

What I am trying to achieve is the following:

I want to use the Blueprint ‘Wake-up light alarm with sunrise effect’. However, this requires a timestamp as input. I would now like to generate this timestamp from the set alarms of the Google Nest Hub.

I have 2 different alarms: one for my girlfriend and one for me.

When her alarm goes off, her light goes on, when my alarm goes off, my light goes on.

However, this only works if the time stamps I use for this can be clearly assigned to an alarm clock in the Google Home Hub. If they are constantly changing, it doesn’t work. So I would like to reference a unique feature in the attributes (e.g. the label).

Unfortunately, I can’t currently get this information from the attributes…

Try this template in developer tools → templates.

{% for alarm in state_attr('sensor.schlafzimmer_alarms', 'alarms') -%}
  {%- if alarm.label == "Wecker Alex" %} 
    {{ alarm.fire_time }}
  {% endif -%}
{%- endfor %}
1 Like

Great! That’s it!
Thank you very much @Hellis81

You can also do this with filters instead of looping. This is especially useful if you are trying to use the information for further processing in a template, because you will run into issues with the scope of variables in a for loop.

{{ state_attr('sensor.schlafzimmer_alarms', 'alarms') | selectattr('label', '==', 'Wecker Alex') | map(attribute='fire_time') | first }}
1 Like