Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use sensor battery status to give to homekit #26

Open
tvillingett opened this issue Nov 2, 2016 · 2 comments
Open

use sensor battery status to give to homekit #26

tvillingett opened this issue Nov 2, 2016 · 2 comments

Comments

@tvillingett
Copy link
Contributor

From the API

The battery status is now also included in the sensor/info and sensors/list API call. Possible values are:
0-100 - percentage left, if the sensor reports this
253 - battery ok
254 - battery status unknown (not reported by this sensor type, or not decoded)
255 - battery low

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)

@mifi
Copy link
Collaborator

mifi commented Nov 3, 2016

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);
                    });
                });
            }

@dezral
Copy link

dezral commented Nov 28, 2017

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
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants