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

Add support for current / volt

Unlike other gateway, I didn't hack the power-meter to embbed current
and voltage.. not really sure about this. Chris doesn't like the embbed
stuff.. that's why this time, I will ask him an volt/amp-meter schema.
;)
parent 54c072d7
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,14 @@ type LuxMeter struct {
XAALDevice
}
type VoltMeter struct {
XAALDevice
}
type AmpMeter struct {
XAALDevice
}
type DebugDevice struct {
XAALDevice
}
......@@ -492,6 +500,42 @@ func (dev *LuxMeter) update(payload map[string]interface{}) {
}
}
// =============================================================================
// VoltMeter
// =============================================================================
func NewVoltMeter(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterface {
dev := &VoltMeter{XAALDevice{schemas.NewBasic(addr), zDev, exp}}
dev.DevType = "voltmeter.any"
dev.AddAttribute("voltage", 0.0)
dev.setup()
return dev
}
func (dev *VoltMeter) update(payload map[string]interface{}) {
value, err := convertToFloat64(payload[dev.Expose.Name])
if err == nil {
dev.GetAttribute("voltage").SetValue(value)
}
}
// =============================================================================
// AmpMeter
// =============================================================================
func NewAmpMeter(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInterface {
dev := &AmpMeter{XAALDevice{schemas.NewBasic(addr), zDev, exp}}
dev.DevType = "ampmeter.any"
dev.AddAttribute("current", 0.0)
dev.setup()
return dev
}
func (dev *AmpMeter) update(payload map[string]interface{}) {
value, err := convertToFloat64(payload[dev.Expose.Name])
if err == nil {
dev.GetAttribute("current").SetValue(value)
}
}
// =============================================================================
// Debug Device
// =============================================================================
......
......@@ -113,7 +113,8 @@ func (zDev *Z2MDevice) FindXAALDevices(gw *Gateway) {
"light": NewLamp,
"occupancy": NewMotion,
"illuminance": NewLuxMeter,
"voltage": NewDebugDevice,
"voltage": NewVoltMeter,
"current": NewAmpMeter,
}
// 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