@@ -5,46 +5,27 @@ import (
5
5
"os"
6
6
"strconv"
7
7
8
- "github.com/brutella/hc"
9
- "github.com/brutella/hc/accessory"
8
+ "github.com/mastery-la/autodidact/pkg/protocol/homekit"
10
9
11
10
"github.com/mastery-la/autodidact/pkg/bridge"
12
11
13
12
"github.com/joho/godotenv"
14
13
)
15
14
16
15
func main () {
17
- info := accessory.Info {
18
- Name : "Thermostat" ,
19
- SerialNumber : "TCAS3AS14AS3" ,
20
- Manufacturer : "Honeywell" ,
21
- Model : "TCC01" ,
22
- }
23
- acc := accessory .NewThermostat (info , 22.0 , 15.0 , 32.0 , 1.0 )
24
-
25
- config := hc.Config {Pin : "12344321" , Port : "12345" , StoragePath : "./.db" }
26
- t , err := hc .NewIPTransport (config , acc .Accessory )
27
- if err != nil {
28
- log .Panic (err )
29
- }
30
-
31
- bridge , err := getBridge ()
16
+ honeywell , err := getHoneywellThermostat ()
32
17
if err != nil {
33
18
log .Panic (err )
34
19
}
35
20
36
- acc .Thermostat .TargetTemperature .OnValueRemoteUpdate (func (temp float64 ) {
37
- bridge .Thermostat .Thermostat .TargetTemperature .SetValue (temp )
38
- })
21
+ transport := homekit .New ("12344321" , "12345" , "./db" )
39
22
40
- hc .OnTermination (func () {
41
- <- t .Stop ()
42
- })
23
+ transport .AddAccessory (homekit .NewThermostat (honeywell .Thermostat ))
43
24
44
- t .Start ()
25
+ transport .Start ()
45
26
}
46
27
47
- func getBridge () (* bridge.HoneywellThermostat , error ) {
28
+ func getHoneywellThermostat () (* bridge.HoneywellThermostat , error ) {
48
29
err := godotenv .Load ()
49
30
if err != nil {
50
31
log .Fatal ("Error loading .env file" )
0 commit comments