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

Fix mqqtTopic global

I guess I missed a push on git.. so back port this missing stuff.
parent e395ceb3
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,6 @@ import (
)
var (
mqttTopic = "zigbee2mqtt"
mqttClientID = "z2m-" + uuid.New().String()
ignoredTopics = []string{
"bridge/groups",
......
......@@ -34,8 +34,8 @@ func (gw *Gateway) AddZDevice(zDev *Z2MDevice) {
slog.Debug("Adding device", "dev", dev.String())
gw.Engine.AddDevice(dev)
}
gw.Devices[zDev.FriendlyName] = zDev
zDev.Gateway = gw
gw.Devices[zDev.FriendlyName] = zDev
}
func (gw *Gateway) RemoveZDevice(zDev *Z2MDevice) {
......
......@@ -61,7 +61,7 @@ type Feature struct {
// returns the topic for the device
func (zDev *Z2MDevice) getTopic() string {
return mqttTopic + "/" + zDev.FriendlyName
return zDev.Gateway.Config.topic + "/" + zDev.FriendlyName
}
// return the expose with the given name
......@@ -90,6 +90,8 @@ func (zDev *Z2MDevice) HandleMessage(msg mqtt.Message) {
// creates new xAAL devices from a bridge device
func (zDev *Z2MDevice) FindXAALDevices(gw *Gateway) {
// There is a trick here. We call FindXAALDevices w/ gw argument, but the Gateway is only set
// in the AddZDevice method. This is not mandatory but avoid to have Gateway at random place
baseAddr := gw.Config.baseAddr
ieeeAddr, _ := hexStringToInteger(zDev.IeeeAddress)
baseAddr, _ = baseAddr.Add(int64(ieeeAddr))
......
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