Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
z2m
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Go
z2m
Commits
ee04dc5a
Commit
ee04dc5a
authored
5 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Added support for powermeter
parent
a2ddd329
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
devices.go
+1
-0
1 addition, 0 deletions
devices.go
xaal.go
+32
-2
32 additions, 2 deletions
xaal.go
with
33 additions
and
2 deletions
devices.go
+
1
−
0
View file @
ee04dc5a
...
...
@@ -24,6 +24,7 @@ func newXAALDevices(gw *Gateway, zDev *Z2MDevice) {
"humidity"
:
NewHygrometer
,
"linkquality"
:
NewLinkQuality
,
"battery"
:
NewBattery
,
"power"
:
NewPowerMeter
,
}
if
createFunc
,
ok
:=
deviceMap
[
expose
.
Name
];
ok
{
...
...
This diff is collapsed.
Click to expand it.
xaal.go
+
32
−
2
View file @
ee04dc5a
...
...
@@ -35,8 +35,12 @@ type Battery struct {
type
PowerRelay
struct
{
XAALDevice
Z2MDevice
Z2MDevice
Property
string
Z2MDevice
Z2MDevice
}
type
PowerMeter
struct
{
XAALDevice
}
type
Lamp
struct
{
...
...
@@ -115,6 +119,8 @@ func (dev *Hygrometer) update(payload map[string]interface{}) {
func
NewLinkQuality
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
LinkQuality
{
XAALDevice
{
schemas
.
NewLinkquality
(
addr
)}}
dev
.
setup
(
zDev
)
dev
.
RemoveAttribute
(
"devices"
)
dev
.
UnsupportedAttributes
=
[]
string
{
"devices"
}
return
dev
}
...
...
@@ -132,6 +138,8 @@ func (dev *LinkQuality) update(payload map[string]interface{}) {
func
NewBattery
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Battery
{
XAALDevice
{
schemas
.
NewBattery
(
addr
)}}
dev
.
setup
(
zDev
)
dev
.
RemoveAttribute
(
"devices"
)
dev
.
UnsupportedAttributes
=
[]
string
{
"devices"
}
return
dev
}
...
...
@@ -146,7 +154,7 @@ func (dev *Battery) update(payload map[string]interface{}) {
// PowerRelay
// ----------------------------------------------------------------------------
func
NewPowerRelay
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
,
property
string
)
XAALDeviceInterface
{
dev
:=
&
PowerRelay
{
XAALDevice
{
schemas
.
NewPowerrelayToggle
(
addr
)},
*
zDev
,
property
}
dev
:=
&
PowerRelay
{
XAALDevice
{
schemas
.
NewPowerrelayToggle
(
addr
)},
property
,
*
zDev
}
dev
.
SetMethod
(
"turn_on"
,
dev
.
On
)
dev
.
SetMethod
(
"turn_off"
,
dev
.
Off
)
dev
.
SetMethod
(
"toggle"
,
dev
.
Toggle
)
...
...
@@ -186,6 +194,28 @@ func (dev *PowerRelay) Toggle(xaal.MessageBody) *xaal.MessageBody {
return
nil
}
// ----------------------------------------------------------------------------
// PowerMeter
// ----------------------------------------------------------------------------
func
NewPowerMeter
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
PowerMeter
{
XAALDevice
{
schemas
.
NewPowermeter
(
addr
)}}
dev
.
setup
(
zDev
)
dev
.
RemoveAttribute
(
"devices"
)
dev
.
UnsupportedAttributes
=
[]
string
{
"devices"
}
return
dev
}
func
(
dev
*
PowerMeter
)
update
(
payload
map
[
string
]
interface
{})
{
value
,
exists
:=
payload
[
"power"
]
.
(
float64
)
if
exists
{
dev
.
GetAttribute
(
"power"
)
.
SetValue
(
value
)
}
value
,
exists
=
payload
[
"energy"
]
.
(
float64
)
if
exists
{
dev
.
GetAttribute
(
"energy"
)
.
SetValue
(
value
)
}
}
// ----------------------------------------------------------------------------
// Lamp
// ----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment