Closed p000 closed 11 months ago
If you need specific characteristics for an accessory, you can add them yourself. For example if you need the current humidity for a thermostat, you can create your custom thermostat service and add the humidity as a new property.
type CustomThermostat struct {
*service.Thermostat
CurrentHumidity *characteristic.CurrentRelativeHumidity
}
func NewCustomThermostat() *CustomThermostat {
return &CustomThermostat{
Thermostat: service.NewThermostat(),
CurrentHumidity: characteristic.NewCurrentRelativeHumidity(),
}
}
func main() {
info := accessory.Info{ Name: "Thermostat" }
a := accessory.New(info, accessory.TypeThermostat)
// Add your custom thermostat service
thermostat := NewCustomThermostat()
a.AddS(thermostat.S)
// Update the relative humidity
thermostat.CurrentHumidity.SetValue(60)
...
}
@brutella - Thanks for the sample. It worked and you are awesome 👍🏼 😍
Please let me know if this feature to be supported.
I can try contribute as well, with your guidance.