# MQTT Hub/Gateway

**URL:** <https://community.homey.app/t/mqtt-hub-gateway/6766>\
**Category:** Apps\
**Created:** [January 14, 2019, 6:59pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766 "2019-01-14T18:59:50Z")\
**Posts on this page:** 20\
**Page:** 49

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 9, 2021, 12:40am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/971 "2021-05-09T00:40:35Z")

</div>

**Version 3.5.0** ([test](https://homey.app/nl-nl/app/nl.hdg.mqtt/MQTT-Hub/test))

- MQTT Device icons

All 5955 icons from the [MDI iconset](https://materialdesignicons.com/) can be searched and selected as device icon. Additional custom .svg images can be uploaded.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/1/11ba5b86bf8d565ae3fa3ab869d3f188b7ad815c.png)

For version history, see: [CHANGE\_LOG](https://github.com/harriedegroot/nl.hdg.mqtt/blob/master/CHANGE_LOG.md)

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 9, 2021, 10:44am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/972 "2021-05-09T10:44:09Z")

</div>

**Version 3.5.1** ([test](https://homey.app/nl-nl/app/nl.hdg.mqtt/MQTT-Hub/test))

- Upload custom icon fixes
- Remove uploaded icons on cancel pairing OR uninstall of MQTT Device

For version history, see: [CHANGE\_LOG](https://github.com/harriedegroot/nl.hdg.mqtt/blob/master/CHANGE_LOG.md)

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 10, 2021, 8:08pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/973 "2021-05-10T20:08:52Z")

</div>

Brilliant update! Now I need to recreate all devices 😭

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 10, 2021, 8:45pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/974 "2021-05-10T20:45:33Z")

</div>

Sorry…

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 10, 2021, 10:48pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/975 "2021-05-10T22:48:31Z")

</div>

**Version 3.5.2**

- HA Discovery: Cover position template fix for HA version 2021.6+ ([issue 56](https://github.com/harriedegroot/nl.hdg.mqtt/issues/56))
- Security: Homey, jsonPath & lodash NPM package upgrades

For version history, see: [CHANGE\_LOG](https://github.com/harriedegroot/nl.hdg.mqtt/blob/master/CHANGE_LOG.md)

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 12, 2021, 1:25pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/976 "2021-05-12T13:25:15Z")

</div>

I tried the new icons and I seem to have trouble with the custom SVG one. First I tried using Safari on a MacBook and it didn’t work. Then I tried moving the files to my iPhone and upload it and it didn’t work. last I tried using Chrome and I got it the Icon to upload and attach to the device.

I can see this custom icon in both chrome and safari but there isn’t any icon at all on my iPhone. I tried restarting the MQTT Hub app, the iPhone app and the iPhone itself but none of it mattered. It’s also been a couple of hours since I did it and it has not appeared.

The ones you choose in the list does not seem to have this problem.

This is the icon I used:

> **[Cfl, electric, electricity, light, source, tube, tubelight icon - Free download](https://www.iconfinder.com/icons/998251/cfl_electric_electricity_light_source_tube_tubelight_icon)**
>
> Download this cfl, electric, electricity, light, source, tube, tubelight icon in solid style from the Sound & music category. Available in PNG and SVG formats.

Any ideas?

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 12, 2021, 1:39pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/977 "2021-05-12T13:39:11Z")

</div>

I had some trouble with the web app. Seamed like the icon isn’t uploaded to CDN before it is loaded into the mobile app. So opening the mobile app after creating the device in the browser did the trick on my side.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 12, 2021, 1:41pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/978 "2021-05-12T13:41:49Z")

</div>

@Camelen Where can I find the SVG version of that particular icon?

Found already: [https://www.iconfinder.com/icons/998251/download/svg/512](https://www.iconfinder.com/icons/998251/download/svg/512)

Had no problem uploading the icon & adding it to the device:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/6/163f2e09448b1225a5a99f690b36af59d5497fce.png)

This time added using the web app in Chrome. Did not even have to load the device in the mobile app.

And indedeed…icon is not displayed in the mobile app (Android) ☹  
Lets try adding the icon from the app…

There’s a small bug in the mimetype, preventing me to select an SVG on mobile.  
But after resolving this, the selected icon on mobile is correctly uploaded and added to the MQTT device.

The strange thing: the icon is not displayed on mobile, but is in the web app ?!?!?

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 12, 2021, 2:02pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/979 "2021-05-12T14:02:54Z")

</div>

Yes and it is also displayed in the web app in a different browser so it’s not some cache-thing. At least the behavior seems consistent over the phone-apps.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 12, 2021, 2:03pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/980 "2021-05-12T14:03:19Z")

</div>

**Version 3.5.3**

- SVG mimetype fix for uploading MQTT Device icons

For version history, see: [CHANGE\_LOG](https://github.com/harriedegroot/nl.hdg.mqtt/blob/master/CHANGE_LOG.md)

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 12, 2021, 2:04pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/981 "2021-05-12T14:04:45Z")

</div>

Maybe it’s something with the SVG structure? Viewport? etc.  
I’m not an SVG expert 🙂 …

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 12, 2021, 2:29pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/982 "2021-05-12T14:29:58Z")

</div>

I have barely used svgs before so I’m probably not very helpful here. With the 3.5.3 update I can also upload from the phone app and it shows during the configuration process but not after it’s finished.

I just realized that an svg file is basically just code so I tried downloading an icon from [https://materialdesignicons.com/](https://materialdesignicons.com/) and upload it and that file worked so I guess there’s a problem with the svg-file I used.

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 13, 2021, 7:19pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/983 "2021-05-13T19:19:22Z")

</div>

I think that I have found some unwanted behavior.

It seems as if MQTT Hub puts into the set topic what it sees in the state topic.  
This will causes some trouble for me and does also seem wrong to me.

Explanation / to repliacte:  
I’m starting to transition to zwavejs2mqtt and am adding my devices to Homey through MQTT Hub.  
While trying to add a dimmer (fibaro) the payload for current value looks like this:  
State topic: zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue  
Payload: {“time”:1620932977766,“value”:32}

Set topic is:  
Topic: zwave/kitchen/island/switch\_multilevel/endpoint\_1/targetValue/set  
Payload: 0-99 integer (will round if decimals) or true / false (remember last level).

So I used a valueTemplate simply named “value” and to circumvent 0-100 to 0-99 I tried to set the output template to value\*99/100.  
This caused erratic behavior because there was a disconnect between what MQTT Hub sets and what is reported back, which then MQTT Hub sets into the /set topic and so on.

I also checked by just changing the current value topic with MQTT Explorer to a new dim value and MQTT Hub then puts this value in the /set topic. If I turned of MQTT Client to disconnect homey this behavior did not happen so I’m pretty certain that this isn’t caused by some of my other devices.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 13, 2021, 8:32pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/984 "2021-05-13T20:32:55Z")

