So, if I understand the Google Calendar- and the HA Calendar documentation correctly, there’s only a straightforward way to do automations based on when an event starts/ends, but not when its’ notifications trigger, no?
I’m asking because I want to mirror those notifications to see them on all devices as soon as they’re created (at the point of the appointment is obviously gonna be too late)
and I don’t know how that’s supposed to be possible if the API doesn’t directly include that functionality.
so the action references (right terminology?) the calendar event in this example but I suppoose it would have to be done differently if the trigger was the events’ notification rather than the event itself, wouldn’t it?
There are multiple ways to make this work, depending on how you have everything set up, but it is not part of HA’s Calendar integration.
If your calendar is sending standard notifications, you can use the HA companion app’s Last Notification sensor. You will need to make sure the calendar app on your device is in the Allow list for the sensor.
If your calendar is sending email notification, you will need to set up an IMAP sensor and Content sensor to trigger your automation.
This can vary based on the calendar application running on your phone… not all phone manufacturers install the base calendar app package. If your device uses a different calendar app package you will need to figure out which attributes you need to use.
Can you achieve what you want by using the calendar trigger offset? That is, the automation can fire X minute before the event. You can’t do it dynamically based on the exact notification offset time in google calendar, but it its fixed (e.g. “5 minutes before event start”) before all events it will work. I assume you may have already thought about this, but just wanted to clarify the offset feature in case that was missed.
You will need to make sure the calendar app on your device is in the Allow list for the sensor.
how do I do that? The documentation I found didn’t tell me how exactly to set it up.
I suppose it’s not normal that I don’t see a sensor.Galaxy_S7_last_notification even though I have the companion app for that device
Also, When I entered your template as a condition it gave me the error “Message malformed: template value should be a string for dictionary value @ data[‘action’][0][‘data’]”
What’s going on with that?
Not all sensors are enabled automatically, you enable them in the Settings menu.
In the mobile app:
Setttings > Companion App > Manage Sensors > Last notification > Allow list (at the bottom of the page)
Make sure there is a check in the box next to your calendar app, then save the list. Samsung is kind of notorious for using non-standard app packages, so you may need to do some research to figure out which one you need to enable.
You will likely also need to change the values in the Condition template since other apps often use different variable names than those used by the base Android/Google applications.
That error is regarding the value for data: in the notify action. You likely have an indentation or quotation error somewhere… There’s no way for us to tell without seeing your configuration.
I tested the automation and it only worked 1 out of 6 times for some reason.
Asides from that, how can I check what a notfications’ channel ID is called?
The tester does not work with Template conditions… especially in this case since there is no trigger event to populate the trigger variable used by this template.
You will have to go to the Developer Tools > States tool and check the attributes of the last notification sensor immediately after a calendar notification is received.
@Didgeridrew your code seems to run without any issue for some weeks.
I was wondering if there’s a way to extend the functionality even further to make it act like an actual calendar notification, meaning that when it’s tapped it opens the event from that notification in the calendar app
I don’t use Pushover, so you’ll need to do a bit of experimenting…
For the HA companion app and Android devices, I would add a click action with an Android intent, but Pushover only seems to allow opening a url. The intent url may work if all your target devices are Android. Try the following:
hm upon changing the action to the version you presented the Pushover notifications for this Automation don’t fire anymore at all
And I’m pretty sure I added the code correctly this time
Considering one of my devices has iOS I tried just adding the URL in this simpified action:
action:
- service: notify.pushover
data:
message: |-
test
url: 'https://calendar.google.com/calendar/u/0?cid=YXJzNGw0bjEyM0BnbWFpbC5jb20'
but even that threw an error:
“Error running action
Error rendering data template: Result is not a Dictionary”
I also tried the variant that was in the Pushover documentation:
action:
- service: notify.pushover
data:
message: test
data:
url: https://calendar.google.com/calendar/u/0?cid=YXJzNGw0bjEyM0BnbWFpbC5jb20
which on iOS upon tapping the notification only causes the pushbullet app to open with the link there for me to tap again to open google calendar. I was hoping for the page to pop up from just tapping the notification though, just like how the actual calendar app would behave. Additionally, it opens the Google Calendar Website thereby clogging my tabs, not the Google Calendar App.
I didn’t find comprehensive documentation, nor actual package names, just some vague userposts so I also tried google calendar://calendar.google.com/calendar/u/0?cid=YXJzNGw0bjEyM0BnbWFpbC5jb20 and google_calendar://calendar.google.com/calendar/u/0?cid=YXJzNGw0bjEyM0BnbWFpbC5jb20 for the last line with no success
iOS stuff is outside my wheelhouse… have you looked into setting up a Siri Shortcut to launch the Calendar. You can fire Shortcuts via HA service call with additional data, so that might be an avenue to explore.
@Didgeridrew
I’ve been noticing a issue recently which I can’t exactly pinpoint because it doesn’t occur consistently
I think it’s probably something in my Galaxy S6s’ tasker configuration (because upon disabling all Profiles the issue disappeared) but everything is set up correctly so it must be a bug
The issue is that sometimes the Pushover notification just gets immediately canceled
Do you have any suggestions or know a way to set this calendar up which is less prone to bugs?
Update: I just quit using the Galaxy S6 and used a Pixel 3 + Galaxy S7 and iPhone 12 mini instead and the issue went away.
I noticed a new issue with @Didgeridrew 's automation: When I set two Calendar notifications at the same time only one of them triggers the automation. So, the other one isn’t mirrored.
It’s not even in Home Assistant’s History page.
that didn’t do anything and I would’ve been surprised if it did since it’s not the automation not firing but actually the value not being reported by the HA Companion App.
He suggests to use the Active Notification Count sensor as a workaround as that contains the notification title as an attribute.
So, I tried redoing the automation with that sensor, but I got stuck because for this sensor the attributes are different in that each notification has an individual number on the left side of the colon
and I don’t know how to make templates for that. Would you help me out with that?