Skip to content

Commit

Permalink
feat: only show the current production
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Oct 31, 2023
1 parent 648263f commit 3c71591
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
15 changes: 0 additions & 15 deletions accessories.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,3 @@ func NewInverterSensor(info accessory.Info) *Inverter {

return &a
}

type Production struct {
*accessory.A
Light *service.LightSensor
}

func NewProduction(info accessory.Info) *Production {
a := Production{}
a.A = accessory.New(info, accessory.TypeSensor)

a.Light = service.NewLightSensor()
a.AddS(a.Light.S)

return &a
}
19 changes: 2 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,8 @@ func main() {
log.Fatal("failed to create client", "err", err)
}

bridge := accessory.NewBridge(accessory.Info{
Name: "Solarman Bridge",
})

inverter := NewInverterSensor(accessory.Info{
Name: "Inverter",
})

daily := NewProduction(accessory.Info{
Name: "Daily kWh",
})

cumulative := NewProduction(accessory.Info{
Name: "Cumulative kWh",
Name: "Solarman Inverter",
})

updateSensors := func() {
Expand All @@ -81,9 +69,6 @@ func main() {

inverter.Light.CurrentAmbientLightLevel.SetMaxValue(rated)
inverter.Light.CurrentAmbientLightLevel.SetValue(output)

daily.Light.CurrentAmbientLightLevel.SetValue(get(data, "Etdy_ge1"))
cumulative.Light.CurrentAmbientLightLevel.SetValue(get(data, "Et_ge0"))
}

go func() {
Expand All @@ -94,7 +79,7 @@ func main() {
}
}()

server, err := hap.NewServer(fs, bridge.A, inverter.A, daily.A, cumulative.A)
server, err := hap.NewServer(fs, inverter.A)
if err != nil {
log.Fatal("fail to start server", "error", err)
}
Expand Down

0 comments on commit 3c71591

Please sign in to comment.