sean9keenan / homebridge-bigAssFans

A Homebridge plugin for Big Ass Fans
MIT License
28 stars 15 forks source link

properly process occupancy value #32

Closed barkmadley closed 2 years ago

barkmadley commented 4 years ago

I found using this example program that the occupancy value being stored is not the same value that is passed to the update callback:

var bigApi = require("BigAssFansAPI");

const fm = new bigApi.FanMaster(3);
fm.onFanConnection = function(fan) {
  console.log(fan.name, 'isOccupied pre-update', fan.sensor._isOccupied);
  fan.sensor.update('isOccupied', function(err, value) {
    console.log(fan.name, 'isOccupied update', fan.sensor._isOccupied, err, value);
  });
};
second bedroom isOccupied pre-update undefined
Living Room Fan isOccupied pre-update undefined
main bedroom isOccupied pre-update undefined
second bedroom isOccupied update true null OCCUPIED
Living Room Fan isOccupied update false null UNOCCUPIED
main bedroom isOccupied update false null UNOCCUPIED

This implies that either the occupancyGetWrapper function is not implemented correctly or the property update function needs to use the subProperty value, rather than the raw value: https://github.com/sean9keenan/BigAssFansAPI/blob/3e8261577e0c76210638e9471af8387444c7e900/BigAssApi.js#L149-L150

sean9keenan commented 2 years ago

Sorry that I didn't see this / merge it in – This is great!