Skip to content
Snippets Groups Projects
Commit 1547f7d3 authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Cleanup some code

Switch to switch.. (go syntax)
parent 500466e9
No related branches found
No related tags found
No related merge requests found
...@@ -9,10 +9,10 @@ import ( ...@@ -9,10 +9,10 @@ import (
) )
type Gateway struct { type Gateway struct {
client MQTT.Client
engine *xaal.Engine engine *xaal.Engine
devices map[string]*Z2MDevice devices map[string]*Z2MDevice
baseAddr uuid.UUID baseAddr uuid.UUID
client MQTT.Client
} }
var ( var (
......
...@@ -166,9 +166,10 @@ func (dev *PowerRelay) update(payload map[string]interface{}) { ...@@ -166,9 +166,10 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
value, exists := payload[dev.Property].(string) value, exists := payload[dev.Property].(string)
if exists { if exists {
power := dev.GetAttribute("power") power := dev.GetAttribute("power")
if value == "ON" { switch value {
case "ON":
power.SetValue(true) power.SetValue(true)
} else if value == "OFF" { case "OFF":
power.SetValue(false) power.SetValue(false)
} }
} }
...@@ -232,9 +233,10 @@ func (dev *Lamp) update(payload map[string]interface{}) { ...@@ -232,9 +233,10 @@ func (dev *Lamp) update(payload map[string]interface{}) {
value, exists := payload["state"].(string) value, exists := payload["state"].(string)
if exists { if exists {
light := dev.GetAttribute("light") light := dev.GetAttribute("light")
if value == "ON" { switch value {
case "ON":
light.SetValue(true) light.SetValue(true)
} else { case "OFF":
light.SetValue(false) light.SetValue(false)
} }
} }
......
...@@ -45,8 +45,7 @@ type Z2MDevice struct { ...@@ -45,8 +45,7 @@ type Z2MDevice struct {
IeeeAddress string `json:"ieee_address"` IeeeAddress string `json:"ieee_address"`
SwBuildID string `json:"software_build_id"` SwBuildID string `json:"software_build_id"`
FriendlyName string `json:"friendly_name"` FriendlyName string `json:"friendly_name"`
// Manufacturer string `json:"manufacturer"` // TODO: This is quite the same as Vendor / Model XAALDevices []XAALDeviceInterface
XAALDevices []XAALDeviceInterface
} }
type Expose struct { type Expose struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment