NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
412 stars 52 forks source link

[Bug]: BatteryLevel is not displaying properly #485

Closed Jacksonbm1 closed 2 years ago

Jacksonbm1 commented 2 years ago

NRCHKB Plugin Version

1.4.3

Node JS Version

v14.17.1

NPM Version

8.3.2

Node-RED Version

v1.3.1

Operating System

Raspbian

What happened?

Basically, I've added a battery service and it's displaying as a tile that's not supported (I can click on it and see what the values are, but it doesn't work as you'd expect). I would expect to see the a sensor value, but instead I see a tile. See pictures below.

What my dashboard looks like:

IMG_5057

What the tile looks like:

IMG_5058

How I'd expect it to look:

8mfb3auvlyu51

How to reproduce?

Run my code or create and populate a battery service.

code: [{"id":"8b349b7f.134c28","type":"debug","z":"c99697c1.464008","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":560,"wires":[]},{"id":"4e8f88b.28d8678","type":"homekit-service","z":"c99697c1.464008","isParent":true,"hostType":"0","bridge":"6f2f3dc2.0f4384","accessoryId":"","parentService":"","name":"sb-desk-battery","serviceName":"Battery","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":920,"y":560,"wires":[["8b349b7f.134c28"],[]]},{"id":"dba4abed.6f3bf8","type":"change","z":"c99697c1.464008","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.BatteryLevel","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":540,"wires":[["4e8f88b.28d8678"]]},{"id":"1f8e4157.24154f","type":"inject","z":"c99697c1.464008","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"BatteryLevel\":100}","payloadType":"json","x":710,"y":580,"wires":[["4e8f88b.28d8678"]]},{"id":"fa6b63a0.4f0db","type":"inject","z":"c99697c1.464008","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"foo\":\"bar\"}","payloadType":"json","x":730,"y":500,"wires":[["4e8f88b.28d8678"]]},{"id":"dffd6f18.67e4f","type":"change","z":"c99697c1.464008","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":540,"wires":[["dba4abed.6f3bf8"]]},{"id":"20bfdb82.b64dc4","type":"poll-state","z":"c99697c1.464008","name":"","server":"f26a3c35.08253","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalUnits":"seconds","outputinitially":true,"outputonchanged":true,"entity_id":"sensor.desk_down_battery","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":270,"y":540,"wires":[["dffd6f18.67e4f"]]},{"id":"6f2f3dc2.0f4384","type":"homekit-bridge","bridgeName":"node-red-hk-4","pinCode":"000-00-000","port":"","advertiser":"bonjour-hap","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"f26a3c35.08253","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Expected behavior:

8mfb3auvlyu51

Additional comments?

This is my first time using this node, so I may very well be misunderstanding something. I also redacted the homekit code from the copied flow

Relevant log output

No response

caitken-com commented 2 years ago

Hi, @Jacksonbm1. Battery service can only be used as a child service to another service.

https://nrchkb.github.io/wiki/service/battery/

Jacksonbm1 commented 2 years ago

I also just noticed that the indicator in the "expected" image is actually a "low battery" indicator. Not intuitive, but I understand why it's happening. Thank you

TheNON75 commented 2 years ago

Without any jokes: whether it is good or not to have a battery working properly as child service only, this is by design made by Apple. In case you would like to have it differently, you can try to write them (and possibly join a group of thousands of users demanding the same) and request a change to it. While fully understanding that a standalone battery does make sense these days, we cannot change this.

Thanks for your understanding

Jacksonbm1 commented 2 years ago

Yeah I understand. That wasn't directed at you, but more a general thought.