Solution to track your google home alarms and timers and trigger different home assistant events

installed this integration because i want to read out the alarms we used to set to wake us .
We used the spoken word: Hey google zet wekker om 7:30 (translation: Hey google set alarm clock at 7:30) , we used the Lenovo smartclock in the bedroom.
The integration seems to be running fine :
1

but when i looked at the device Google Home Slaapkamer ouders wekker
3 the alarm isn’t available .
So i tried to set a new alarm (by voice) for example at 16:30 it’s still not there ? So what’s wrong or what did i do wrong ?

In case anyone is also annoyed with the timers you set on google home speakers that they are hard to turn off.
This sequence triggers on state changes on multiple speakers and let’s the timer ring for five seconds (one loop) then deletes the timer.
It works with multiple timers at the same time (unless if they are supposed to happen very close in time).

[{"id":"c444bad2.edcff8","type":"function","z":"4f357a5f.1c8d34","name":"","func":"msg.payload = {\n    \"entity_id\": msg.topic\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":1880,"wires":[["47a970e3.57d74"]]},{"id":"6fd4626a.4f533c","type":"server-state-changed","z":"4f357a5f.1c8d34","name":"","server":"4bbca37b.1700ec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.sovrum_mini_timers","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":260,"y":1880,"wires":[["c444bad2.edcff8"]]},{"id":"a016e909.c55228","type":"server-state-changed","z":"4f357a5f.1c8d34","name":"","server":"4bbca37b.1700ec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.kok_mini_timers","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":270,"y":1940,"wires":[["c444bad2.edcff8"]]},{"id":"76e24daf.129cb4","type":"server-state-changed","z":"4f357a5f.1c8d34","name":"","server":"4bbca37b.1700ec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.vardagsrum_mini_timers","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":240,"y":2000,"wires":[["c444bad2.edcff8"]]},{"id":"47a970e3.57d74","type":"api-current-state","z":"4f357a5f.1c8d34","name":"","server":"4bbca37b.1700ec","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":700,"y":1880,"wires":[["eb6346f7.5dc178"]]},{"id":"eb6346f7.5dc178","type":"function","z":"4f357a5f.1c8d34","name":"","func":"if(msg.payload != \"unavailable\"){   \n    msg.delay = (Date.parse(msg.payload)-Date.now()) + 5000;\n    msg.payload2 = {\n        data:{\n        \"entity_id\": msg.topic,\n        \"timer_id\": msg.data.attributes.timers[0].timer_id\n        }\n    };\n\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":1880,"wires":[["755dae3f.d731f"]]},{"id":"755dae3f.d731f","type":"delay","z":"4f357a5f.1c8d34","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1000,"y":1880,"wires":[["e547e036.76bd2"]]},{"id":"e547e036.76bd2","type":"change","z":"4f357a5f.1c8d34","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":1880,"wires":[["c36f6761.ba0768"]]},{"id":"c36f6761.ba0768","type":"api-call-service","z":"4f357a5f.1c8d34","name":"","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"google_home","service":"delete_timer","entityId":"sensor.sovrum_mini_timers","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1390,"y":1880,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Just change the entity names on the events state nodes on the left.

Anyone build automations based on alarms?
Very curious to see examples!

2 Likes

Nobody?
I’m thinking about a trigger:

  • if alarm is put off

condition:
alarm set on device x

then turn on script

Not sure if thats possible

1 Like

Nobody? any idea?
Is this topic dead?
@Ilja_Leiko any idea?

1 Like

So by default it takes 180 secs to sync changes, so you’ll be able to see it only after that time. Then, it might be the integration is not capable to retrieve the device status, as this keeps happening for one of the 2 Home mini I have. One of them seems to (pretty much) always work fine, the other fine is always unreachable. This morning I discovered it was the opposite, so it’s so random and annoying I’ve never been able to figure it out so I just gave up for now. The integration is there and installed, lovelace cards too but I’m not using it.

I am also trying to turn on the bedroom light after the alarm goes off but couldn’t catch that in HA. Probably because it takes 3 minutes for it to update HA. So, if I am getting it right, the only way is to get the alarms that are set and do a time match with HA time and trigger the automation. But to me, this seems to be unnecessary processing of comparing time. Has anybody done good automation based on alarm status?

Here’s my automation, as you said, doing time match is the only thing working :slight_smile: The 3 minutes to update , doesnt play a role there since i dont put alarms for time less than 3 minutes :slight_smile: lol

- id: 'Google Home alarm'
  alias: 'GH Alarm trigger'
  trigger:
  - platform: time
    at: sensor.wekker_alarms
  condition: []
  action:
  #Do you actions / sripts
  - entity_id: light.nachtlampje
    service: light.turn_on
    data:
      brightness_pct: 80
      transition: 200
  - delay: 00:00:10
  - service: script.turn_on 
    target:
      entity_id: script.google_home_say
    data:
      variables:
        tts_message: "Goeiemorgen ! Tijd om rustig op te staan."
        tts_target: media_player.slaapkamer
        tts_volume: 0.10
  - delay: 00:02:00
  - entity_id: light.nachtlampje
    service: light.turn_off 
  mode: single  

Is this something new that it takes three minutes to update?
I remember being able to set a timer on 20 seconds and it was updated in HA before it rang.

It seems update_entity works to force an update, so I guess that could be a workaround.

1 Like

You can adjust the update yourself in the integration page:

With version 1.6 we have changed the update interval from 10 seconds to 180 seconds. This is due to #202. Some people are experiencing devices timing out when trying to fetch data from them.

You can manually change the update interval by pressing the configure button on the integration page. Default is 180 seconds. Change this at your own risk! If your devices are timing out, please increase this until it is stable again.

Trying to set this up in a second instance, but i must be doing something wrong…
I added the app in the google account
Then added the integration, all good, but i dont see any devices…

Trying to set it up at my friends house, and he has no entities either.
How did you solve it?
Theres nothing special in the network and i enable mdns in his network

Do you have an delay of the automation, because of the different internal time check or time state. I do have a slide delay of 4 sec in this automation

trigger:
  - platform: template
    value_template: "{{ now() >= states('sensor.wohnzimmer_timers')|as_datetime }}"
condition: []
action:
  - device_id: 659d836acf7ea85d3c6470907bc9d72a
    domain: light
    entity_id: light.deckenleuchte
    type: flash
mode: single

and 1.5 sec in this automation

trigger:
  - platform: time
    at: sensor.wohnzimmer_timers
condition: []
action:
  - service: notify.marceltelegram
    data:
      message: Test
mode: single

Is there a way to set the trigger time 10 sec before it the server time?

Is it possible to flag a google device to be ignored? I have several devices found by the integration, but I’m only interested in one.

Hi. I am trying to use the UI to set an automation that fires when one of the Google home hub alarms goes off. I use the time platform and set it equal to the sensor that maps to the display I am using.

Here’s what the developer tools says the state of the sensor is:

next_alarm_status: set
alarm_volume: 72
alarms:
  - alarm_id: alarm/96f2f1d2-3ce1-4334-ad76-86d666fb37b0
    fire_time: 1690486200
    local_time: '2023-07-27 12:30:00'
    local_time_iso: '2023-07-27T12:30:00-07:00'
    status: set
    label: null
    recurrence: null
device_class: timestamp
icon: mdi:alarm-multiple
friendly_name:  Office display alarms

But this does not fire the trigger, at least in 2023.7.3. Any ideas?

Do you have an updated version of this? Never got it to work for me tbh but the timers do show up in HA.

I was able to start a timer in a google NEST using an Alexa templated command for a variable time (ie washing machine remaining time), then i was able to use a template a sensor with the HACs integration and stop the timer, it is a bit clumsy, so I was wondering if it’s possible to pass an analog or numeric helper along with a toggle helper to google and then start an automation in google home that templates or reads that value for the specific amount of time. Just need to know if it’s possible or if anybody has done it as I havent really done anythign with the google scripts automation.

I have a question on how to get the alarm ID without going into HA manually to pull it in order to delete alarms. What I’m trying to do is to delete an alarm if I’ve woken up before it goes off. I have a routine that runs when I get up, and that works. What I’m trying to figure out is how to pass the alarm-id from the sensor back to the service to delete the alarm. There is only one alarm set for the device. And I can see the alarm in HA and I’ve been able t delete it when trying with the developer tools. Just missing that last piece to connect the two. Fairly new to HA here, so forgive me if this is obvious to everyone but I’ve been looking around for a couple hours now and I’m not any closer than when I started. Thanks a bunch!

Okay…I guess I should have waited an addition hour to post because I did find it. Next time I’ll search for four hours but part of me is convinced that I only found it because I did post the question. :upside_down_face:
If anyone else finds this wondering, in the alarm id use:
“{{states.sensor.device_alarms.attributes.alarms[0].alarm_id}}”
Worked like a charm.

2 Likes

I want to just show the time of the next alarm… but how do i set that local time attribute (preferably in an nice annotation)