Skip to content

Commit

Permalink
Update hub-main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Jan 22, 2023
1 parent e66d164 commit 8d0964c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/device/hub-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ export default class {
this.log.error(JSON.stringify(subdevice));
if (subdevice.ms100) {
// Apply the update to the accessory
subAcc.control.applyUpdate({
temperature: subdevice.ms100?.latestTemperature,
humidity: subdevice.ms100?.latestHumidity,
voltage: subdevice.ms100?.voltage,
});
const update = {};
if (hasProperty(subdevice.ms100, 'latestTemperature')) {
update.temperature = subdevice.ms100.latestTemperature;
}
if (hasProperty(subdevice.ms100, 'latestHumidity')) {
update.humidity = subdevice.ms100.latestHumidity;
}
if (hasProperty(subdevice.ms100, 'voltage')) {
update.voltage = subdevice.ms100.voltage;
}
subAcc.control.applyUpdate(update);
} else if (subdevice.status === 2) {
// If the status is 2 then has been reported offline - report a battery of 0
subAcc.control.applyUpdate({ voltage: 0 });
Expand Down

0 comments on commit 8d0964c

Please sign in to comment.