[RELEASE] Device Activity Check - Get notifications for "inactive" devices

Hi,

I've found this thread from searching on "lastActivityTime". I recently ran into an issue with a zigbee contact switch using a driver someone contributed "Xiaomi Aqara Mijia Sensors and Switches".

TLDR: it has a "presence" check that runs every N hours, and this was fooling my app into thinking the device (with dead batter) was still having daily activity

Is there a better field to use for checking the last time communication came from the battery powered device?

Also, apologies if this app here already does this, I looked at the source for this app here and saw it using

dev.getLastActivity()?.getTime()

I'm using

it.device.lastActivityTime.getTime()

which looks like the same thing?

Here was the log that fooled me:

And here is the device option for "presence" check

If this driver is by an author who is no longer maintaining their drivers (and was well known for using this attribute for that purpose), I'd suggest moving to a different driver if you can.

But either way, this app can work. You, of course, can't use the "Last Activity At"-based detection method, but you can use the "presence attribute" option for that group instead. (Each group has options for how you want to monitor the devices.)

I use the device activity checker for a lot of devices but for devices like the aqara that have a presence in the driver, I simply use the notifier app to let me know if a sensor goes “not present”.

Thanks, makes sense. I decided to just turn off this "presence" option in the device (as seen in the graphic actually) and then I can use lastActivityAt again.

Actually in the end I gave up on this zigbee door contact as it's just a very small battery and went with a zwave contact sensor instead.

Would it be easy to add an option to turn on or off a device within a group when a notification is sent out? I would like to use a device to indicate when batteries are low or devices haven't respond to display on my dashboard. Thanks.

Not too hard -- I've thought about this before -- but there are some issues/questions surrounding it that make it more complex than it might initially seem be:

  • like its name, the app just "checks" things on your schedule but doesn't "monitor" anything on its own, so a switch being on or off doesn't necessarily tell you anything about right now (though I certainly understand how it might be useful to some extent)
  • what turns the switch back off? (the next time there could be a notification but wasn't? should previewing/manually viewing the current report page also do either of these things?)

But I'm happy to try something if anyone finds it useful -- just not sure what people are expecting for any of the above.

All good questions. Here is how I would envision it works:

For each group you have the option of specifying a virtual switch, or the app creates a virtual switch. The app checks the group as it does now at the specified time. If the group triggers the alert then it turns the switch on. The next time the app checks, if there is no trigger event then it turns the switch off.

Since it is a virtual switch - if I resolve the condition I can easily turn the switch off manually before it checks again if needed. For example - replacing batteries.

One switch per group vs. one for the app would make sense. This would provide the ability to have a switch alerting to battery conditions, no response to activity check, etc.

1 Like

An added bonus would be to add a text field to the virtual device to store the report. Then when the device is triggered the text field could be used to display the report to indicate which device is the problem on touchscreens.

1 Like

This seems like a reasonable approach and is more or less what I was thinking, just wasn't sure if it made sense to others. Though the per-group thing is going to take more effort than one for the whole app. :smiley: (You can create multiple instances of the parent app if you want, if you weren't aware -- though this was, of course, one of the things that prompted me to write the app in the fist place...)

This was a feature I contemplated originally but has never actually been requested until now, at least in some form or another:

