Help with a template sensor out of attributes of another sensor

Hey community,

I am trying to create sensor via the template platform from the custom Google Home Integration.
The Integration provides a sensor that swows me the different alarms created on my Google Nest Hub. What I´m trying to do ist to extract the local_time attribute of the 2 different alarms, that I have configured.

Here is what the sensor gives me:

next_alarm_status: set
alarm_volume: 96
alarms:
  - alarm_id: alarm/997bb51d-a9fb-4564-870e-192d51b1f0fe
    fire_time: 1643527800
    local_time: '2022-01-30 08:30:00'
    local_time_iso: '2022-01-30T08:30:00+01:00'
    status: set
    label: null
    recurrence:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 0
  - alarm_id: alarm/last_missed_alarm_id
    fire_time: 1642921200
    local_time: '2022-01-23 08:00:00'
    local_time_iso: '2022-01-23T08:00:00+01:00'
    status: missed
    label: null
    recurrence:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 0
  - alarm_id: alarm/6cecd8d6-314e-432a-8ebb-911b1114d262
    fire_time: 1643347800
    local_time: '2022-01-28 06:30:00'
    local_time_iso: '2022-01-28T06:30:00+01:00'
    status: inactive
    label: null
    recurrence:
      - 1
      - 2
      - 3
      - 4
      - 5
device_class: timestamp
icon: mdi:alarm-multiple
friendly_name: SchlafzimmerNest alarms

One alarm_id is from my wife the other one is my alarm. Is it possible to create a sensor for each local_time in dependency of the alarm_id?

Thanks for your help!

Try something like this:

{{ (state_attr('sensor.your_sensor', 'alarms') | selectattr('alarm_id', '==', 'your_id') | list)[0]['local_time'] }}
1 Like