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

Would it be possible to let this app flip an existing switch rather than just a child switch ? I have an existing switch that I want to switch and now I have to instead get the app to run a rule that will flip the switch.

In the child switch section of the search trigger you can control other switches in todays version. It will toggle the child switch along with the selected devices.

Given this is based on an ST version it started with controlling a child switch only and I have slowly added the Additional Action features to perform other actions since it doesn’t always make sense to have a child switch especially with notifications. Creating the child switch is optional as well. I suppose I could add switch control to the additional actions section and remove it from the child switch section.

Creating the child switch does not seem optional to me, we must specify a name. It doesn’t make sense to create a child switch, I already have one.

Currently in order to toggle additional switches it is required to also create a child. But overall it is optional with that toggle in your screenshot.

Know you’ve been using this app for a while and know this was based on a port of a ST app which was all child switch driven. Hence why it currently the way it is. The child switch has many attributes about the matched Google item what your current switch won’t have. May not be important to your current use case but it is for others.

I can explore moving that functionality to additional actions when I have some free time over the holidays.

3 Likes

Is anyone else having their html tags stripped from the notification output text in RuleMachine?

My email notifications are just a wall of text, so I'm trying to add a line break, but the "" just disappears the second I hit "Done Editing Action."

I even tried the dishwasher example in the setup instructions and that gets stripped as well. Thought maybe it was just RuleMachine but I'm getting the same result in the Basic Rules App as well.

If HTML tags aren't possible, is there a way to make my email less wall-of-text-ey?

They are stripped for security reasons. Old post explaining:

I came across that post as well but thought that the users of this app must be using a workaround. The driver code in that thread threw up an Empty Parent error when I tried installing it so no dice there.

Am I misunderstanding the majority of people's use-case for the GCal search app? I must be, because not being able to add line-breaks to my email notifications became an issue on my very first email :thinking:

Gmail notifications are somewhat new to this app and the majority of the use cases for this app are search related querying calendar events and tasks to automate things within the home. I personally have several calendar queries that will turn on lights for wake up alarms, notify family and neighbors of USPS mail holidays and trash/recycling pickup, set my vacation switch to automate thermostat settings, prevent guest bedroom lights from turning off if guest is present, etc.

When I added Gmail search to the list it was logical for me to also add Gmail notifications too. But again that was added within the last year and this solution has existed well before Hubitat since it was created on the SmartThings platform many years ago and it was ported over and I have been enhancing the last several years.

My uses of email notifications are very limited to be honest and I added based on community request. I mostly use Pushover notifications. Hopefully others chime in here.

Have you tried \n for line break?

Know @danabw uses this for emails maybe he has some ideas.

I only use the email option to send emails to the Verizon email>text gateway, so not worrying about line breaks or any special characters...my messages are simple/short "this happened" notifications. Sorry I can't help.

1 Like

I did a little more testing and the Gmail Notification device allows you to insert <br> and it works:
image
Resulting email...
image

So the HTML stripping is definitely a RM and Basic rule situation as I confirmed that the BR's were being removed. I even tried to use a hub variable and insert the <br> and it also stripped them out.

I am sorry for this situation but this isn't a problem with the GCal app or device, its a HE hub UI situation causing it. You might consider opening a feature request in the Rule Machine category and request something to allow line breaks to be allowed.

1 Like

@bpkeeber sorry for yet another reply, thought of a work around I could create within this solution. I tested the use of the ASCII \n within the message and unfortunately it doesn't cause a line break but I added a few lines of code within the parent GCal Search app and I can substitute that for the actual <br> that is necessary to cause a line break.

My test RM app action:
image

Resulting email:
image

I will add it to the next release but in the mean time you could add these few lines of code to your existing GCal Search app code. Insert the following lines:

if (message.indexOf("\\n") > -1) {
	message = message.replace("\\n", "<br>")
}

Between lines 1096 and 1098 like the following:

Then include a \n in your rules and it should turn it into a new line.

1 Like

Version 4.6.0 has been posted to Github and HPM:

  • Added ability to turn on and off other existing switches in the Additional Actions settings. A child switch is no longer required to do so. If this was setup previously, the upgrade process will move the settings to Additional Actions. Thanks @mboisson for the suggestion!
  • Added the ability to enter '\n' within a Gmail notification message which will cause a carriage return within the email sent. In recent versions HTML is automatically stripped so this is a work around for new lines within email notifications. Thanks @bpkeeber for the idea!
  • When selecting switches in the various Additional Actions settings, the filter box is now available to quickly find specific switches.
2 Likes

I see that you've already published the updated version 4.6.0 :hushed: This is fantastic! thank you so much.

I appreciate your consideration immensely.

Can't wait to upgrade my automations with some shiny new
\nline
:sparkles: line :sparkles:
\nline
:sparkles: breaks :sparkles:
:sunglasses:

1 Like

This is fantastic, thank you -- I only use the GMail part right now (to enable Email/SMS based on events), but it works great.

Small bugfix (for your next release) -- if a child device is actually disabled on the Devices page, the code in the GCal_Search.groovy throws a null pointer exception at getNotificationDevices().

You could change lines 253/254 to have devPrefs?. instead of devPrefs. and then it shows the line correctly, but with null values of course.

2 Likes

Welcome to the community. Appreciate the bug report and solution. I am traveling this week on business but will get this resolved next week.

2 Likes

@ritchierich - just upgraded to the latest app code using Hubitat Package Manager and got this error in the log:

Subject: Log: error - Away
Message: Date/Time: 2024-01-24 16:56:48.687
Message: java.lang.RuntimeException: invalid device id 'null' on line 2374 (method upgradeSettings)

Any idea what may cause this?

Latest update changed the name of a few settings from prior version and the upgradeSettings function moves old to new. Given it says null you weren’t using the old setting so no worries. Will put in better error handling in the next release.

2 Likes

Version 4.6.1 has been posted to GitHub and HPM:

  • Fixed NullPointerException while loading the parent GCal Search app when a Gmail Notification device is disabled. Thank you @dpanagiotou for reporting this issue!
  • Added additional error handling in the upgradeSettings app to prevent errors. Thank you @rakeshg for reporting this issue.
3 Likes

Hi, Probably a weird question, but could google sheet api linked the same way ? I try to update some cells using api and its complicated but if we could have the service linked like this we could update the sheet directly from hubitat without creating forms or public share.

Unfortunately I haven’t done much with Google Sheets so don’t know. Know there are several threads in this community on how to push data to sheets so maybe those will solve your needs.