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
de8f8178
Commit
de8f8178
authored
8 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Added Access info (more work TDB)
parent
202d76c2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gateway.go
+4
-0
4 additions, 0 deletions
gateway.go
main.go
+2
-1
2 additions, 1 deletion
main.go
z2m.go
+5
-3
5 additions, 3 deletions
z2m.go
with
11 additions
and
4 deletions
gateway.go
+
4
−
0
View file @
de8f8178
...
...
@@ -25,3 +25,7 @@ func GetGW() *gateway {
})
return
instance
}
func
NewGW
()
*
gateway
{
return
GetGW
()
}
This diff is collapsed.
Click to expand it.
main.go
+
2
−
1
View file @
de8f8178
...
...
@@ -22,7 +22,8 @@ func main() {
// client.Publish("zigbee2mqtt/0x70b3d52b600f89d3/set", 0, false, `{"state": "toggle"}`)
eng
:=
xaal
.
NewEngine
()
GetGW
()
.
engine
=
eng
gw
:=
GetGW
()
gw
.
engine
=
eng
eng
.
Run
()
client
.
Disconnect
(
250
)
slog
.
Debug
(
"MQTT disconnected"
)
...
...
This diff is collapsed.
Click to expand it.
z2m.go
+
5
−
3
View file @
de8f8178
...
...
@@ -44,6 +44,7 @@ type Expose struct {
Unit
string
`json:"unit,omitempty"`
Features
[]
Feature
`json:"features,omitempty"`
Values
[]
string
`json:"values,omitempty"`
Access
int
`json:"access,omitempty"`
}
type
Feature
struct
{
...
...
@@ -51,6 +52,7 @@ type Feature struct {
Type
string
`json:"type"`
Property
string
`json:"property,omitempty"`
Unit
string
`json:"unit,omitempty"`
Access
int
`json:"access,omitempty"`
}
func
(
bDevice
*
BridgeDevice
)
GetTopic
()
string
{
...
...
@@ -75,7 +77,7 @@ func (bDevices *BridgeDevice) dump() {
expTab
:=
table
.
NewWriter
()
expTab
.
SetTitle
(
"Exp:"
+
bDevices
.
FriendlyName
)
expTab
.
SetStyle
(
table
.
StyleRounded
)
expTab
.
AppendHeader
(
table
.
Row
{
"Name"
,
"Type"
,
"Unit"
,
"Values"
,
"Features: Name[Type](Unit){Property}"
})
expTab
.
AppendHeader
(
table
.
Row
{
"Name"
,
"Type"
,
"Acc"
,
"Unit"
,
"Values"
,
"Features: Name[Type]
-Acc-
(Unit){Property}"
})
for
_
,
expose
:=
range
bDevices
.
Definition
.
Exposes
{
values
:=
""
if
len
(
expose
.
Values
)
>
0
{
...
...
@@ -84,11 +86,11 @@ func (bDevices *BridgeDevice) dump() {
features
:=
""
if
len
(
expose
.
Features
)
>
0
{
for
_
,
feature
:=
range
expose
.
Features
{
features
+=
fmt
.
Sprintf
(
"- %s[%s](%s){%s}
\n
"
,
feature
.
Name
,
feature
.
Type
,
feature
.
Unit
,
feature
.
Property
)
features
+=
fmt
.
Sprintf
(
"- %s[%s]
-%d-
(%s){%s}
\n
"
,
feature
.
Name
,
feature
.
Type
,
feature
.
Access
,
feature
.
Unit
,
feature
.
Property
)
}
features
=
strings
.
TrimSuffix
(
features
,
"
\n
"
)
}
expTab
.
AppendRow
(
table
.
Row
{
expose
.
Name
,
expose
.
Type
,
expose
.
Unit
,
values
,
features
})
expTab
.
AppendRow
(
table
.
Row
{
expose
.
Name
,
expose
.
Type
,
expose
.
Access
,
expose
.
Unit
,
values
,
features
})
}
fmt
.
Println
(
expTab
.
Render
())
}
...
...
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