Skip to content

Commit

Permalink
fix: air purifier service name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin committed Jan 28, 2024
1 parent 4faca7f commit 6a7937f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/devices/AirPurifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default class AirPurifier extends baseDevice {
// get the service if it exists, otherwise create a new service
// you can create multiple services for each accessory
this.serviceAirPurifier = accessory.getService(AirPurifier);
if (this.serviceAirPurifier === undefined) {
this.serviceAirPurifier = accessory.addService(AirPurifier, 'Air Purifier');
if (!this.serviceAirPurifier) {
this.serviceAirPurifier = accessory.addService(AirPurifier, 'Air Purifier', 'Air Purifier');
this.serviceAirPurifier.addOptionalCharacteristic(Characteristic.ConfiguredName);
this.serviceAirPurifier.updateCharacteristic(Characteristic.ConfiguredName, 'Air Purifier');
}
Expand Down Expand Up @@ -69,7 +69,7 @@ export default class AirPurifier extends baseDevice {
this.serviceAirQuality = accessory.getService(AirQualitySensor) || accessory.addService(AirQualitySensor);

this.serviceLight = accessory.getService(Lightbulb);
if (this.serviceLight === undefined) {
if (!this.serviceLight) {
this.serviceLight = accessory.addService(Lightbulb, device.name + ' - Light');
this.serviceLight.addOptionalCharacteristic(Characteristic.ConfiguredName);
this.serviceLight.updateCharacteristic(Characteristic.ConfiguredName, 'Light');
Expand All @@ -79,8 +79,8 @@ export default class AirPurifier extends baseDevice {

if (this.Status.filterMaxTime) {
this.serviceFilterMaintenance = accessory.getService(FilterMaintenance);
if (this.serviceFilterMaintenance === undefined) {
this.serviceFilterMaintenance = accessory.addService(FilterMaintenance);
if (!this.serviceFilterMaintenance) {
this.serviceFilterMaintenance = accessory.addService(FilterMaintenance, 'Filter Maintenance', 'Filter Maintenance');
this.serviceFilterMaintenance.addOptionalCharacteristic(Characteristic.ConfiguredName);
this.serviceFilterMaintenance.updateCharacteristic(Characteristic.ConfiguredName, 'Filter Maintenance');
}
Expand All @@ -91,7 +91,7 @@ export default class AirPurifier extends baseDevice {

this.serviceAirFastMode = accessory.getService('Air Fast');
if (this.config.air_fast_mode) {
if (this.serviceAirFastMode === undefined) {
if (!this.serviceAirFastMode) {
this.serviceAirFastMode = accessory.addService(Switch, 'Air Fast', 'Air Fast');
this.serviceAirFastMode.addOptionalCharacteristic(Characteristic.ConfiguredName);
this.serviceAirFastMode.updateCharacteristic(Characteristic.ConfiguredName, 'Air Fast');
Expand Down

0 comments on commit 6a7937f

Please sign in to comment.