Would be nice to call an URL within the Notifications app

I'm trying to setup a better low battery notification that is both informative and less annoying that doesn't require an hour of custom rule making that has be to updated with future devices.

I have the Notifications app setup for low battery notifications but the only options I have available are Twilio SMS messages and phone notifications. I have 40 battery devices and have it set to notify at < 40%.

Having the messages go to SMS triggers them all the time especially when some of these remotes have battery values that seem to fluctuate day to day where it reads lower than actual then later it reports high enough. I don't like hopping in the car and playing music from my phone and having the stereo interrupted with SMS dings coming across and the Apple Car play reading off low battery messages to me. I just want those to go to email.

I only want critical notifications going to my phone (water leaks, smoke alarms). I want low battery notices to go to my non-phone email. Adding the option to call a URL to the notifications app would make it easy as I have my own server script setup to take a simple message string and my server handles firing that off in an email.

Send GET to: https://www.MYDOMAIN.com/cgi-bin/hubitat.cgi?mt_note=Battery%20Low%20(%value%%)%20-%20�vice%%20on%20�te%

This call would work if I could add it into the Notifications app.

I setup a separate RM rule instead to try this, added a rule checking off all 40 devices if there is a low battery tripped, but from what I read in another thread that type of rule which is easy to create and update won't pass along the device/value variables. It only passes along %date%.

The alternative looks to have to manually add all 40 devices OR'ed together or 40 different if statements just to grab the device and battery values. Not something I want to spend that much time on especially with having to maintain that rule.

Is there an easier way to set up an email notification for any low battery that I'm missing? For now I'm just going to send a low battery notice email without the device info and I'll have to check the battery level dashboard.

If it helps, there’s a community driver for a notification device that sends an email. I believe this can work with the Notifications app:

https://raw.githubusercontent.com/lgkahn/hubitat/master/batterymonitor.groovey

Thanks, I'll try out the email driver. Having that show up as a notification device in the built-in Notifications app will cover what I'm looking for.

The notification app already is working fine checking battery levels. And I have a dashboard setup with just the devices using batteries that is a good quick check that shows them in red/green/grey just fine.

This is why the better approach is to use an app that reports about devices that are inactive. There are a few excellent ones that will give a single report once a day about all of your inactive devices. I like @ericm's Device Monitor, but [RELEASE] Device Activity Check - Get notifications for "inactive" devices and [RELEASE] Device Watchdog are also nice.

(some of those can report on battery level, too, if you want, but activity is better IMHO)

This is not correct. It can reference %device% and %value%. For a battery alert those would be the name of the device and the battery level reported.

3 Likes

I did try it and the %device% and %value% were not being passed into the URL string but the %date% value was. I've got the SendMail installed now and just about got it setup, so I'll just use that instead in the Notifications app, which will work out better anyway.

Cool, thanks. I had it on my list to see about how to do inactive device checks. I'll take a look at those.

1 Like

Been tying to get this this LGK Sendmail working but no luck. I have my own web server and multiple domains on it with my own email servers. Using the same settings (mail server, outgoing email, SSL authentication password, port, etc. all match) I have in my Thunderbird profiles for SMTP outgoing emails and can't get it to send out. Debug logging says telnet is okay in the device but it won't send out.

there is no ssl or any encryption .. only optional authentication is username password that may be why you cannot get it working.

Ah, ok. Looks like I can't use it then. When I try to send with authorization turned off and use port 587 which is the non-ssl port my web server kicks back errors that its not authorized. I seem to recall my server had all the non-ssl stuff locked down for PCI compliance scans. I can still use other RM commands to at least just fire off a script call to my server using GET and let my script send the email since I have that all working. I just couldn't get the device name to send that way.

you are misunderstanding authorization and encryption. they are independent. try turning authorization back on and use port 587

if you have your own email server and it accepts incoming mail. it has to work without end to end encryption normally that is port 25 . does your server not accept incoming mail? is it only for outgoing.? How do you get incoming mail for your domains?

It uses POP accounts for incoming email with SSL/TLS passwords and port 995 and outgoing is SMTP on port 487. Honestly its been a few years since I touched any of the email servers and I recall it was a headache getting the servers all patched up and locked down for all the PCI compliance scans that I had to have run on it for my credit card processing. I was just replicating the same settings I'm using in my email client in the SendMail. I've already removing all the LGK Sendmail driver and code and and doing my own thing that doesn't need Hubitat to do the email sending. I have my own server side scripts I can call and they handle sending me emails.

pop is not incoming.. pop is for reading mail that has already been delivered to the server and is waiting to be read.

if you tell me what your domain name is . i can look up what server is handling your incoming mail and most likely tell you what settings you need.

Thanks, but I've already moved on from this. I might have not worded that right, but yea I know the difference between which direction things are going. I already have a perl script I call from a different battery check RM rule I wrote that fires me off an email. The only thing that isn't working there is that I can't get the %device% and %value% to get passed into the GET string. I do get the %date%, I also tried OR'ing the battery check condition so only a single device trips the rule and calls the script as I read that can work in another thread, but that's not working either. I get "null" passed for the device. It's really not a big deal, all I have to do is click the battery level dashboard I made to see what device showed up low.

1 Like

What I'm really trying to do is just get the device name that tripped a low battery rule to show up in a URL.

If (Battery Level of Back Office Sensor < 40) then
https://www.XXXXX.com/cgi-bin/hubitat.cgi?mt_action=1&mt_device=�vice%
end if

Testing this with just 1 device in the condition passes null into the server. When I add %date% that does give me the date and %value% is blank. Someone else mentioned that something like this is supposed to work for getting the device name and value. My full rule checks about 40 battery devices so I have them all in the conditional.

suggestion . log it and see if the device name is intact.. if so it may be the spaces in the name causing issues for the url.

I can't get it to send a URL that has spaces and even using %20 in place of spaces doesn't work. Any URL that does have a space in it seems to cause the GET to not even send it to the server. And all my device names are multi-words with spaces. I'm giving up on this and just going to call my script to send me a general purpose battery warning and I can just click the dashboard to see what is low. And I'm looking at integrating one of the device monitor apps instead that might work out better.

I am using a perl script I wrote to just pass in a variable to tell it what happened in general. If its a smoke or water alarm it fires off emails to 3rd party contacts with instructions on how to enter the building and where to look for the leak or smoke detector that tripped, etc. Longer messages than I want to put in a rule within Hubitat anway. Its fine if I can't get any variables out of Hubitat or have it convert the URL to something it can send such as if it has spaces in it. I just need to be able to fire it off with a single variable like ?action=1 or ?action=2, etc.

And that part I have all working.