ZX612 / Topin Protocol / Battery Level

Frank Meier4 years ago

Server and Tracker work fine with the Topin Protocol (which I missed 1 year ago --> many thanks for this support!!).
How can I read out the correct battery level (protocol says "0x13 status package") and send a notification if e.g. battery level is <20%?

I was not successful reading out the battery level since now. Many thanks!

Dan Dyse4 years ago

Hey Frank, what exactly is the model you are using? I am trying some ZX612 and they don't seem to work. What's your settings?

Frank Meier4 years ago

Hi Dan, yes I am also using ZX612 - it submits "batteryLevel=13" as an example... this works, so battery has 13% left.
I didn't figure out how to send an email if batteyLevel <20... please let me know if you had success, thx!

Frank Meier4 years ago

The Computed Attribute seems to work now..
Attribute: Alarm
Expression: batteryLevel < 62 ? "lowBattery" : null
Type: String
Output Info: "lowBattery"

But the Notification is not working, I will not get an Information on Web, Mail if the battery level is beyond 62%.
Notification is enabled.

What am I doing wrong?
Many thx for your help...!

Dan Dyse4 years ago

Hey Frank, it is working here now for both mail and popup. I have used the same computed attribute.
I have then added a notification Type "Alarm", Alarms "Low Battery" and Channels "Web" and "Mail".
Don't forget to activate both for the device you want it working on!

I have added mail-configuration by adding appropriate attributes to the user:
https://www.traccar.org/documentation/notifications/

It seems that an event is only triggered once, even if the attribute keeps being true. Not sure why...

And somehow I keep getting a "Attribute computation error" but it seems to work anyway. The logfile says:

WARN: Attribute computation error - org.traccar.handler.ComputedAttributesHandler.computeAttribute@102![0,12]:
'batteryLevel < 58? 'lowBattery' : null;' undefined variable batteryLevel - Variable (... < ComputedAttributesHandler:102
< *:113 < BaseDataHandler:27 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < ExtendedObjectDecoder:64 < ...)

Anton?

Anton Tananaev4 years ago

Attribute batteryLevel is missing.

Dan Dyse4 years ago

Yeah, this is what the message says, I can read.
I thought this is a Traccar system attribute which can be used in expressions ... if not - how come this still works?

Anton Tananaev4 years ago

It can be used if it's present in the message. I guess it works because some messages have it.

Dan Dyse4 years ago

What's the name of the attribute in the State window showing the battery level? Can it be used in expressions?

Anton Tananaev4 years ago

That is the name.

Dan Dyse4 years ago

You say the name is "batteryLevel". But the log says that it's undefined. Still the value is shown in status windows. And the expression somehow works. You say it's missing the attribute "batteryLevel". What am I getting wrong here? Come on Anton, please be a bit more helpful.

Anton Tananaev4 years ago

Please read my previous comment more carefully. But that's just a guess because you haven't really provided enough information to verify it.

Dan Dyse4 years ago

It seems it is not just me having diffculties understanding how to achieve rather simple things. Could you please give a full example how to do this:
A computed attribute that checks the battery level of the device and raises a notification when the level drops below a given value (e.g. 50). Everyone could learn from such a simple example instead of trying around, asking stupid questions over and over again. I can imagine you are annoyed of answering these questions. Please help.
Thank you.

Anton Tananaev4 years ago

I would use something like this:

batteryLevel ? (batteryLevel < 62 ? "lowBattery" : null) : null
Frank Meier4 years ago

Unfortunately no success here - LowBattery is not working; no notification at all.
Other notifications are working propertly (e.g. Device Online / Offline). Is there somewhere a logfile where I can get more information?

Computed Attribute seems to work...