rgavril / homebridge-xiaomi-air-purifier3

Homebridge plugin for controlling Xiaomi Air Purifier 3/3H
46 stars 7 forks source link

Add temp & humidity sensors #1

Closed danekszy closed 4 years ago

danekszy commented 4 years ago

Adds basic functionality for temperature and humidity sensors in AP3. LMK know if there's something to be fixed here, happy to change accordingly. ;) Cheers!

rgavril commented 4 years ago

Thanks for thanking your time to help, great work!

I've started this as a personal project and humidity & temp sensors were not useful for me at the moment but now that the project is public I'm sure other users will appreciate having them available.

There are some small changes that I wand you to implement before merging this:

  1. Because the temperature and humidity sensors will be active only when the device is powered on, you should also update Characteristic.StatusActive of this new services in the updateStatusActive() method.

        if (this.miotPurifier.get('power') == true) {
            .....
            this.temperatureService.setCharacteristic(Characteristic.StatusActive, true);
            this.humidityService.setCharacteristic(Characteristic.StatusActive, true);
        } else {
            ....
            this.temperatureService.setCharacteristic(Characteristic.StatusActive, true);
            this.humidityService.setCharacteristic(Characteristic.StatusActive, true);
        }
  2. I would also apreciate changing the name of the services to temperatureSensorService and humiditySensorService to better reflect their use and to keep the same naming convention as the other services.

Tanote650 commented 4 years ago

Many thanks for the useful addition!

danekszy commented 4 years ago

Hey @rgavril, thanks for taking care of that! Also, thanks for making this module in the first place. 😉 Cheers!