Open tvillingett opened 7 years ago
I have no sensor device to test with and I don't know the format of the getSensorInfo response so I wouldn't know how to implement that, although it should be quite simple yes:
something along the lines:
if (cx instanceof Characteristic.BatteryLevel) {
cx.on('get', (callback) => {
TelldusLive.getSensorInfo(this.device, (err, device) => {
if (err) return callback(err);
const val = device.DONTKNOWWHATSHERE;
// TODO TRANSFORM VALUE TO 0-100
this.log("Battery sensor " + device.name + " [" + val + "]");
callback(false, val);
});
});
}
Does this help ? ;-)
devices/list: { "id": 15, "methods": 0, "name": "R\u00f8galarm", "state": 2, "statevalue": "", "type": "device" },
device/info: { "id": 15, "methods": 0, "model": "n/a", "name": "R\u00f8galarm", "protocol": "zwave", "state": 2, "statevalue": "", "type": "device" }
sensor/info: { "data": [ { "name": "temp", "scale": 0, "value": 23.0 } ], "id": 15, "model": "n/a", "name": "R\u00f8galarm", "protocol": "zwave", "sensorId": 15 }
sensors/list: { "battery": 100, "id": 15, "model": "n/a", "name": "R\u00f8galarm", "novalues": true, "protocol": "zwave", "sensorId": 15 },
From the API
with no batteryinfo:
{"id":"9044149","name":"Garage inne","lastUpdated":1478118807,"ignored":0,"client":"130828","clientName":"Torodd1","online":"1","editable":1,"battery":254,"keepHistory":0,"protocol":"fineoffset","model":"temperaturehumidity","sensorId":"231"}
with battery OK
{"id":"7877912","name":"Utetemp norrsida","lastUpdated":1478118860,"ignored":0,"client":"130828","clientName":"Torodd1","online":"1","editable":1,"battery":253,"keepHistory":0,"protocol":"oregon","model":"EA4C","sensorId":"130"},
in homekit set StatusLowBattery = 0
and with "battery":255
set StatusLowBattery = 1
Otherwise with 0-100 % use set low battery at maybe 5% ? (because the temperaturesensor in homekit don't support percentage, only ok or low battery)