-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinverter.go
68 lines (52 loc) · 1.41 KB
/
inverter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package symo
import (
"github.com/brutella/hc/accessory"
"github.com/brutella/hc/characteristic"
"github.com/brutella/hc/service"
)
type Accessory struct {
*accessory.Accessory
Inverter *Service
}
func NewAccessory(info accessory.Info) *Accessory {
a := accessory.New(info, accessory.TypeOther)
svc := NewService(info.Name)
a.AddService(svc.Service)
return &Accessory{a, svc}
}
const typeInverter = "14FA9D31-FC94-4F98-B00D-4AE878523748" // Parce Measurement Service
type Service struct {
*service.Service
Name *characteristic.Name
Current *Power
Today *Power
Year *Power
Total *Power
}
func NewService(name string) *Service {
nameChar := characteristic.NewName()
nameChar.SetValue(name)
pow := NewPower(0)
pow.Type = TypeTotalPower
pow.Unit = "W"
pow.Description = "Leistung"
today := NewPower(0)
today.Type = TypeTotalPower
today.Unit = "Wh"
today.Description = "Heute"
year := NewPower(0)
year.Type = TypeTotalPower
year.Unit = "Wh"
year.Description = "Dieses Jahr"
total := NewPower(0)
total.Type = TypeTotalPower
total.Unit = "Wh"
total.Description = "Gesamt"
svc := service.New(typeInverter)
svc.AddCharacteristic(pow.Characteristic)
svc.AddCharacteristic(today.Characteristic)
svc.AddCharacteristic(year.Characteristic)
svc.AddCharacteristic(total.Characteristic)
svc.AddCharacteristic(nameChar.Characteristic)
return &Service{svc, nameChar, pow, today, year, total}
}