[RELEASE] Google Calendar, Task, and Gmail Search and Gmail Notification Device

@justinrsteele and @afidel thank you again for letting me know about this edit. I have finally gotten around to updating the steps in Github along with a new screenshot of using TVs and Limited Input devices for the credential type. What is very strange is my production hub still uses Desktop and is working fine but when I changed the credentials on my dev hub to my test Google account I got the same error as you. So it forced me to create a new TVs... credential. I went ahead and updated my production hub too just to be safe since my family depends on this integration.

For anyone else reading this, please keep these updates coming. This is the second time the console was changed since I composed the instructions and with a working integration I don't often repeat the steps.

@mark.townshend very sorry for the delay I was traveling and away from a computer for the holidays. Did you ever get this working? Maybe you were caught up with the error mentioned above with the wrong Application type when creating your credential. I have updated step 13 of the instructions in Github to reflect this change. Please login to the Google Console and navigate to your credentials and see if the type is set to Desktop or TV and Limited Input. If the former, delete that credential and create a new one and try again as that is the cause of your issue. If not please let me know further and if there are errors in the log.

1 Like

Thanks for replying.
I did have it set to TV and Limited Input, only had the Hubitat a week.
Deleted the credentials and recreated, and it has this time authenticated.
I shall tinker further.

2 Likes

Hi! as I mentioned in another topic, would be possible to implement a parameter for having a switch not being toggled when the event ends? This would allow me to use this app for managing the house chores.

For everyone else's awareness, recent comments suggested/required the use of the "TV and Limited Input" credential within the Google Console. I adjusted the Github instructions as a result. As I was investigating whether this app could work with Google Tasks, I found that this credential type has very limited access to Google API Scopes which do NOT include Tasks and Calendar isn't listed either yet it does obviously work. My fear is Calendar access will eventually be removed and this app breaks.

@maxnet21 I've been thinking about your use case and the use of Google Tasks is the best solution and adjusting the current calendar search is not a good use of time. Investing time into using their Web Application credential type is worth it which would allow me to expand the use cases of this application to Tasks too.

A major overhaul of this app is coming which will require that everyone setup a new API Credential and go through the OAuth setup again. Last night I made some good progress but I need more time to complete and test these changes. I will also add a new search trigger for Tasks too. It makes sense to adjust the names of these apps and I also need to test how that will impact upgrading them via HPM, etc and decide if this is even possible. More to come in the next week or so as I find free time to work on this. Like before I may request Beta testing before I release v3.0 so if you are interested in testing please let me know. @maxnet21 I will definitely request your help testing the Task integration once that is complete.

4 Likes

Awesome, count me in for testing!

1 Like

@maxnet21 and anyone else willing to test the v3.0 Beta. This is a MAJOR update where the OAuth setup has completely changed to utilize the Web Application credential type. Again as mentioned above the use of the "TV and Limited Input" credential might break this app at some point so I am trying to get ahead of it.

v3.0 Changes:

  • Complete rewrite of the OAuth code
  • You must enable OAuth on the parent GCal Search app so that the new web authorization will work.
  • Added a new child search trigger app that will allow you to search and match for Google Tasks
  • Clicking Reset Google Authentication or Removing the app now revokes access to your Google Account token. You can view that access in your Google Account Permissions
  • Plumbing in place to utilize Google Reminders that I will add at a later time

ToDo Items:

  • See if I can get Google Reminders to work with this app as a new search trigger
  • Make the child switch an option vs requirement. Idea is to reduce overhead of a child switch that may not be needed for simple Reminder TTS Notifications, etc. Then expand the app to trigger notifications or trigger Rule Machine actions instead - open to ideas here but I definitely don't want to bloat this app with RM functionality.
3 Likes

Hey,

I went through the update instructions but my switches are not being updated when it fields a task.
This is a screenshot of my log. Any suggestions?

As a test, I create a single child app that search for any task containing * (bring any thing).

@maxnet21 You should remove or edit your screenshot as it contains your Google authentication bearer token. It is not finding any tasks at all in your Google account. Did you select the right task list?

I am not able to reproduce this, I entered * as well and toggled my switch because it grabbed the first task it found for today (I have 3)
image

image

@ritchierich Tks for the heads up. Wrote my comment in a hurry and didnt think of the token.
Yeah, I am sure I am checking the right calendar and there are tasks there. At first I thought it was an authenticated issue but based on the log it doesn't seem so. I will play around a bit more and get back to you tomorrow evening!

I manage to bring the tasks now. Strangely, it would work when I set the Search Range as "End of Next day" or a specific numeric range (i.e. 24 hours). I don't know if this has to do with the timezone I am (Central Europe), no idea what could be.

Just one thing: I see that when i toggle a switch, marking a task as complete, the task is removed from my calendar. Is it possible to mark it as complete instead? It feels safer this way.

PS: Related to our previous talk, I see on Google Calendar that Tasks don't have a Due date, maybe this explains the issue you had with the API.

The current version is querying for tasks that have a due date set. Did you not set one prior? I have my search range set to End of Current Day and it works. But if I remove the due date via web UI it doesn't find the matching task.

This could be changed where I get a list of all uncompleted tasks for matching if that makes sense. Toggling the switch will mark it completed.

Unfortunately no. I am super frustrated by the task API as things behave much differently than inactions via the web UI. Here is what I am up against.

Using the Google API explorer here is the raw data to demonstrate what I am referring to:

