bessarabov / mac2mqtt

View and control some aspects of macOS computer via MQTT
MIT License
68 stars 23 forks source link

Crashes when trying to get battery state of mac mini #8

Open wormiedk opened 2 years ago

wormiedk commented 2 years ago
panic: runtime error: index out of range [1] with length 0

goroutine 32 [running]:
main.getBatteryChargePercent(0xc000049ef0, 0x1319948)
        /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:284 +0x115
main.updateBattery(0x137cc20, 0xc000198000)
        /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:290 +0x85
main.main.func1(0xc00013a370, 0x137cc20, 0xc000198000, 0xc00013a3c0)
        /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:318 +0xe5
created by main.main
        /Users/bessarabov/Dropbox/git/mac2mqtt/mac2mqtt.go:310 +0x1d0
balzreber commented 1 year ago

same error here

callumgare commented 1 year ago

This can be fixed using this PR https://github.com/bessarabov/mac2mqtt/pull/17 and building a new binary by following the process in https://github.com/bessarabov/mac2mqtt/pull/9. Hopefully these changes will be merged soon.