Skip to content

Commit

Permalink
Work in progress port to new HA. Doesn't build
Browse files Browse the repository at this point in the history
  • Loading branch information
njpatel committed Apr 21, 2016
1 parent d40c675 commit 09999f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
37 changes: 18 additions & 19 deletions src/hivekit/main.go
Expand Up @@ -8,9 +8,8 @@ import (

"hive"

"github.com/brutella/hc/accessory"
"github.com/brutella/hc/hap"
"github.com/brutella/hc/model"
"github.com/brutella/hc/model/accessory"
"github.com/brutella/log"
)

Expand All @@ -24,9 +23,9 @@ var (

hiveHome *hive.Hive

thermostat model.Thermostat
hotWaterSwitch model.Switch
heatingBoostSwitch model.Switch
thermostat accessory.Thermostat
hotWaterSwitch accessory.Switch
heatingBoostSwitch accessory.Switch
transport hap.Transport
accessoryUpdate sync.Mutex
)
Expand All @@ -52,30 +51,30 @@ func main() {
}

func setupHomeKit() {
aInfo := model.Info{
aInfo := accessory.Info{
Name: "Hive Bridge",
Manufacturer: "British Gas PLC",
}
a := accessory.New(aInfo)
a := accessory.New(aInfo, accessory.TypeBridge)

tInfo := model.Info{
tInfo := accessory.Info{
Name: "Heating",
Manufacturer: "British Gas PLC",
}
t := accessory.NewThermostat(tInfo, 20.0, hive.MinTemp, hive.MaxTemp, 0.5)
t.OnTargetTempChange(targetTempChangeRequest)
t.OnTargetModeChange(targetModeChangeRequest)
t.Thermostat.TargetTemperature.OnValueUpdate(targetTempChangeRequest)
t.Thermostat.OnTargetModeChange(targetModeChangeRequest)
thermostat = t

bInfo := model.Info{
bInfo := accessory.Info{
Name: "Heating Boost",
Manufacturer: "British Gas PLC",
}
b := accessory.NewSwitch(bInfo)
b.OnStateChanged(heatingBoostStateChangeRequest)
heatingBoostSwitch = b

sInfo := model.Info{
sInfo := accessory.Info{
Name: "Hot Water",
Manufacturer: "British Gas PLC",
}
Expand Down Expand Up @@ -121,16 +120,16 @@ func setupHive() {
thermostat.SetTemperature(state.CurrentTemp)
thermostat.SetTargetTemperature(state.TargetTemp)
thermostat.SetMode(modeForHiveMode(state.CurrentHeatingMode))
thermostat.SetMode(model.HeatCoolModeAuto)
thermostat.SetMode(accessory.HeatCoolModeAuto)
thermostat.SetTargetMode(modeForHiveMode(state.TargetHeatingMode))
})
}

func modeForHiveMode(mode hive.HeatCoolMode) model.HeatCoolModeType {
func modeForHiveMode(mode hive.HeatCoolMode) accessory.HeatCoolModeType {
if mode == hive.HeatCoolModeOff {
return model.HeatCoolModeOff
return accessory.HeatCoolModeOff
}
return model.HeatCoolModeAuto
return accessory.HeatCoolModeAuto
}

func hotWaterStateChangeRequest(on bool) {
Expand All @@ -140,14 +139,14 @@ func hotWaterStateChangeRequest(on bool) {
}
}

func targetTempChangeRequest(temp float64) {
err := hiveHome.SetTargetTemp(temp)
func targetTempChangeRequest(c *Characteristic, newValue, oldValue interface{}) {
err := hiveHome.SetTargetTemp(float64(temp))
if err != nil {
log.Printf("[WARN] Unable to set target temperature: %v\n", err)
}
}

func targetModeChangeRequest(hcMode model.HeatCoolModeType) {
func targetModeChangeRequest(hcMode accessory.HeatCoolModeType) {
log.Printf("[Warn] Changing target mode is unsupported at this time")
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/manifest
Expand Up @@ -10,7 +10,7 @@
{
"importpath": "github.com/brutella/hc",
"repository": "https://github.com/brutella/hc",
"revision": "6f71e9ea5c63315666cb95b8a4756a5718d39ac4",
"revision": "2fe2d89cb73752a6494c486a5b058cf638b335d2",
"branch": "master"
},
{
Expand Down

0 comments on commit 09999f6

Please sign in to comment.