Skip to content

Commit

Permalink
fix: don't create batteryPercentage if a device has no battery status
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Nov 18, 2019
1 parent 381fe29 commit d891e64
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/iobroker-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,13 @@ export async function extendDevice(accessory: Accessory) {
accessory.deviceInfo.power === PowerSources.InternalBattery ||
accessory.deviceInfo.power === PowerSources.ExternalBattery
) {
stateObjs.battery = objectDefinitions.batteryPercentage(
objId,
"device"
);
if (accessory.deviceInfo.battery != undefined) {
// Some 3rd party devices send no battery info
stateObjs.battery = objectDefinitions.batteryPercentage(
objId,
"device"
);
}
}

if (accessory.type === AccessoryTypes.blind) {
Expand Down

0 comments on commit d891e64

Please sign in to comment.