staromeste/homebridge-http-advanced-accessory

How to get BatteryService level?

Opened this issue · 3 comments

Hello,

i have the following config:

{ "accessory": "HttpAdvancedAccessory", "name": "Nuki Battery", "service": "BatteryService", "debug": true, "urls": { "getBatteryLevel": { "url": "<JSON STATUS URL>", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.state.batteryCharge", "indedx": 0 } } ] }, "getStatusLowBattery": { "url": "<JSON STATUS URL>", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.state.batteryCritical", "index": 0 } }, { "type": "static", "parameters": { "mapping": { "false": "0", "true": "1" } } } ] } } }

My ultimate goal is to expose a "sensor"(?!) to homekit which has my battery level and also is "triggered" based on weather the battery is low or not.

The part with the sensor being triggered seems to be working. All mappings are correct the the value is resolved and the sensor displays as triggered/not triggered in the homebridge UI (havnt added that to home app yet).

However the accessory that i see in my homebridge UI only displays 0% (not the actual level).
Furthermore in the debug log i can see that http-advanced-accessory is making only one request to the URL (ant it seems to be triggered by the "getStatusLowBattery" url. How can i make it also read the "getBatteryLevel" url and apply the result?

Is the key not "getBatteryLevel"?

Where can i see what "characteristics" does each service support?

@staromeste You seem to be correct! When i added BatteryLevel to the optionCharacteristic array eveyrthing is set correctly in Homebridge UI (correct percentage and correct "trigger" state of the accessory)

Now on to the second problem - when i add this to the Home app it just says "This accessory is not currently supported by the Home app"

I can tap on it to view details and i do see the battery level. However i cant add it to any automations. Any ideas or is this a dead end!