My %device% and %value% are not filling in my outgoing message. What am I not understanding?
I tried breaking it up into 2 separate IF statements and got the same results.
My %device% and %value% are not filling in my outgoing message. What am I not understanding?
I tried breaking it up into 2 separate IF statements and got the same results.
These reflect the trigger device name (%device%), the event value (%value%), and the date of that event (%date%), the latter two meaning the event on the trigger device. You might get that last one or maybe the last two for a "certain time" trigger, but I would not count on any of them because you don't have a device as a trigger. Conditionals in your actions do not affect the values of these, which it sounds like you might be expecting. See: Rule 5.1 | Hubitat Documentation
Are you trying to get a notification every day at a certain time? If so, you'd need to either build a string with a conditional for each device (less awkward to receive but may be harder to make) or use a separate conditional and notification for each device (probably gets more potentially awkward the more devices you have but might be OK for just a few). You could also look into a custom app, such as this one I wrote: [RELEASE] Device Activity Check - Get notifications for "inactive" devices (you can do exactly what you want if you use "Battery" as the detection type, but you might actually want to use "Last activity at" if that is what you really care about, as battery can be unreliable...but you can find lots of discussion on that here).
My goal is to check each battery operated device at 11:00 am each day and message me if any device has a battery level below 10%. The 70% in the example was just for testing because I could not find any really dead batteries to test with. From what you say, it looks like I will need a whole bunch of IF statements.
I have a custom app I wrote to do this. If you’re interested I’m happy to share
I understand the allure to proactively monitor batteries at the device level, but especially for lithium batteries, I think you'll (sooner or later) find that it's more trouble than it's worth. In general, anyway.
Lithium batteries have a very steep drop-off at EOL, and their performance at lower values can vary wildly... Just last night, I replaced a dead 2450 cell that had last reported in at 25%. Other users here have had lithium cells that went on just fine for weeks or even months after reporting 0%.
On top of that, not all devices are created equal in terms of how accurately they report battery level to begin with.
For all those reasons, I no longer track or monitor my battery levels anymore -- I just rely exclusively on Device Activity Check (Robert's excellent app that he linked above) to tell me when a device is finally stone-cold dead.
My only "critical" battery device is my side-door lock, and I just replace those batteries annually no matter what they are.
If I had other critical devices, I'd do a similar regularly-scheduled proactive swap.
Otherwise, my battery devices simply run till they're dead, and then DAC alerts me to that within the next 24 hours.
With Rule Machine, yes (unless you wanted to just get a notification for the event, whenever it happens to occur). But if you wanted to use a custom app:
Apparently there is another, above, too.
What is the app written in? I'm interested in learning WebCore.
It’s a groovy app. I’ll paste code here tomorrow.
You could also just use the built-in Notifications app. I use Notifications and @bertabcd1234’s Device Activity Check apps to make sure I am notified when batteries need replacing.
These other folks posting here are much better at this kind of stuff then I am, but here is mine for comparison. I used 50% but on line 63 you can change that to whatever you want. This doesn't work for everything as some devices don't report battery in a timely manner as referenced above. But it works for me for some devices.
/**
* Battery Monitor
*
* Copyright 2020 Jim White
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "Battery Monitor",
namespace: "jwwhite001",
author: "Jim White",
description: "Monitor Battery Status",
category: "My Apps",
iconUrl: "",
iconX2Url: "",
iconX3Url: "")
preferences {
section("Devices To Monitor") {
input "battSensor", "capability.battery", required: true, multiple: true, title: "Battery Devices"
}
section("Time For Battery Check") {
input "checkTime", "time", required: true, title: "Battery Check Time"
}
section("Notification Devices") {
input "notifyPush", "capability.notification", required: true, multiple: true, title: "Notification Device for Presence"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
unsubscribe()
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
schedule(checkTime,battChkHandler)
}
//Control Routines
def battChkHandler(evt) {
battSensor?.each {
if (it.currentbattery < 50){
def msg = "${it.displayName} Battery At $it.currentbattery%"
notifyPush.deviceNotification(msg)
}
}
}
There is also this app that is available in Hubitat Package Manager:
I copied your code to a file on my computer, but I have never installed outside software before. Can you tell me or point me to documentation on how to install and run your program?
Custom apps code instructions here in the Documentation... The part about OAuth does not commonly apply, and I doubt it's necessary for that particular app.