Script for battery testing

Support for our english speaking visitors

Moderator: Co-Administratoren

Antworten
chercheur
Beiträge: 38
Registriert: 13.10.2015, 17:50
Hat sich bedankt: 1 Mal

Script for battery testing

Beitrag von chercheur » 06.11.2015, 17:55

Hello,

I use the following script for testing all batteries of my house (Homematic CCU2).
Unfortunately it always reports "batteries OK" even if 1 of my device is reported as "low battery" when checking it directly (or less than 1.5v).

Would you have an idea ?

Tx

var myAssembly = dom.GetObject("SurBatteries");
var previousTest = dom.GetObject("Low Batteries").Variable();
string itemID;
string text = "";
string stdout;
string stderr;
integer counter = 0;

foreach(itemID, myAssembly.EnumUsedIDs())
{
var item = dom.GetObject(itemID);
var device = dom.GetObject(item.Device());
var interface = dom.GetObject(item.Interface());

string interface_name = interface.Name();
string device_address = device.Address();
device_address = device_address.StrValueByIndex(":", 0);

string channel_name = interface_name # "." # device_address # ":0.LOWBAT";
var channel = dom.GetObject(channel_name);

if ( (channel.State() == true) && (channel.Value() == true) )
{
if ( counter == 0 )
{
text = item.Name();
}
else
{
text = text # ", " # item.Name();
}
}
counter = counter + 1;
}
if ( text == "" )
{
text = "Batteries OK";
dom.GetObject("Low Batteries").State(text);
}
else
{
dom.GetObject("Low Batteries").State(text);
if ( text != previousTest )
{
system.Exec("/etc/config/addons/email/email 06", &stdout, &stderr);
}
}

blueznl
Beiträge: 109
Registriert: 29.11.2014, 18:09
Danksagung erhalten: 1 Mal

Re: Script for battery testing

Beitrag von blueznl » 24.07.2016, 14:16

Did you ever get this to work?

I couldn't get the battery checks to work from the web interface either. I haven't dabbled in my own scripts yet. (I think I'm stupid, can't seem to figure out how to upload my own scripts.)

Antworten

Zurück zu „HomeMatic - english“