</div>

@Camelen Isn’t it the other way around? The state topic is updated with the value provided on the `/set` topic. The device state is synced with the input value.

I expect you got into a message loopt…  
Did you try rounding the values to break this loop?

I also got comparable behaviour with a light brightness / dim level, while working on the HA Discovery and auto generation of MQTT devices based on the HA discovery protocol ($config).  
So it already was the next thing on the list 🙂

_My guessing (probably incomplete…)_:  
Due the calculation you’re communicating floating point values i.s.o integers. Because the input (set) and output (state) topics are lined up, you end up with a message loop. This is because the other end of the line (zwavejs2mqtt) also detects a new/changed value and reports a state change of the device back to Homey. Homey gets a new input and sends a device state change to zwavejs2mqtt, …, _loop_, …, etc…

This loop will break if the MQTT device input (set) equals the current state, but this won’t happen due the small floating point difference introduced by the calculation. Maybe rounding the values is a first workaround to hit this brake? But it’s probably not a / the full / correct solution. As mentioned, this needs some attention…

Maybe the equality check needs to be placed after the equation has been executed, but again, I need to check this…

* * *

Regarding the **auto discovery of HA devices** : I’m using the [MQTT statestream](https://www.home-assistant.io/integrations/mqtt_statestream/), combined with this [BluePrint](https://community.home-assistant.io/t/mqtt-state-stream-to-mqtt-discovery/258591) to create [HA Discovery](https://www.home-assistant.io/docs/mqtt/discovery/) topics for all HA devices. Allowing me to import all devices from HA to Homey, without a single manual definition. Work in progress…

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 13, 2021, 8:44pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/985 "2021-05-13T20:44:20Z")

</div>

Just checked, calculation is executed before value comparison, so thats not the answer…  
[device.js (r263)](https://github.com/harriedegroot/nl.hdg.mqtt/blob/master/drivers/device/device.js)

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 13, 2021, 8:45pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/986 "2021-05-13T20:45:11Z")

</div>

> Isn’t it the other way around? The state topic is updated with the value provided on the `/set` topic. The device state is synced with the input value.

Well yeah that’s the way it is supposed to be I guess. The way I thought that it should work is that the /set topic is never touched except for changing the state of the device. Do we really need to have a sync from the current state → /set? Because that’s what I’m seeing.

