staromeste / homebridge-http-advanced-accessory

Supports all devices on HomeBridge Platform / Bridges devices to http
Apache License 2.0
67 stars 23 forks source link

How to get BatteryService level? #42

Open korgoth opened 2 years ago

korgoth commented 2 years ago

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 commented 2 years ago

I didn’t check but maybe it’s an optional Characteristic and you should add it to the list optionCharacteristic.GuidoIl giorno 25 ott 2022, alle ore 22:18, korgoth @.***> ha scritto: Hello, i have the following config: { "accessory": "HttpAdvancedAccessory", "name": "Nuki Battery", "service": "BatteryService", "debug": true, "urls": { "getBatteryLevel": { "url": "", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.state.batteryCharge", "indedx": 0 } } ] }, "getStatusLowBattery": { "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?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

korgoth commented 2 years ago

@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!

staromeste commented 2 years ago

You might want to try the Eve app. Not all features are supported by the native Home app.GuidoIl giorno 25 ott 2022, alle ore 23:52, korgoth @.***> ha scritto: @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!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>