Raw data of a new uncompleted task:
image

Completing task in the web UI where it remains on the screen striked out:
image

Completing the task via switch in current Beta:
image

So noticed that hidden was not set and the title was also wiped out and hoped that setting those would keep the task in the calendar striked out. So via Google API explorer I reverted this task back to needsAction and then set the following values similar to what was set via web UI:
image

Got the following response which is the same as the prior one completing via web UI:
image

But task doesn't appear striked out in the UI :sob:

As mentioned before there are definitely other attributes on these tasks that the API doesn't expose. I wish I could replicate the UI but I cannot. Thoughts?

@maxnet21 Quick update on a positive note! The Google Task API actually has 2 update methods for tasks: Patch and Update. The current beta version uses Update and I just switched to Patch and this resolves the issue!! The task remains on the calendar striked out. Super frustrating that this isn't documented or mentioned but I will release a new beta version that uses Patch instead.

Let me know about setting due dates of the tasks and if that was the cause of the issue. Again I can change the query to get all uncompleted tasks instead if this makes better sense.

1 Like

Oh, great news! I think marking the task as completed is certainly desired since you keep the history, plus many users might feel uncomfortable if the App keeps deleting tasks.

About the Search Range issue: you said it brings only tasks with due date? Well, my tasks have due date with a time (not a start time and end time, just time, see screenshot).

I was about to give you instructions to replicate my issue, but basically any task I created, recurring or not, does not get found unless I select the Range "End of next day". This includes test that would only exist, let's say, this evening, and not in the following day!

Tasks aren't deleted, just hidden from view. But regardless this issue is now addressed.

OK so you are setting Midnight. Technically speaking when the code searches for today's events it is looking for events up to 2022-01-25 23:59:59. Your task is one second later ( 2022-01-26 00:00:00) thus end of the following day is required to capture it. But this is all semantics and the "When to Run" setting resolves this because I would suggest that you run it after midnight to gather the current day's tasks. And to be clear the date portion of the due date is available in the API but the time portion is not captured, defaults to midnight.

I have also made some good progress with Reminders and will be changing the app up a bit. I was in the process of adding Reminders to the Task app vs a 3rd child app and then that got me thinking I could combine all 3 searches into one child app with a selection at the top to make the code management and installation process much easier. I will provide instructions on what to do when I release the new beta version.

2 Likes

@maxnet21 I have uploaded v3.0.1 to the Beta folder. This new version includes:

  • Google Reminder search. This behaves just like tasks where the switch will toggle if a reminder is found and upon toggling it again it will complete the reminder Google.
  • Google Tasks will now show as striked through in the web UI when you toggle the switch vs completely hidden

Now I decided to abandon the separate task search trigger child app. For you and anyone else that installed Beta v3.0.0:

  • Unfortunately you will need to delete the task search child apps. Please do this BEFORE upgrading to v3.0.1 as the main GCal Search app will no longer show you these child apps
  • After upgrading to v3.0.1 you will find a "Do you want to search Google Calendar, Task, or Reminder" question at the top. This defaults to Calendar for the upgrade. Changing this preference will change options available for the search trigger accordingly

Thank you again for your help testing this Beta. Please let me know of any issues as well as if you are good to release it to everyone.

3 Likes

@maxnet21 I wanted to check in and see if the latest Beta version is working for you and if you have any further feedback in these updates.

You also might try Google Reminders too to see if they will work for your use case. Time associated with the due date does come across via the unofficial API I am using.

Thanks!

Hi! Sure! I will try out asap, worse case I get back here on Sunday!

1 Like

Hi All,
New the Hubitat and the Community (long time HA tinkerer, coming over from Vera most recently). I'm just getting this integration setup as part of my integration. THANK YOU for the great work on it.

My question:

  • Is there any mechanism to use this integration other than setting Virtual Switches. I love the ease here, but I'm wanting to avoid creating too many virtual switches to trigger calendar events. Is there another option to consider here? (e.g.)

    Set a Hub Variable based on a Calendar Condition
    Trigger a Scene or set a Mode based on a Calendar Condition (integrate a GCal search result into Rules Machine w/o a switch).

Thanks so much!
(I see the developer and community is in the middle of a significant update, thank you).

First off welcome to Hubitat! As you noted I am in the middle of a big update and I would encourage you to install the new version instead of the old since the new version will be coming very soon. It is very stable, I’ve been running it for the past few weeks, and it will be less rework for you when it is released - requires changes in the Google Console.

Fortunately virtual switches are “free” and one thing I do is prefix them with “Z”s to force them to the bottom of my device list since there are many I have had to use in the past 3 years on HE. Just an idea that works for me.

I totally understand your question and will be working to make the child switch an option vs requirement. In a few of my use cases I simply have a rule watching the switch turn on only and perform actions so the switch isn’t really necessary. But in other cases, rules watch it turning on and off which makes the switch useful especially since many inbuilt apps have restrictions based on a switch state. So for example I create a calendar entry when we are having a guest stay over and certain night time rules don’t execute because that switch is turned on.

Rule Machine does have an API where rules can be invoked from other apps. I have read comments from Bruce that it doesn’t work yet with the latest rule machine but he is in the process of enhancing that. In the mean time I will see what I can do but want to mention further updates will be required.

I just updated the Google API instructions yesterday with the new required changes and you can follow those here:

Thanks so very much for the information and the prompt reply. I will switch over to your new version and give it go! I truly appreciate all your work.

1 Like