If I change the dim value in Homey to 32 the /set topic gets changed to 32, raw number.  
This triggers a change in state of the device through zwavejs2mqtt and the currentValue topic is updated to reflect the 32 dim level.

However if I change the currentValue manually in MQTT Explorer to 32 (this does not trigger a state change of the device itself in zwavejs2mqtt) then homey / MQTT Hub changes the /set topic to reflect 32 and THEN zwavejs2mqtt gets triggered to carry out the state change.

This seems incorrect to me. Why is Homey/MQTTHub syncing the /set value with the currentValue? I just don’t see the reason for it.

> Due the calculation you’re communicating floating point values i.s.o integers. Because the input (set) and output (state) topics are lined up, you end up with a message loop. This is because the other end of the line (zwavejs2mqtt) also detects a new/changed value and reports a state change of the device back to Homey. Homey gets a new input and sends a device state change to zwavejs2mqtt, …, _loop_ , …, etc…

Yes, this sounds reasonable. But why though? Why does /set have to line up with currentValue in both directions? Is there any benefit to it except risks for loops etc.?

> Regarding the **auto discovery of HA devices** : I’m using the [MQTT statestream](https://www.home-assistant.io/integrations/mqtt_statestream/), combined with this [BluePrint](https://community.home-assistant.io/t/mqtt-state-stream-to-mqtt-discovery/258591) to create [HA Discovery](https://www.home-assistant.io/docs/mqtt/discovery/) topics for all HA devices. Allowing me to import all devices from HA to Homey, without a single manual definition. Work in progress…

This sounds great. There’s auto discovery between zwavejs2mqtt to HA but obviously not to Homey and it’s kind of a PITA to add all the devices to homey through the app/webapp.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 13, 2021, 8:46pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/987 "2021-05-13T20:46:29Z")

</div>

Just checking:  
Where did you put the /set topic on the MQTT Device capability config?  
And isn’t the /set topic called by zwavejs2mqtt?

The /set topic should never be updated by Homey on device state change, unless it’s configured as state topic for the MQTT Device capability.

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 13, 2021, 8:49pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/988 "2021-05-13T20:49:30Z")

</div>

> {  
> “dim”: {  
> “capability”: “dim”,  
> “stateTopic”: “zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue”,  
> “setTopic”: “zwave/kitchen/island/switch\_multilevel/endpoint\_1/targetValue/set”,  
> “valueTemplate”: “value”,  
> “outputTemplate”: “”,  
> “displayName”: “Dim level”  
> },

This is the code of the device.  
If I disconnect Homey from MQTT the behavior stops.

> The /set topic should never be updated by Homey on device state change, unless it’s configured as state topic for the MQTT Device capability.

That’s what I thought and that’s why I’m reporting this bug 🙂  
The fault could be in my settings but I don’t really think so.

I can check logs in my mosquitto to verify who posts the change.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 13, 2021, 8:54pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/989 "2021-05-13T20:54:57Z")

</div>

Looks correct…  
FYI: valueTemplate can be left black for the same behaviour.

The ‘setTopic’ is called when the MQTT Device state (capability value) is changed.  
A change can be triggered manually, via a flow / script or a message on the state topic…

---

<div class="post-metadata">

**Author:** ![Camelen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/camelen/32/9613_2.png) [@Camelen](https://community.homey.app/u/Camelen)\
**Post date:** [May 13, 2021, 8:58pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/990 "2021-05-13T20:58:36Z")

</div>

From what I can tell Mosquitto supports my suspicion. I did not post anything that should have touched the /set topic of the dimmer here.

This is the log from Mosquitto:  
1620939241: Received PUBLISH from mqtt-explorer-1e2de860 (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue’, … (33 bytes))

1620939241: Sending PUBLISH to homey\_client (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue’, … (33 bytes))

1620939241: Sending PUBLISH to 5vArLtX1iTBXYhodlZW1RO (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue’, … (33 bytes))

1620939241: Sending PUBLISH to mqtt-explorer-1e2de860 (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/currentValue’, … (33 bytes))

1620939241: Received PUBLISH from homey\_client (d0, q0, r1, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/targetValue/set’, … (2 bytes))

1620939241: Sending PUBLISH to ZWAVE\_GATEWAY-zwavejs2mqtt (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/targetValue/set’, … (2 bytes))

1620939241: Sending PUBLISH to mqtt-explorer-1e2de860 (d0, q0, r0, m0, ‘zwave/kitchen/island/switch\_multilevel/endpoint\_1/targetValue/set’, … (2 bytes))

[Previous page](https://community.homey.app/t/mqtt-hub-gateway/6766.md?page=48)

[Next page](https://community.homey.app/t/mqtt-hub-gateway/6766.md?page=50)
