Battery Handler

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
mc_digital
Posts: 1
Joined: 13 Feb 2022 23:01

Battery Handler

Post by mc_digital »

Hello...first time posting, but I have found many useful tidbits of info that have helped me with projects. Can't seem to find an answer to this one though.

No matter what I do, I can't seem to get the battery handler to work with SmartThings.

I'm using z-uno as a water sensor, to report just Wet or Dry (it's actually hooked up to the float sensor of my 12V backup sump pump). That part works great. The water sensor template in SmartThings also reports battery status...it was grayed out and 0%. Then I figured out once I set sleep mode to FREQUENTLY_AWAKE, the battery control came alive and reported 100%.

I then wanted to make a custom battery handler, and report back my sump pump battery status...can't seem to get that to ever fire though. It just keeps saying 100%. Here's what I tried just to get 50% out as a test:

byte batteryLevel=50;

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);
ZUNO_SETUP_BATTERY_HANDLER(getterBattery);


byte getterBattery() {
return batteryLevel;

}

I sent reports a bunch of times and left it on overnight...nothing.

I also tried zunoSendWakeUpNotification() to see if that would force a request for battery status, but even though it's right out of the reference section, the Arduino compiler says there's no function by that name. That's the first call I've ever had a problem with in the IDE. Everything else works fine.

I'm guessing there's something I'm missing in how to get SmartThings to ask for battery status, or I'm missing a key piece to setup the handler properly...just can't figure it out.

Any insights appreciated.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Battery Handler

Post by p0lyg0n1 »

Hi,
The first significant information we need is the version of your ZUno and your core-version. Seems you use ZUno G2 with core version 3.0.7. Am I right? I'll try to make example with the latest beta (v 3.0.9b2) and post it here.

Best regards,
Alex.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Battery Handler

Post by p0lyg0n1 »

So, I tried the latest core (3.0.9b2) with RaZberry (Z-Way), it works as expected. So it answers with 50% value every time controller asks. When I wake up Z-Uno using "BTN" it reports battery unsolicited with 50% value.
Here is my sample code (is based on your code):

Code: Select all

byte batteryLevel=50;
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);
ZUNO_SETUP_BATTERY_HANDLER(getterBattery);
ZUNO_SETUP_CHANNELS(
        ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, getterTemp)
);
byte getterBattery() {
 return batteryLevel;
}
void setup(){
}
void loop(){
    delay(3000);
    zunoSendDeviceToSleep();
}
// Getter
int getterTemp() {
  return 2100+rand()%1000;
}
Another one thing I have to note is zunoSendWakeUpNotification. This function is suitable for sleeping devices ONLY, because FLIRS devices don't have WakeUp command class.
Please try my code ^^^ with SmartThings. I think it has to work. You have to update your device to the latest beta, please follow this instruction
https://z-uno.z-wave.me/arduino-install/ (here the beta-repository listed).
Good luck!
Best regards,
Alex.
Post Reply