[RELEASE] Google Calendar, Task, and Reminder Search

Apologies for the delay. I needed a couple more days for thorough real-world testing.

Verdict: Works great! :smiley: :+1: Thank you VERY MUCH! I’ve fully implemented this with the rules and Alexa commands to do what I initially required. Result: I’ve been able to cut off meetings on time.

One issue I noticed today. When events are double booked, the one that starts first and lasts the longest controls the switch. In non-sequential, non-expansion mode, can it take the shorter of it all? Or create another option? E.g. event1 starts at 9 am and ends at 11 am. Event2 starts at 10 am and ends at 11:30 noon - switch should turn on a 9, off and on at 10 (including the default 1 min or user set offset), off and on at 11 (again with offset), and off at 11:30.

Last ask, and I am well prepared to get a “no” on this one. Would it be possible to trigger switches at two different times? E.g switch 1 triggers with the -5 min start offset (meeting is about to start warning), but switch 2 turns on at 0 min offset (do not disturb, I’m now in a meeting). I might be able to hack it through some additional virtual switches and rules, so it’s not critical, but I thought I’d still ask.

Awesome great to hear

Not really sure how to handle this one to be honest programmatically. Will think about it and let you know.

Assume you mean the additional sync/toggle switches? If yes this would be an extremely hard thing to implement in the current UI and it would be very confusing. I would suggest creating rules and virtual switches for your specific use cases.

Of course, the second I said that, something will go wrong. Murphy's law. I updated to the official release 2.3.1 last night. Today, the switch is back to briefly turning off (and triggering the end rule) then then turning ON if an event is ongoing at the time of update.

That's exactly what I thought.

Which version were you on previously? 2.3.0.6 of beta? If yes there were no changes to the code. I am traveling this weekend but if you have time to compare to be sure that would be great but there should have been no changes other than version number.

Yes, it was 2.3.0.6. I can't see the old beta code, so I can't run a compare on any of the code. Hmmm. I wonder what's going on. The linked switch is turning on every 15 minutes which is the virtual switch to trigger the 10 minute warning sequence that an event is ending. Which means the light has going through it's 12 minute sequence all day!

Oh well, light will be physically unplugged over the weekend until I can figure it out. Have a great weekend.

You can view deleted files via Commits link highlighted above. GCal Search Trigger was the only file that changed between v2.3.0.5 and v2.3.0.6, parent GCal Search and the Switch remained the same other than version number change.

  • Here is BETA 2.3.0.6. I compared to the published v2.3.1 and there are no differences other than the version number and a few comments within the code.
  • Here is BETA v2.3.0.5. This has many changes compared to v2.3.0.6 and maybe you were on that version? Curious if you revert back to it if the issue goes away? If yes I can compare to see what might be causing it.

Edit: Thinking about it, before reverting to v2.3.0.5, comment out lines 234-254 to see if this solves the issue.

I was working with @halfrican.ak and added this code because he was having an issue with the switch turning on when it shouldn't where he had an offset to turn on the previous day. v2.3.0.6 and the published version of v2.3.1 contain these changes.

Ah! Thank you.

I commented out the lines and refreshed the switch. It immediately triggered the Reverse These Switches. I reverted to 2.3.0.5. Same problem.

I think what's happening is that the Google Switch is actively being turned off after a refresh, even though it's already off, and that starts to trigger the other switch and the rule. Maybe a check to see the state of the Google Switch and then toggle it IF needed? It was working great during the betas at some point and then broke again. :grimacing:

I am not able to reproduce this behavior. Here is what I setup:

  • Search trigger setup to poll every minute
  • No entry is on calendar to match the search string so code will continue to turn "on" the GCal child switch
  • Have a reverse switch setup like yours to turn "off".
  • This reverse switch uses the stock Virtual Switch driver and I enabled descriptionText logging so I would watch it turning off every minute, even though its already off.
  • I setup a rule when the reverse switch turns off, it will log an entry and also send me a Pushover notification:
    image

To test this setup, I manually clicked On and Off in the reverse switch and got the following log messages:

I then enabled the GCal Search trigger and as you can see the descriptive text for the reverse switch being turned off happens, but the rule is never triggered because the state never changes, it is already off:
image

@ritchierich

First of all, thanks for your hard work.

I was wondering if this is possible, I have a calendar with only "All Day Events" with multiple per day. I want to get all the events scheduled for today (preferably in one call, but can do it with multiple if needed). After looking at the code, it looks like getNextEvents in GCal Search gets all the events, but poll in GCal Switch doesn't get them.

Any suggestions would be appreciated.

Alan

The way this works is scheduling is done via child GCal Search Trigger app with further on/off refinements in the GCal Switch driver. The Search Trigger app always calls Poll in the child Switch to initiate the query, which in turn calls the parent Search Trigger getNextEvents which in turn calls the GCal Search getNextEvents telling it which calendar to query since that setting is part of each child Search Trigger app. GCal Search will gather the events and pass that down to the child Search Trigger app to process the match.

You should be able to insert your code in the Search Trigger getNextEvents function. There you will find code that filters for all day events already for example code. Entering a search string of * will get all events for that calendar.

1 Like

Thanks for the help. Made the changes. Had some issues with End date/time, so I decided that when you want multiple events, they must be all day events (what I wanted anyway). I know, cheating, but didn't really want to write extra code. I guess I code parse the list, but didn't. If you want to code, happy to share.

Alan

Programming with dates is the bane of my existence. Bang my head every time. When I first published this project I had simple scheduling because of that but over time community members wanted more flexibility and thus I added it in.

I don’t fully understand your specific use case but if you could explain and if others desire this feature I am happy to explore.

Primary use case is to load all the All-Day events I have on today's calendar. So, if I have multiple All-Day events, I want to know in the morning and display on my Dashboards. Hope this helps!

Alan

Ah got it. @bptworld has a driver that can do this already though haven't used it myself so don't know how it connects:

I wanted in my own notification tile (custom code), but I will look at Bryan's work.

1 Like

Bryan work is very sophisticated but what I wanted was just the events on today.

1 Like

What about this one (sorry if it's already been mentioned):

1 Like

Hi @ritchierich,

Great work on this app, just installed it and started playing...

Is there a way to have the switch turn on if an event is found anywhere on the day? I've setup entries in my calendar for when my local football side play, configuring each calendar entry based on when the game will be played. I would like the linked switch to turn on to indicate today is "game day". I know I could use the offsets, but the start times are not always the same, would be nice if there was a specific option for this use case.

Thanks,
Simon

If I can add another request while I am at it, would be nice to have a formatting option for the start and end time attributes. Perhaps still have the default the way they are currently stored, but an option to enter a format string would be nice. If you use the existing attributes for any logic, then maybe additional attributes for start and end as formatted strings would be the way to go.

Also, do you have any plans to implement a tile layout at all?

Thanks,
Simon

Want to make sure I understand the request, do you have the search running once a day and you want the switch to turn on at the time of the query regardless of the actual matching event timeframe? If yes thinking a “delay toggle” type preference that defaults to on could be added and when off it would toggle switch immediately if a matching event is found regardless of start time. But I would assume you would want the end time to remain and switch turn off at the end of the matching event, with offset option too.

Ugh I hate programming with dates and I had issues with formats and comparing dates in the code. So know there is room for improvement. Are you any good with programming dates? :joy: Definitely open to pull requests. Thinking the easiest approach would be to use the hub location setting as the preference versus offering a new setting.

I do not but open to pull requests. I don’t use dashboards at all so not much use for me.

1 Like

Download the Hubitat app