# 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:** 57

<div class="post-metadata">

**Author:** ![rutberg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rutberg/32/10698_2.png) [@rutberg](https://community.homey.app/u/rutberg)\
**Post date:** [June 14, 2022, 6:40am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1132 "2022-06-14T06:40:44Z")

</div>

Yes i found that setting but it didn’t have any effect, I can see the values shifting in MQTT explorer, but the device doesn’t update. I thought it had more impact on device output rather than input.

If this is supposed to work I’ll do some further testing this afternoon.

---

<div class="post-metadata">

**Author:** ![rutberg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rutberg/32/10698_2.png) [@rutberg](https://community.homey.app/u/rutberg)\
**Post date:** [June 14, 2022, 1:25pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1134 "2022-06-14T13:25:56Z")

</div>

This is interesting, tested with just setting “value” in the template field, and suddenly the device started to register events on ON/OFF.

> {  
> “alarm\_motion”: {  
> “capability”: “alarm\_motion”,  
> “stateTopic”: “ring/00e64a46-0000-4491-92ca-1c290525cb3d/alarm/00e00e0b-06bb-404b-ae80-e57c900ca6ae/motion/state”,  
> “setTopic”: “”,  
> “valueTemplate”: “value”,  
> “outputTemplate”: “”,  
> “displayName”: “Motion alarm”  
> }  
> }

---

<div class="post-metadata">

**Author:** ![rutberg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rutberg/32/10698_2.png) [@rutberg](https://community.homey.app/u/rutberg)\
**Post date:** [June 14, 2022, 1:27pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1135 "2022-06-14T13:27:24Z")

</div>

And then I removed “value”, it still works. It seems like there’s been some hiccup that have ben solved by just pushing the values again.

---

<div class="post-metadata">

**Author:** ![paaland](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/paaland/32/26023_2.png) [@paaland](https://community.homey.app/u/paaland)\
**Post date:** [July 17, 2022, 7:49pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1136 "2022-07-17T19:49:57Z")

</div>

Any ideas why my displayNames are not used?

```auto
{
    "measure_power": {
        "capability": "measure_power",
        "stateTopic": "ams/meter/import/active",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Power"
    },
    "measure_current.l1": {
        "capability": "measure_current",
        "stateTopic": "ams/meter/l1/current",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Current l1"
    },
    "measure_current.l2": {
        "capability": "measure_current",
        "stateTopic": "ams/meter/l2/current",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Current l2"
    },
    "measure_current.l3": {
        "capability": "measure_current",
        "stateTopic": "ams/meter/l3/current",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Current l3"
    },
    "measure_voltage.l1": {
        "capability": "measure_voltage",
        "stateTopic": "ams/meter/l1/voltage",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Voltage l1"
    },
    "measure_voltage.l2": {
        "capability": "measure_voltage",
        "stateTopic": "ams/meter/l2/voltage",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Voltage l2"
    },
    "measure_voltage.l3": {
        "capability": "measure_voltage",
        "stateTopic": "ams/meter/l3/voltage",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Voltage l3"
    },
    "meter_power.acc": {
        "capability": "meter_power",
        "stateTopic": "ams/meter/import/active/accumulated",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Energy"
    },
    "meter_power.hour": {
        "capability": "meter_power",
        "stateTopic": "ams/realtime/import/hour",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Energy this hour"
    },
    "meter_power.day": {
        "capability": "meter_power",
        "stateTopic": "ams/realtime/import/day",
        "setTopic": "",
        "valueTemplate": "",
        "outputTemplate": "",
        "displayName": "Energy this day"
    }
}

```

All the capabilities uses the default name. So I have three Current, three Voltage and three Energy (in Norwegian). No way of knowing which is which when creating flows.

 ![Screenshot 2022-07-17 21.49.09](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/1/219389870cecc635aca5e94da6382e681a1873d4.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 18, 2022, 12:31am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1137 "2022-07-18T00:31:49Z")

</div>

With one capability it is OK. Did you try what the result is with a one capability device?

```auto
{
  "measure_voltage": {
    "capability": "measure_voltage",
    "stateTopic": "",
    "commandTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Special Display Name Voltage"
  }
}

```

![Screenshot from 2022-07-18 02-29-11](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/9/19418fd7b2ebc169446d06650bffc1a5456e927d.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 22, 2022, 7:59pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1138 "2022-07-22T19:59:45Z")

</div>

Hi all,

When I disable a device, it won’t dissapear from HA. Is that by design or is it a setting I can change?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [July 22, 2022, 8:58pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1139 "2022-07-22T20:58:59Z")

</div>

Disabled in Mqtt Hub settings? In that case no updates will be pushed to Mqtt. But the HA device will stay. If you don’t neednit anymore, you can delete it in HA (settings/devices, search by name and delete).  
If it’s activated in Homey again, state changes will be pushed again and the device will be created again in HA.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 22, 2022, 9:53pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1140 "2022-07-22T21:53:55Z")

</div>

Thanks Ronny, that’s indeed how it works now.  
As I am fiddling often with (temporary) new devices, I am also busy by removing them from HA afterwards 😊  
For me, a disabled device almost never gets enabled again, so it would be nice to have an “Auto add new devices” switch to prevent everything from popping up in HA when you are experimenting 🙃

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [July 22, 2022, 9:58pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1141 "2022-07-22T21:58:06Z")

</div>

If you add a new device in Homey, restart the Hub and it will update the HA devices (new device is created in HA).  
A problem is: when you replace a Homey device (remove and add with same name), you will have 2 devices in HA. So I delete the old device in HA, replace in Homey and restart teh Hub to sync again. This way you don’t need to update the HA-Dashboard.

---

<div class="post-metadata">

**Author:** ![ef02lajo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ef02lajo/32/59487_2.png) [@ef02lajo](https://community.homey.app/u/ef02lajo)\
**Post date:** [August 25, 2022, 8:28pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1142 "2022-08-25T20:28:30Z")

</div>

Hi, is it possible to publish the on/off values like ON/OFF with capital letters? by default it seems the payload is sent in lower case. My devices need capital letters in the payload to accept the message.

I have searched the forums without finding anything around this and been trying different things with the outputTemplate and the other settings but not been able to get it work. Is it possible to use string functions like “value.toUpperCase()” in the outputTemplate?

Any pointers on how to achieve this is highly welcome, thanks!

---

<div class="post-metadata">

**Author:** ![RogerSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rogerst/32/12432_2.png) [@RogerSt](https://community.homey.app/u/RogerSt)\
**Post date:** [September 3, 2022, 4:19pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1143 "2022-09-03T16:19:35Z")

</div>

When Homey restarts, my MQTT Hub does seem to not start properly. This leads to the MQTT Hub not functioning, and my broker not receiving any messages.

I really need to manually restart the app, and then force another broadcast for things to return to normal, which requires my presence and is generally annoying.

I have now automated this flow (advanced flow).

- once the Homey has restarted an event is emitted
- when this event is emitted by Homey, most of the apps have not been started yet
- I use simplelog to log things in my log and on the timeline, but at this point in time, the SImpleLog app has not been started yet. Instead I write a notification to the timeline. This will work as it is native supported functionality that is available when the homey-started event is emitted.

After that, the flow waits a considerable amount of time before doing the real work, since it can take quite some time before all apps are started after a reboot:

- wait 20 minutes - this might be shorter, but I prefer to be safer than sorrier
- restart the MQTT Hub
- trigger a broadcast 2 minutes after the restart of the MQTT Hub

Whenever Homey restarts willingly or unwillingly, this ensures that my MQTT statuses are properly working - even when I’m not at home when a restart occurs spontaneously.

Please see this screenshot:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/c/ec14c4765637f05424a63c9c3c955de0e04c8ee8.png)

---

<div class="post-metadata">

**Author:** ![Zimo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zimo/32/16621_2.png) [@Zimo](https://community.homey.app/u/Zimo)\
**Post date:** [September 4, 2022, 8:20am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1144 "2022-09-04T08:20:19Z")

</div>

I thought that restart of MQTT hub app automatically triggers broadcast - that’s my observation.

I had same flow in the past too, however now it’s disabled as it’s not needed. Still restarting regularly during night as suggested in this forum.

---

<div class="post-metadata">

**Author:** ![RogerSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rogerst/32/12432_2.png) [@RogerSt](https://community.homey.app/u/RogerSt)\
**Post date:** [September 4, 2022, 8:50am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1145 "2022-09-04T08:50:10Z")

</div>

I have noticed the auto broadcast feature to be working _most_ of the time. I have found a few occasions in the past few months where the app would not broadcast.  
If it works for _you_ without the forced broadcast then I’m still happy 😉

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 4, 2022, 11:51am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1146 "2022-09-04T11:51:18Z")

</div>

Thats odd, my Homey only restarts after an update, and I never restart the MQTT Hub app.  
It seems to be a local issue?

 ![Screenshot_20220904-134846_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/f/7fd6c160bea6af3ceb59b2be5b6960d68902ef2b.jpeg)  
This is a Homey zigbee temperature sensor

---

<div class="post-metadata">

**Author:** ![RogerSt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rogerst/32/12432_2.png) [@RogerSt](https://community.homey.app/u/RogerSt)\
**Post date:** [September 4, 2022, 12:08pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1147 "2022-09-04T12:08:47Z")

</div>

Could be. One of my apps could have a memory leak. I have never investigated…

---

<div class="post-metadata">

**Author:** ![Juriaan](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/juriaan/32/16493_2.png) [@Juriaan](https://community.homey.app/u/Juriaan)\
**Post date:** [September 4, 2022, 5:58pm UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1148 "2022-09-04T17:58:07Z")

</div>

Hi all,

I do not know how to get the MQTT Hub app to send MQTT messages in JSON format and convert values. Perhaps one of you is willing to help me out. The idea is to link Homey to a device controlled in Home Assistant.

I have created a MQTT device of type light. MQTT topics are:  
ha\_test/light/kleedkamer\_lamp/state for state  
ha\_test/light/kleedkamer\_lamp/set\_light for commands

Payload for on/off should be:  
{ “state”: “OFF”} and { “state”: “ON”}

Payload for dim level should be in a 0-249 scale:  
{ “brightness”: “249”}

After a lot of trial and error, the settings are as follows. Obviously, it does not work because it is not in proper JSON format:

```auto
{
  "onoff": {
    "capability": "onoff",
    "stateTopic": "ha_test/light/kleedkamer_lamp/state",
    "setTopic": "ha_test/light/kleedkamer_lamp/set_light",
    "valueTemplate": "$.state",
    "outputTemplate": "value ? \"\"ON\"\" : \"OFF\"",
    "displayName": "Turned on"
  },
  "dim": {
    "capability": "dim",
    "stateTopic": "ha_test/light/kleedkamer_lamp/state",
    "commandTopic": "ha_test/light/kleedkamer_lamp/set_light",
    "valueTemplate": "$.brightness / 255 * 100",
    "outputTemplate": "round((value / 100) * 255)",
    "displayName": "Brightness"
  }
}

```

The only thing that properly changes in Homey when I change it in HA is on/off. Changing on/off in Homey does not work, because the payload is “ON” or “OFF” and not the JSON object stated above.

So my questions are:  
How can I transform on/off in a proper JSON format  
How can I make calculations in the value\_template on the JSON input received? The current template does not work  
How can I transform the output to make it a JSON object? Now only the value is send

I am sorry for all the questions. I cannot seem to find the right help on the internet to guide me in the right direction.

I do have a work around and that is using a virtual device controller by messages through MQTT client. I can properly format the messages in a flow. This works perfectly with sensors, which are one way of course. With lights not so much. When I change the dim level in Homey, it is not in sync with MQTT. While dimming, messages from the changing MQTT state are also coming in with a slight delay, messing up the process. Reading back in this thread, Harrie de Groot seems to have fixed that.

I appreciate your help. And thanks @HarriedeGroot for creating this app! I hope you and/or the developer community will maintain it in future as well.

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [October 3, 2022, 5:43am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1149 "2022-10-03T05:43:52Z")

</div>

Trying also to understand how to pick a value with JSONpath and use it in a MathJS expression for unit convertion. I.e  
I have a topic that delivers temperature `(t)` in decigrades and not centigrades:  
`{"type":6,"t":406}`  
Now I would like to be able to evaluate `"$.t / 10"` to get centigrades in the valueTemplate. But somehow do not get that working.

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [October 3, 2022, 6:08am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1150 "2022-10-03T06:08:56Z")

</div>

And the answer is to use `"valueTemplate": "t / 10"`

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [October 3, 2022, 8:02am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1151 "2022-10-03T08:02:36Z")

</div>

MQTT Device as a thermostat. How can I set the range scale so that maximum temperature is 40°C instead of the default 35°C? I would be using the thermostat mode to set Spa temperature to 37°C.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [October 4, 2022, 11:15am UTC](https://community.homey.app/t/mqtt-hub-gateway/6766/1152 "2022-10-04T11:15:40Z")

</div>

~~I suspect Athom has set the limits for `target_temperature` and the MQTT device uses default ranges for capabilities.  
My tado thermostat target temperature has an equal range: 4° - 35°  
(while tado itself is limited to 25°, when using their mobile app)  
[https://support.homey.app/hc/en-us/requests/new](https://support.homey.app/hc/en-us/requests/new)~~

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

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