From 976af973bc781adf07b480841602d23be2346edf Mon Sep 17 00:00:00 2001 From: mestafin Date: Sun, 4 Mar 2018 21:41:12 +0100 Subject: [PATCH 1/4] created fan, heater and window_covering accessories --- accessory/fan.go | 23 +++++++++++++++++++++++ accessory/heater.go | 20 ++++++++++++++++++++ accessory/window_covering.go | 24 ++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 accessory/fan.go create mode 100644 accessory/heater.go create mode 100644 accessory/window_covering.go diff --git a/accessory/fan.go b/accessory/fan.go new file mode 100644 index 00000000..93ae3af3 --- /dev/null +++ b/accessory/fan.go @@ -0,0 +1,23 @@ +// Created by mestafin +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type Fan struct { + *Accessory + Fan *service.Fan +} + +// NewFan returns a fan accessory containing one fan service. +func NewFan(info Info) *Fan { + acc := Fan{} + acc.Accessory = New(info, TypeFan) + acc.Fan = service.NewFan() + + acc.AddService(acc.Fan.Service) + + return &acc +} + diff --git a/accessory/heater.go b/accessory/heater.go new file mode 100644 index 00000000..bef36a3d --- /dev/null +++ b/accessory/heater.go @@ -0,0 +1,20 @@ +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type HeaterCooler struct { + *Accessory + HeaterCooler *service.HeaterCooler +} + +// NewSwitch returns a heater which implements model.Heater. +func NewHeater(info Info) *HeaterCooler { + acc := HeaterCooler{} + acc.Accessory = New(info, TypeHeater) + acc.HeaterCooler = service.NewHeaterCooler() + acc.AddService(acc.HeaterCooler.Service) + + return &acc +} diff --git a/accessory/window_covering.go b/accessory/window_covering.go new file mode 100644 index 00000000..d5a7dc01 --- /dev/null +++ b/accessory/window_covering.go @@ -0,0 +1,24 @@ +// Created by mestafin +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type WindowCovering struct { + *Accessory + + WindowCovering *service.WindowCovering +} + +// NewWindowCovering returns a WindowCovering which implements model.WindowCovering. +func NewWindowCovering(info Info) *WindowCovering { + acc := WindowCovering{} + acc.Accessory = New(info, TypeWindowCovering) + + acc.WindowCovering = service.NewWindowCovering() + + acc.AddService(acc.WindowCovering.Service) + + return &acc +} From ddc062715841f6ec3d84f463422aee2fd843827d Mon Sep 17 00:00:00 2001 From: mestafin Date: Sat, 10 Mar 2018 19:51:26 +0100 Subject: [PATCH 2/4] updated accessories and services for heater_cooler and window_covering --- accessory/{heater.go => heater_cooler.go} | 2 +- service/heater_cooler.go | 6 ++++++ service/window_covering.go | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) rename accessory/{heater.go => heater_cooler.go} (88%) diff --git a/accessory/heater.go b/accessory/heater_cooler.go similarity index 88% rename from accessory/heater.go rename to accessory/heater_cooler.go index bef36a3d..49cb9eae 100644 --- a/accessory/heater.go +++ b/accessory/heater_cooler.go @@ -10,7 +10,7 @@ type HeaterCooler struct { } // NewSwitch returns a heater which implements model.Heater. -func NewHeater(info Info) *HeaterCooler { +func NewHeaterCooler(info Info) *HeaterCooler { acc := HeaterCooler{} acc.Accessory = New(info, TypeHeater) acc.HeaterCooler = service.NewHeaterCooler() diff --git a/service/heater_cooler.go b/service/heater_cooler.go index fabd72fd..d501a26c 100644 --- a/service/heater_cooler.go +++ b/service/heater_cooler.go @@ -1,4 +1,5 @@ // THIS FILE IS AUTO-GENERATED +// Modified by Mestafin package service import ( @@ -14,6 +15,8 @@ type HeaterCooler struct { CurrentHeaterCoolerState *characteristic.CurrentHeaterCoolerState TargetHeaterCoolerState *characteristic.TargetHeaterCoolerState CurrentTemperature *characteristic.CurrentTemperature + // added optional + TargetTemperature *characteristic.TargetTemperature } func NewHeaterCooler() *HeaterCooler { @@ -31,6 +34,9 @@ func NewHeaterCooler() *HeaterCooler { svc.CurrentTemperature = characteristic.NewCurrentTemperature() svc.AddCharacteristic(svc.CurrentTemperature.Characteristic) + // optional + svc.TargetTemperature = characteristic.NewTargetTemperature() + svc.AddCharacteristic(svc.TargetTemperature.Characteristic) return &svc } diff --git a/service/window_covering.go b/service/window_covering.go index 1d1a0810..6f268180 100644 --- a/service/window_covering.go +++ b/service/window_covering.go @@ -13,6 +13,8 @@ type WindowCovering struct { CurrentPosition *characteristic.CurrentPosition TargetPosition *characteristic.TargetPosition PositionState *characteristic.PositionState + // + HoldPosition *characteristic.HoldPosition } func NewWindowCovering() *WindowCovering { @@ -28,5 +30,8 @@ func NewWindowCovering() *WindowCovering { svc.PositionState = characteristic.NewPositionState() svc.AddCharacteristic(svc.PositionState.Characteristic) + svc.HoldPosition = characteristic.NewHoldPosition() + svc.AddCharacteristic(svc.HoldPosition.Characteristic) + return &svc } From d7ddc68f04df9f6a425857365b55e9aae4933e71 Mon Sep 17 00:00:00 2001 From: mestafin Date: Mon, 12 Mar 2018 10:43:11 +0100 Subject: [PATCH 3/4] add / update accessories: fan.go heater_cooler.go window_covering.go update service: heater_cooler, add optional TargetTemperature characteristic --- accessory/fan.go | 2 +- accessory/heater_cooler.go | 1 + accessory/window_covering.go | 1 - service/heater_cooler.go | 8 ++++---- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accessory/fan.go b/accessory/fan.go index 93ae3af3..5c262849 100644 --- a/accessory/fan.go +++ b/accessory/fan.go @@ -1,4 +1,3 @@ -// Created by mestafin package accessory import ( @@ -7,6 +6,7 @@ import ( type Fan struct { *Accessory + Fan *service.Fan } diff --git a/accessory/heater_cooler.go b/accessory/heater_cooler.go index 49cb9eae..c69a38d9 100644 --- a/accessory/heater_cooler.go +++ b/accessory/heater_cooler.go @@ -6,6 +6,7 @@ import ( type HeaterCooler struct { *Accessory + HeaterCooler *service.HeaterCooler } diff --git a/accessory/window_covering.go b/accessory/window_covering.go index d5a7dc01..1850d450 100644 --- a/accessory/window_covering.go +++ b/accessory/window_covering.go @@ -1,4 +1,3 @@ -// Created by mestafin package accessory import ( diff --git a/service/heater_cooler.go b/service/heater_cooler.go index d501a26c..1dfd7626 100644 --- a/service/heater_cooler.go +++ b/service/heater_cooler.go @@ -1,5 +1,5 @@ // THIS FILE IS AUTO-GENERATED -// Modified by Mestafin +// Modified by mestafin package service import ( @@ -15,8 +15,8 @@ type HeaterCooler struct { CurrentHeaterCoolerState *characteristic.CurrentHeaterCoolerState TargetHeaterCoolerState *characteristic.TargetHeaterCoolerState CurrentTemperature *characteristic.CurrentTemperature - // added optional - TargetTemperature *characteristic.TargetTemperature + + TargetTemperature *characteristic.TargetTemperature } func NewHeaterCooler() *HeaterCooler { @@ -34,7 +34,7 @@ func NewHeaterCooler() *HeaterCooler { svc.CurrentTemperature = characteristic.NewCurrentTemperature() svc.AddCharacteristic(svc.CurrentTemperature.Characteristic) - // optional + svc.TargetTemperature = characteristic.NewTargetTemperature() svc.AddCharacteristic(svc.TargetTemperature.Characteristic) From 318d85029c6da78c5ad99342235a4c31a37ce220 Mon Sep 17 00:00:00 2001 From: mestafin Date: Mon, 12 Mar 2018 17:15:04 +0100 Subject: [PATCH 4/4] add / update accessories: fan.go heater_cooler.go window_covering.go update service: heater_cooler - add optional TargetTemperature characteristic window_covering - add optional HoldPosition characteristic --- accessory/fan.go | 23 +++++++++++++++++++++++ accessory/heater_cooler.go | 21 +++++++++++++++++++++ accessory/window_covering.go | 23 +++++++++++++++++++++++ service/heater_cooler.go | 6 ++++++ service/window_covering.go | 5 +++++ 5 files changed, 78 insertions(+) create mode 100644 accessory/fan.go create mode 100644 accessory/heater_cooler.go create mode 100644 accessory/window_covering.go diff --git a/accessory/fan.go b/accessory/fan.go new file mode 100644 index 00000000..5c262849 --- /dev/null +++ b/accessory/fan.go @@ -0,0 +1,23 @@ +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type Fan struct { + *Accessory + + Fan *service.Fan +} + +// NewFan returns a fan accessory containing one fan service. +func NewFan(info Info) *Fan { + acc := Fan{} + acc.Accessory = New(info, TypeFan) + acc.Fan = service.NewFan() + + acc.AddService(acc.Fan.Service) + + return &acc +} + diff --git a/accessory/heater_cooler.go b/accessory/heater_cooler.go new file mode 100644 index 00000000..c69a38d9 --- /dev/null +++ b/accessory/heater_cooler.go @@ -0,0 +1,21 @@ +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type HeaterCooler struct { + *Accessory + + HeaterCooler *service.HeaterCooler +} + +// NewSwitch returns a heater which implements model.Heater. +func NewHeaterCooler(info Info) *HeaterCooler { + acc := HeaterCooler{} + acc.Accessory = New(info, TypeHeater) + acc.HeaterCooler = service.NewHeaterCooler() + acc.AddService(acc.HeaterCooler.Service) + + return &acc +} diff --git a/accessory/window_covering.go b/accessory/window_covering.go new file mode 100644 index 00000000..1850d450 --- /dev/null +++ b/accessory/window_covering.go @@ -0,0 +1,23 @@ +package accessory + +import ( + "github.com/brutella/hc/service" +) + +type WindowCovering struct { + *Accessory + + WindowCovering *service.WindowCovering +} + +// NewWindowCovering returns a WindowCovering which implements model.WindowCovering. +func NewWindowCovering(info Info) *WindowCovering { + acc := WindowCovering{} + acc.Accessory = New(info, TypeWindowCovering) + + acc.WindowCovering = service.NewWindowCovering() + + acc.AddService(acc.WindowCovering.Service) + + return &acc +} diff --git a/service/heater_cooler.go b/service/heater_cooler.go index fabd72fd..1dfd7626 100644 --- a/service/heater_cooler.go +++ b/service/heater_cooler.go @@ -1,4 +1,5 @@ // THIS FILE IS AUTO-GENERATED +// Modified by mestafin package service import ( @@ -14,6 +15,8 @@ type HeaterCooler struct { CurrentHeaterCoolerState *characteristic.CurrentHeaterCoolerState TargetHeaterCoolerState *characteristic.TargetHeaterCoolerState CurrentTemperature *characteristic.CurrentTemperature + + TargetTemperature *characteristic.TargetTemperature } func NewHeaterCooler() *HeaterCooler { @@ -32,5 +35,8 @@ func NewHeaterCooler() *HeaterCooler { svc.CurrentTemperature = characteristic.NewCurrentTemperature() svc.AddCharacteristic(svc.CurrentTemperature.Characteristic) + svc.TargetTemperature = characteristic.NewTargetTemperature() + svc.AddCharacteristic(svc.TargetTemperature.Characteristic) + return &svc } diff --git a/service/window_covering.go b/service/window_covering.go index 1d1a0810..6f268180 100644 --- a/service/window_covering.go +++ b/service/window_covering.go @@ -13,6 +13,8 @@ type WindowCovering struct { CurrentPosition *characteristic.CurrentPosition TargetPosition *characteristic.TargetPosition PositionState *characteristic.PositionState + // + HoldPosition *characteristic.HoldPosition } func NewWindowCovering() *WindowCovering { @@ -28,5 +30,8 @@ func NewWindowCovering() *WindowCovering { svc.PositionState = characteristic.NewPositionState() svc.AddCharacteristic(svc.PositionState.Characteristic) + svc.HoldPosition = characteristic.NewHoldPosition() + svc.AddCharacteristic(svc.HoldPosition.Characteristic) + return &svc }