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 (
)
type Gateway struct {
client MQTT.Client
engine *xaal.Engine
devices map[string]*Z2MDevice
baseAddr uuid.UUID
client MQTT.Client
}
var (
......
......@@ -166,9 +166,10 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
value, exists := payload[dev.Property].(string)
if exists {
power := dev.GetAttribute("power")
if value == "ON" {
switch value {
case "ON":
power.SetValue(true)
} else if value == "OFF" {
case "OFF":
power.SetValue(false)
}
}
......@@ -232,9 +233,10 @@ func (dev *Lamp) update(payload map[string]interface{}) {
value, exists := payload["state"].(string)
if exists {
light := dev.GetAttribute("light")
if value == "ON" {
switch value {
case "ON":
light.SetValue(true)
} else {
case "OFF":
light.SetValue(false)
}
}
......
......@@ -45,8 +45,7 @@ type Z2MDevice struct {
IeeeAddress string `json:"ieee_address"`
SwBuildID string `json:"software_build_id"`
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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment