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

Added DebugDevice

Used for new devices type
parent 6fcdc0de
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,10 @@ type LuxMeter struct { ...@@ -61,6 +61,10 @@ type LuxMeter struct {
XAALDevice XAALDevice
} }
type DebugDevice struct {
XAALDevice
}
type XAALDeviceInterface interface { type XAALDeviceInterface interface {
update(map[string]interface{}) update(map[string]interface{})
GetXAALDevice() *xaal.Device GetXAALDevice() *xaal.Device
...@@ -481,8 +485,22 @@ func NewLuxMeter(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterfa ...@@ -481,8 +485,22 @@ func NewLuxMeter(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterfa
} }
func (dev *LuxMeter) update(payload map[string]interface{}) { func (dev *LuxMeter) update(payload map[string]interface{}) {
slog.Info("update", "payload", payload)
lux, err := convertToInt(payload[dev.Expose.Name]) lux, err := convertToInt(payload[dev.Expose.Name])
if err == nil { if err == nil {
dev.GetAttribute("illuminance").SetValue(lux) dev.GetAttribute("illuminance").SetValue(lux)
} }
} }
// =============================================================================
// Debug Device
// =============================================================================
func NewDebugDevice(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterface {
dev := &DebugDevice{XAALDevice{schemas.NewBasic(addr), zDev, exp}}
dev.setup()
return dev
}
func (dev *DebugDevice) update(payload map[string]interface{}) {
slog.Info("Debug Device update", "payload", payload)
}
...@@ -113,6 +113,7 @@ func (zDev *Z2MDevice) FindXAALDevices(gw *Gateway) { ...@@ -113,6 +113,7 @@ func (zDev *Z2MDevice) FindXAALDevices(gw *Gateway) {
"light": NewLamp, "light": NewLamp,
"occupancy": NewMotion, "occupancy": NewMotion,
"illuminance": NewLuxMeter, "illuminance": NewLuxMeter,
"voltage": NewDebugDevice,
} }
// Search a matching expose name // Search a matching expose name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment