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

I upgraded to V2 via HPM so that’s working too

3 Likes

I'm trying to follow the steps you have on github for the Google API setup and it seems to be missing a bunch of steps. I need to get to bed, but I can post more with some screenshots tomorrow.

To summarize though, when I try to create credentials I get the error " To create an OAuth client ID, you must first set a product name on the consent screen" with a button to configure the consent screen. This button takes me to an app registration page with a lot of stuff to enter.

I don’t think it’s missing stepsbut some of it seems out of order. By reading the whole instructions and then filling in the bits from later when asked earlier (if that makes sense) it worked for me. Finding how to create a new project was a bit of a challenge to start with but the online search facility helps a lot.

1 Like

Thank you for the feedback. The Google Console is the most painful part of this solution. I am certainly no expert in that area and had set mine up years ago for another purpose and was able to reuse it when I installed the ST ported version. I went through the setup a few times as I was creating the instructions and the steps and order worked both times.

If you have edits please share or better yet submit a pull request in GitHub to the readme.md with those changes. Would be great if we can make this better for all.

1 Like

I had a scenario this morning that didn't work the way I expected, so I wanted to share. Here is my calendar for today:

I have a switch set up to look for events with the title "Busy". Notice that around 9:00AM, I have several overlapping events. The switch picked up the first Busy event (8:30AM to 9:30AM) and turned the switch on at 8:30AM. At 9:30AM, it turned the switch off, even though there was second active event during this time (9:00AM - 10:20AM).

It makes sense, I think, but I'm not sure if there's any way to get the behavior that I want. It refreshed at 9:25AM, when the first event was still active, so it kept the schedule for the switch to turn off at 9:30AM when that event ends. (Technically both events were active at this time, so I don't know exactly why it chose the earlier one.) It refreshed again at 9:40AM, picked up the second event correctly, and turned the switch back on. However, by this point, the switch had been off from 9:30AM to 9:40AM, causing the vacuum to start in the middle of my meeting (DOH!).

Unfortunately the current version doesn't address this situation. The code picks up the first event within the timeframe of current minute through the end time setting (default end of day). So it would pick up the first busy and create schedule for that specific event.

It doesn't continue to loop through the other events to expand out the end time if events are overlapping. Could it? Probably (well definitely) but my head hurts at the moment thinking about how to approach it as dates such a pain to program around.

Thank you for the screenshot as it gives me something to test with as I approach how to solve this.

100% agree, and don't feel like you have to jump on this right away. Just another challenge to keep your entertained in your spare time :stuck_out_tongue:

I ended up having the same behavior with back-to-back events. The refresh at 10:25AM used the meeting from 10:15AM to 10:30AM, so it turned the switch off at 10:30AM. The meeting from 10:30AM to 11:30AM didn't get picked up until the next refresh at 10:40AM. I might be able to change my refresh strategy to better handle this case, but I'm not sure yet.

Just thinking out loud here: what happens if the Event End Offset overlaps with the next event?

For example, let's say I have back-to-back meetings from 8AM-9AM and 9AM-10AM. Currently, the following happens:

7:55AM - Switch refreshes, finds the 8AM-9AM meeting, and schedules itself to turn on at 8:00AM and off at 9:00AM.
8:00AM - Switch turns on.
8:55AM - Switch refreshes, finds the 8AM-9AM meeting again, and makes no changes.
9:00AM - Switch turns off.
9:10:AM - Switch refreshes, finds the 9AM-10AM meeting, turns itself on, and schedules itself to turn off at 10:00AM.

If I schedule the Event End Offset past the start of the next meeting, could I overcome the gap between 9:00AM and 9:10AM above? Would it do something like this:

7:01AM - Switch refreshes, finds the 8AM-9AM meeting, and schedules itself to turn on at 8:00AM and off at 9:02AM.
8:00AM - Switch turns on.
8:01AM - Switch refreshes, finds the 8AM-9AM meeting again, and makes no changes.
9:01AM - Switch refreshes, finds the 9AM-10AM meeting, deletes the existing schedule to turn off at 9:02AM, and reschedules itself to turn off at 10:02AM.
10:02AM - Switch turns off.

(That all makes sense in my head, but I always wonder if it's complete nonsense when I write it down..)

Couldn't you just have multiple child apps that look for events every hour, or some period that would catch the overlap? It might cause a false positive, and make the vacuum not run often enough, but would probably be more desirable than the other way around.

Or use the opposite logic, and look for away events and trigger the vacuum to begin from that instead of (or in addition to?) the busy event.

I feel like this situation could be handled by creating a virtual switch driven by an RM rule that handles the "logic" of the overlapping events?

1 Like

I just pulled up the Google Console and the UI is completely different than when I took the instructional screenshots :rage: This is going to be hard to maintain if this happens. Will eventually get to updating the screenshots in GitHub but hopefully you had better success today walking through them.

1 Like

@mikee385 In between meetings looked at the code and this might be a bit simpler than I originally thought. I posted a "testing" version for you to try in my personal repo. Could you please try this and let me know your results? From there I can post the new version to the main repo.

  • Link to Testing Version - v2.1.1 now includes this functionality
  • Replace your GCal_Search_Trigger.groovy app code.
  • Changes are only to the getNextEvents() function
  • The new code will loop through all the events found from the Google query and checks if the end date date is greater than or equal to the start time of the next event. If yes then the event end time changes to the next event and so on.
  • What this does mean is the state values in the child switch might not match if say the title or location are different but have the same keyword for the match.
1 Like

Yeah, that makes sense. I probably would have tried this myself if it hadn't been getting late. I'll try again when I have some free time this weekend.

I just redid this app yesterday, and I also had to skip back and forth a few times in the instructions. It did end up working, but it was a bit confusing to have to do that naming of the OAuth product name step, then go back and continue to do the rest of the steps.

Thank you!!! I've got it installed, so I'll let you know how it works. Sadly (thankfully?), I have zero (ZERO!) meetings tomorrow and Monday is a holiday, so I may not have any meaningful results until Tuesday.

...Eh, nevermind. I just created a bunch of fake meetings tomorrow just to test this out :stuck_out_tongue:

2 Likes

Looking good so far!

Edit: @ritchierich Worked perfectly today. Both of my switches turned on exactly when I wanted and turned off exactly when I wanted. Great job!

2 Likes

@ritchierich Just wanted to give you mad props - this is fantastic. I downloaded this a week ago to keep track of my kids' school breaks (they are still learning remotely unfortunately), and to give them reminders through our Sonos speakers that their breaks are over if I happen to be in a meeting. Synced to a calendar with stat and PA days to ensure that the messages only go out on school days.

Then I got to thinking that this app would be great for garbage day reminders. I was giving up hope on figuring out how to do this, started a search in the community and lo and behold, @gertjan.deprez thought of exactly the same thing at the same time. In a week from when I downloaded the app initially, the functionality magically appeared. Amazing!

My ultimate plan is to put a motion sensor behind one of the trash, compost or recycling bins, and if no movement has been detected the day before garbage day, I'll get a reminder that evening to take out the trash. What could be better, other than the trash taking itself out??? Although in a few years, when my kids are a bit bigger, the trash will effectively take itself out, in theory haha.

Anyway, thanks so much for developing this app - I've only had it a week and it's already become an integral part of my (admittedly very new and spartan) home automation solution!

2 Likes

I don't wanna walk with any honor from it. I only had some ideas but nothing more.

I'm still running 'tests' but so far it's i'm ready for the next step...
Fase 3:
Turn on a outlet (with heater) on 1hour before event and only when it's not 11am or later and when Temperature is less then 22°C.
(auto turn off after 15min)

should be great and so far this app won't be a problem... amazing work.

1 Like

Thank you for the kind words and I am very happy you are finding this useful. I found great benefit in using the original version @cometfish ported over and I adapted it to my needs. Happy to share so others may benefit as well.

4 Likes

I’m not sure if this is the app or my calendar, but something looks a little off. I have an all-day event for Monday, and it looks like it picked it up correctly, as the switch is on and eventAllDay is true. But the start and end times look weird. It’s like it used the time zone offset, even when it shouldn’t have (or maybe twice?) .