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
1547f7d3
Commit
1547f7d3
authored
5 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup some code
Switch to switch.. (go syntax)
parent
500466e9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gateway.go
+1
-1
1 addition, 1 deletion
gateway.go
xaal.go
+6
-4
6 additions, 4 deletions
xaal.go
z2m.go
+1
-2
1 addition, 2 deletions
z2m.go
with
8 additions
and
7 deletions
gateway.go
+
1
−
1
View file @
1547f7d3
...
@@ -9,10 +9,10 @@ import (
...
@@ -9,10 +9,10 @@ import (
)
)
type
Gateway
struct
{
type
Gateway
struct
{
client
MQTT
.
Client
engine
*
xaal
.
Engine
engine
*
xaal
.
Engine
devices
map
[
string
]
*
Z2MDevice
devices
map
[
string
]
*
Z2MDevice
baseAddr
uuid
.
UUID
baseAddr
uuid
.
UUID
client
MQTT
.
Client
}
}
var
(
var
(
...
...
This diff is collapsed.
Click to expand it.
xaal.go
+
6
−
4
View file @
1547f7d3
...
@@ -166,9 +166,10 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
...
@@ -166,9 +166,10 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
value
,
exists
:=
payload
[
dev
.
Property
]
.
(
string
)
value
,
exists
:=
payload
[
dev
.
Property
]
.
(
string
)
if
exists
{
if
exists
{
power
:=
dev
.
GetAttribute
(
"power"
)
power
:=
dev
.
GetAttribute
(
"power"
)
if
value
==
"ON"
{
switch
value
{
case
"ON"
:
power
.
SetValue
(
true
)
power
.
SetValue
(
true
)
}
else
if
value
==
"OFF"
{
case
"OFF"
:
power
.
SetValue
(
false
)
power
.
SetValue
(
false
)
}
}
}
}
...
@@ -232,9 +233,10 @@ func (dev *Lamp) update(payload map[string]interface{}) {
...
@@ -232,9 +233,10 @@ func (dev *Lamp) update(payload map[string]interface{}) {
value
,
exists
:=
payload
[
"state"
]
.
(
string
)
value
,
exists
:=
payload
[
"state"
]
.
(
string
)
if
exists
{
if
exists
{
light
:=
dev
.
GetAttribute
(
"light"
)
light
:=
dev
.
GetAttribute
(
"light"
)
if
value
==
"ON"
{
switch
value
{
case
"ON"
:
light
.
SetValue
(
true
)
light
.
SetValue
(
true
)
}
else
{
case
"OFF"
:
light
.
SetValue
(
false
)
light
.
SetValue
(
false
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
z2m.go
+
1
−
2
View file @
1547f7d3
...
@@ -45,8 +45,7 @@ type Z2MDevice struct {
...
@@ -45,8 +45,7 @@ type Z2MDevice struct {
IeeeAddress
string
`json:"ieee_address"`
IeeeAddress
string
`json:"ieee_address"`
SwBuildID
string
`json:"software_build_id"`
SwBuildID
string
`json:"software_build_id"`
FriendlyName
string
`json:"friendly_name"`
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
{
type
Expose
struct
{
...
...
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