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 {
XAALDevice
}
type DebugDevice struct {
XAALDevice
}
type XAALDeviceInterface interface {
update(map[string]interface{})
GetXAALDevice() *xaal.Device
......@@ -481,8 +485,22 @@ func NewLuxMeter(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterfa
}
func (dev *LuxMeter) update(payload map[string]interface{}) {
slog.Info("update", "payload", payload)
lux, err := convertToInt(payload[dev.Expose.Name])
if err == nil {
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) {
"light": NewLamp,
"occupancy": NewMotion,
"illuminance": NewLuxMeter,
"voltage": NewDebugDevice,
}
// Search a matching expose name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment