Introduce constructors for ExposeMapping

This should allow the ExposeMapping struct to be changed without
constantly impacting its callers.
This commit is contained in:
Darell Tan
2024-11-24 15:25:17 +08:00
parent b11ab07fbb
commit d4daef7bce
8 changed files with 22 additions and 12 deletions

View File

@@ -31,13 +31,13 @@ func createClimateServices(dev *Device) (byte, []*service.S, []*ExposeMapping, e
s.CurrentTemperature.SetStepValue(0.01)
svcs = append(svcs, s.S)
exposes = append(exposes, &ExposeMapping{&exp, s.CurrentTemperature.C, nil})
exposes = append(exposes, NewExposeMapping(&exp, s.CurrentTemperature.C))
case exp.Name == "humidity":
s := service.NewHumiditySensor()
s.CurrentRelativeHumidity.SetStepValue(0.01) // ditto, but 1% increments
svcs = append(svcs, s.S)
exposes = append(exposes, &ExposeMapping{&exp, s.CurrentRelativeHumidity.C, nil})
exposes = append(exposes, NewExposeMapping(&exp, s.CurrentRelativeHumidity.C))
case exp.Name == "pressure":
// TODO looks like pressure is not standard in HomeKit