Skip to content

Commit

Permalink
Handle get/set callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
longzheng committed Nov 9, 2021
1 parent 493464a commit aa9aa09
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/fronius-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,51 @@ export class FroniusAccessory implements AccessoryPlugin {
this.lightbulbService = new hap.Service.Lightbulb(this.name);
this.lightsensorService = new hap.Service.LightSensor(this.name);

this.lightbulbService
.getCharacteristic(hap.Characteristic.On)
.onGet(() => {
if (this.onValue instanceof Error) {
return null;
}

return this.onValue;
})
.onSet(() => {
if (this.onValue instanceof Error) {
return null;
}

return this.onValue;
});

this.lightbulbService
.getCharacteristic(hap.Characteristic.Brightness)
.onGet(() => {
if (this.brightnessValue instanceof Error) {
return null;
}

return this.brightnessValue;
})
.onSet(() => {
if (this.brightnessValue instanceof Error) {
return null;
}

return this.brightnessValue;
});

this.lightsensorService
.getCharacteristic(hap.Characteristic.CurrentAmbientLightLevel)
.setProps({
minValue: 0, // allow minimum lux to be 0, otherwise defaults to 0.0001
})
.onGet(() => {
if (this.luxValue instanceof Error) {
return null;
}

return this.luxValue;
});

this.informationService = new hap.Service.AccessoryInformation()
Expand Down

0 comments on commit aa9aa09

Please sign in to comment.