In the time since I wrote that, this would also be do-able with a string hub variable, though a custom device (or maybe virtual omni device or something else that has what's needed) would also work. The format also doesn't need to be HTML as I suggested above, though at the time that is what some users used on Attribute tiles since Dashboard 1.x can render them.

Running multiple instances of the app is not a problem. I do that with some other apps right now. But obviously cleaner if it runs within the groups of the app.

I was assuming text for the information string, although html is nice as it could format as a list, etc.

I use Sharptools for all of my touchscreens. They created a custom virtual device that I use variants of for passing certain information back and forth beyond normal device activity:

One option might be to let the user create the device and point to it in the app. If you were to create the virtual device in the app presumably it would require creating a new virtual device driver to accommodate the switch and the text?

Assuming this is the question: go into Apps Code, find Device Activity Check, and enable OAuth -- or ignore and just don't use the LAN or cloud report page feature, which is all this is needed for (the in-app report page will still work).

Love the new links because I’m able to snooze battery devices that have died on me. (Since I have a bunch of devices such as SmartThings motion sensors that report 0% for weeks, I just let them die and use DAC to know when to replace the batteries.) These are at my 2nd home and it may be days or weeks until I can replace the batteries, so the easy snooze is great without having to log into remote admin and access the app.

I have the cloud link added to my dashboard, so i can access it there, but it would be great if I could access the link directly from a notification. Is it possible to add an option to include the cloud link in the notification, or do links not natively work in notifications? If not, would it be possible to add a text box to append custom text to the notification? I use Pushover Notifications Driver [Slightly Enhanced] which allows me to add links to my notifications using plain text, so that would work for users like me to add a link in the notification.

Thanks for your work and for considering this option!

I don't think anything like this is possible with the native notifications, or at least it looks like adding a URL to the push notification text does not automatically make it become a hyperlink. Does Pushover work differently, or does it require special formatting in the notification to make this happen? This should be do-able with some option if so.

The Pushover service allows for hyperlinks, and using the Pushover driver I linked above, you can format text so the Pushover service formats as linkable text as shown below. It’s not pretty/simple, but it works. I use this one for a simple link in a notification to set a global variable to confirm setting my apartment to away when leaving (so if I’m just walking the dog it doesn’ happen). So if I could add custom text such as the below to the notification for DAC, I could get linkable text to the cloud status page in my notifications.

The pushover driver does include an option to add a custom link to all notifications. Currently, it goes to my Hubitat Dashboard, but as a workaround I could create an entirely new Pushover notification device specifically for this purpose and make the standard link go to the DAC cloud status page. But the ability to add a link in DAC notification is preferable for me, and perhaps other users would have other use cases for adding custom text to the notification.

[H][HTML][OPEN]center[CLOSE]Confirm Away for HomeKit Presence[OPEN]BR[CLOSE][OPEN]A HREF="https://cloud.hubitat.com/api/abcd1234/apps/100/trigger/setGlobalVariable=confirmAway:yes?access_token=abcd1234"[CLOSE]Set Away[OPEN]/A[CLOSE]       [OPEN]A HREF="https://cloud.hubitat.com/api/abcd1234/apps/100/trigger/setGlobalVariable=confirmAway:no?access_token=abcd1234"[CLOSE]Don’t Set[OPEN]/A[CLOSE][OPEN]/center[CLOSE]

I've added an option for this under "Advanced Options" that should do what you want. Let me know if this isn't what you were thinking!

This change is in version 2.4, just released; as always, manual install or HPM should both work.

1 Like

Yes, it works! The Report Page link is the one I built in the next text box you provided, and it takes me to the cloud report link you provide in the app. The Dashboard link is the default link to my dashboard that is appended to every message. This is great.

THANK YOU!

EDIT: Note that I added a <BR> in my HTML encoding to drop my text to the next line, but if someone is adding plain text, it appends to the end of the last line, so maybe an included line break is preferable here.

EDIT EDIT: Also note:

  1. The text doesn’t appear in the notification until you click done to reinitiatlize the app. You may have seen this, and they may need to be the way that it is, but perhaps a note next to “Append text to notification?” Is warranted to avoid confusion/questions.
  2. If you select the “append” option and don’t enter any text, you get a “null” in the notification. Makes sense, but maybe make this a required field if the option is selected so that doesn’t happen.

image

I thought about that and decided that since you were choosing the text to append, you could put a line break there if you wanted to...but thinking about it more, with plain text and a single-line text entry field, that's not easy. :slight_smile: So I've made that change (one automatic line break) in 2.4.1, just released.

Also changed this so it saves the appended text setting right away.

And changed it to ignore this, much as I want to leave it in to send a "why?!" to anyone who selects the option but doesn't actually use it...

4 Likes

:rofl: … … … :heavy_plus_sign:1

2 Likes

@bertabcd1234 I just noticed there is still one typo left.

Number of hours to remove deivce from report with "snooze"

2 Likes