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
f23dfab3
Commit
f23dfab3
authored
4 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring
parent
4afbc623
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gateway.go
+1
-1
1 addition, 1 deletion
gateway.go
mqtt.go
+1
-19
1 addition, 19 deletions
mqtt.go
utils.go
+21
-0
21 additions, 0 deletions
utils.go
xaal.go
+1
-0
1 addition, 0 deletions
xaal.go
with
24 additions
and
20 deletions
gateway.go
+
1
−
1
View file @
f23dfab3
...
@@ -74,7 +74,7 @@ func (gw *Gateway) MQTTHandler(client mqtt.Client, msg mqtt.Message) {
...
@@ -74,7 +74,7 @@ func (gw *Gateway) MQTTHandler(client mqtt.Client, msg mqtt.Message) {
gw
.
Z2MParseDevices
(
msg
)
gw
.
Z2MParseDevices
(
msg
)
}
else
{
}
else
{
zDev
:=
gw
.
GetZDeviceByTopic
(
msg
.
Topic
())
zDev
:=
gw
.
GetZDeviceByTopic
(
msg
.
Topic
())
//
mqtt
DumpMsg(msg)
//
MQTT
DumpMsg(msg)
if
zDev
!=
nil
{
if
zDev
!=
nil
{
zDev
.
HandleMessage
(
msg
)
zDev
.
HandleMessage
(
msg
)
}
}
...
...
This diff is collapsed.
Click to expand it.
mqtt.go
+
1
−
19
View file @
f23dfab3
...
@@ -4,10 +4,8 @@ import (
...
@@ -4,10 +4,8 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"log/slog"
"log/slog"
"sort"
mqtt
"github.com/eclipse/paho.mqtt.golang"
mqtt
"github.com/eclipse/paho.mqtt.golang"
"github.com/jedib0t/go-pretty/v6/table"
)
)
// MQTTSetup creates a new MQTT client
// MQTTSetup creates a new MQTT client
...
@@ -36,21 +34,5 @@ func MQTTDumpMsg(msg mqtt.Message) {
...
@@ -36,21 +34,5 @@ func MQTTDumpMsg(msg mqtt.Message) {
if
err
!=
nil
{
if
err
!=
nil
{
slog
.
Error
(
"Error decoding JSON %v"
,
"topic"
,
msg
.
Topic
(),
"err"
,
err
)
slog
.
Error
(
"Error decoding JSON %v"
,
"topic"
,
msg
.
Topic
(),
"err"
,
err
)
}
}
jsonDump
(
data
)
// sort keys
keys
:=
make
([]
string
,
0
,
len
(
data
))
for
key
:=
range
data
{
keys
=
append
(
keys
,
key
)
}
sort
.
Strings
(
keys
)
// dump keys
tab
:=
table
.
NewWriter
()
tab
.
SetTitle
(
"MQTT update"
)
tab
.
SetStyle
(
table
.
StyleRounded
)
for
_
,
key
:=
range
keys
{
if
key
!=
"update"
{
tab
.
AppendRow
(
table
.
Row
{
key
,
data
[
key
]})
}
}
fmt
.
Println
(
tab
.
Render
())
}
}
This diff is collapsed.
Click to expand it.
utils.go
+
21
−
0
View file @
f23dfab3
...
@@ -3,8 +3,10 @@ package main
...
@@ -3,8 +3,10 @@ package main
import
(
import
(
"fmt"
"fmt"
"math"
"math"
"sort"
"strconv"
"strconv"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/lucasb-eyer/go-colorful"
"github.com/lucasb-eyer/go-colorful"
)
)
...
@@ -22,6 +24,25 @@ func hexStringToInteger(hexString string) (uint64, error) {
...
@@ -22,6 +24,25 @@ func hexStringToInteger(hexString string) (uint64, error) {
return
integerValue
,
nil
return
integerValue
,
nil
}
}
func
jsonDump
(
data
map
[
string
]
interface
{})
{
// sort keys
keys
:=
make
([]
string
,
0
)
for
key
:=
range
data
{
keys
=
append
(
keys
,
key
)
}
sort
.
Strings
(
keys
)
// dump keys
tab
:=
table
.
NewWriter
()
tab
.
SetTitle
(
"MQTT update"
)
tab
.
SetStyle
(
table
.
StyleRounded
)
for
_
,
key
:=
range
keys
{
if
key
!=
"update"
{
tab
.
AppendRow
(
table
.
Row
{
key
,
data
[
key
]})
}
}
fmt
.
Println
(
tab
.
Render
())
}
// xyToColor converts CIE XY color coordinates and brightness to an RGB color using the go-colorful library.
// xyToColor converts CIE XY color coordinates and brightness to an RGB color using the go-colorful library.
// https://github.com/Koenkk/zigbee2mqtt/issues/3497
// https://github.com/Koenkk/zigbee2mqtt/issues/3497
func
xyToColor
(
x
,
y
,
brightness
float64
)
colorful
.
Color
{
func
xyToColor
(
x
,
y
,
brightness
float64
)
colorful
.
Color
{
...
...
This diff is collapsed.
Click to expand it.
xaal.go
+
1
−
0
View file @
f23dfab3
...
@@ -503,4 +503,5 @@ func NewDebugDevice(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInte
...
@@ -503,4 +503,5 @@ func NewDebugDevice(addr uuid.UUID, zDev *Z2MDevice, exp *Expose) XAALDeviceInte
func
(
dev
*
DebugDevice
)
update
(
payload
map
[
string
]
interface
{})
{
func
(
dev
*
DebugDevice
)
update
(
payload
map
[
string
]
interface
{})
{
slog
.
Info
(
"Debug Device update"
,
"payload"
,
payload
)
slog
.
Info
(
"Debug Device update"
,
"payload"
,
payload
)
jsonDump
(
payload
)
}
}
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