# \[APP\]\[Pro\] MQTT Hub - Community version

**URL:** <https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463>\
**Category:** Apps\
**Tags:** app, mqtt, homey-pro\
**Created:** [July 26, 2024, 3:58pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463 "2024-07-26T15:58:53Z")\
**Posts on this page:** 20\
**Page:** 8

<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:** [December 21, 2024, 9:40pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/149 "2024-12-21T21:40:09Z")

</div>

New **test version 4.3.5** :

- Fixed unit check error for enum capabilities.
- Added **JavaScript function as valueTemplate/outputTemplate**.

Your enum conversion from numeric to string is not possible with MathJS expression (I think).  
That’s why I just added the possibility to use a JS function as template.  
Use this syntax:  
(value) =\> { return value \* 100 }

@Filip_Sutovsky  
You can try to use th enew JS function as value template:

```auto
(value) => { return value > 0 ? 'charging' : 'discharging'}

```

---

<div class="post-metadata">

**Author:** ![Filip\_Sutovsky](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/filip_sutovsky/32/79116_2.png) [@Filip\_Sutovsky](https://community.homey.app/u/Filip_Sutovsky)\
**Post date:** [December 21, 2024, 9:56pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/150 "2024-12-21T21:56:25Z")

</div>

The conversion works with MathJS with the `unit check` fix. The JS evaluation seems like a nice addon, but I’m afraid that using pure JS eval can introduce unwanted security risk. I’m totally not familiar with homie’s architecture, so I can’t tell to which data possible XSS attack could have access to, but I know from professional experience that it is a big no no 😅

---

<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:** [December 21, 2024, 10:10pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/151 "2024-12-21T22:10:05Z")

</div>

Yes, agree. I hope it’s still safe. It runs locllally, you need to be logged in to set device settings.  
And it’s so flexible. Parhaps on MQTT it’s not really needed if you have simple topic values. For HA app I used it for many checks up to array and string handling.

Can you share your MathJS expression? Haven’t seen a number=\>text conversion.

---

<div class="post-metadata">

**Author:** ![Filip\_Sutovsky](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/filip_sutovsky/32/79116_2.png) [@Filip\_Sutovsky](https://community.homey.app/u/Filip_Sutovsky)\
**Post date:** [December 21, 2024, 10:15pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/152 "2024-12-21T22:15:23Z")

</div>

👍

the initial capability setup works as expected after the fix:

```auto
{
  "battery_charging_state": {
    "capability": "battery_charging_state",
    "stateTopic": "deye/battery/power",
    "setTopic": "",
    "valueTemplate": "value > 0 ? 'charging' : 'discharging'",
    "outputTemplate": "",
    "displayName": "Battery charging state"
  }
}

```

 ![Screenshot 2024-12-21 at 23.14.34](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/0/700264e07cc8442a9a3545fd55be3516e9367deb.jpeg)

---

<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:** [December 22, 2024, 12:34pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/153 "2024-12-22T12:34:08Z")

</div>

Any chances in hunting down why MQTT Hub uses a lot of memory? Decreasing memory usage would help in keeping Homey stable over night when the cloud backup happens.

Currently MQTT Hub is the top memory user of apps installed.

---

<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:** [December 22, 2024, 12:40pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/154 "2024-12-22T12:40:05Z")

</div>

The app uses a lot of Node modules. But that was already the case as Harrie developed the app.  
Anyone knowing some details about the used modules - and how to replace them with small coding (can also be copy/past some parts into a local library) can optimize it 😉  
I don’t know the modules well enough.

---

<div class="post-metadata">

**Author:** ![Dirk\_Buekenhoudt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_buekenhoudt/32/4116_2.png) [@Dirk\_Buekenhoudt](https://community.homey.app/u/Dirk_Buekenhoudt)\
**Post date:** [December 22, 2024, 2:46pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/155 "2024-12-22T14:46:08Z")

</div>

I have created a MQTT hub virtual device with alarm-motion capabilities. The name of the device is sensor.mqtt.

In the advanced settings the Topics field has the following value:  
{  
“alarm\_motion”: {  
“capability”: “alarm\_motion”,  
“stateTopic”: “”,  
“setTopic”: “”,  
“valueTemplate”: “”,  
“outputTemplate”: “”,  
“displayName”: “Motion alarm”  
}  
}  
Logging in with MQTT explorer and publishing a message on topic  
homie/homey-devices/sensormqtt/alarm-motion/set false  
Is NOT changing the state of the motion sensor.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/2/422394513e2ce8263981e91a3a44630b5148fa88.png)

Changing the value with a card works perfectly.

---

<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:** [December 22, 2024, 3:45pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/156 "2024-12-22T15:45:43Z")

</div>

Your stateTopic element in your settings doesn’t have a Mqtt topic set.

---

<div class="post-metadata">

**Author:** ![Dirk\_Buekenhoudt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_buekenhoudt/32/4116_2.png) [@Dirk\_Buekenhoudt](https://community.homey.app/u/Dirk_Buekenhoudt)\
**Post date:** [December 22, 2024, 4:09pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/157 "2024-12-22T16:09:51Z")

</div>

how should it look like?

---

<div class="post-metadata">

**Author:** ![Filip\_Sutovsky](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/filip_sutovsky/32/79116_2.png) [@Filip\_Sutovsky](https://community.homey.app/u/Filip_Sutovsky)\
**Post date:** [December 22, 2024, 6:31pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/158 "2024-12-22T18:31:05Z")

</div>

> [@Dirk\_Buekenhoudt](#):
>
> {  
> “alarm\_motion”: {  
> “capability”: “alarm\_motion”,  
> “stateTopic”: “”,  
> “setTopic”: “”,  
> “valueTemplate”: “”,  
> “outputTemplate”: “”,  
> “displayName”: “Motion alarm”  
> }  
> }

@Dirk_Buekenhoudt probably like this

```auto
{
  “alarm_motion”: {
    “capability”: “alarm_motion”,
    “stateTopic”: “homie/homey-devices/sensormqtt/alarm-motion”,
    “setTopic”: “homie/homey-devices/sensormqtt/alarm-motion/set”,
    “valueTemplate”: “”,
    “outputTemplate”: “”,
    “displayName”: “Motion alarm”
  }
}

```

---

<div class="post-metadata">

**Author:** ![Filip\_Sutovsky](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/filip_sutovsky/32/79116_2.png) [@Filip\_Sutovsky](https://community.homey.app/u/Filip_Sutovsky)\
**Post date:** [December 22, 2024, 7:10pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/159 "2024-12-22T19:10:52Z")

</div>

Consider these MQTT topics

 ![Screenshot 2024-12-22 at 19.48.58](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/4/046d9304125180d65f9521b40c362831b3259033.png)

I need to create one value from multiple topics. Specifically, I need to create `measure_power` capability, which would be a addition of `deye/dc/pv1/power` and `deye/dc/pv2/power`. How can I do that? I’ve tried multiple ways, but can’t seem to make it work.  
For example when I tried mqtt wilcards like `deye/dc/+/power`, icoming message from subscribed topics couldn’t be processed, becase MQTT Hub tries to match them exactly and `deye/dc/pv1/power` (incoming topic) != `deye/dc/+/power` (definition saved in valueTemplate)

---

<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:** [December 22, 2024, 8:43pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/160 "2024-12-22T20:43:32Z")

</div>

The app subscribes to topics. If the topic changes, the app writes the value into the capability.  
If you would register topics with wildcard, every topic would appear as changed value and you don’t get the other to sum up.

As workaround you can create a virtual device. Then use the three Mqtt capabilities as trigger and sum up the capabilities into the virtual device.

---

<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:** [December 22, 2024, 9:02pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/161 "2024-12-22T21:02:11Z")

</div>

Make sure to disable the log functionality. It can grow very large and might cause partition space issues.  
I don’t expect app memory usage is influencing backup functionality

---

<div class="post-metadata">

**Author:** ![Dirk\_Buekenhoudt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_buekenhoudt/32/4116_2.png) [@Dirk\_Buekenhoudt](https://community.homey.app/u/Dirk_Buekenhoudt)\
**Post date:** [December 22, 2024, 10:21pm UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/162 "2024-12-22T22:21:13Z")

</div>

> [@Filip\_Sutovsky](#):
>
> ```auto
> {
> “alarm_motion”: {
> “capability”: “alarm_motion”,
> “stateTopic”: “homie/homey-devices/sensormqtt/alarm-motion”,
> “setTopic”: “homie/homey-devices/sensormqtt/alarm-motion/set”,
> “valueTemplate”: “”,
> “outputTemplate”: “”,
> “displayName”: “Motion alarm”
> }
> }
> 
> ```

After some testing this configuration worked for me  
{  
“alarm\_motion”: {  
“capability”: “alarm\_motion”,  
“stateTopic”: “homie/homey-devices/sensormqtt/alarm-motion”,  
“setTopic”: “homie/homey-devices/sensormqtt/alarm-motion”,  
“valueTemplate”: “”,  
“outputTemplate”: “”,  
“displayName”: “Motion alarm”  
}  
}

by sending MQTT message  
homie/homey-devices/sensormqtt/alarm-motion true

Note that virtual devices lamp need to be switched with teh following MQTT message  
homie/ **homey** /kitchenlight/onoff/ **set** true

Thanks all for your help!

---

<div class="post-metadata">

**Author:** ![Awangens](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/awangens/32/7789_2.png) [@Awangens](https://community.homey.app/u/Awangens)\
**Post date:** [December 25, 2024, 12:01am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/163 "2024-12-25T00:01:19Z")

</div>

Amazing thanks for the!  
Works like a charm!

 ![IMG_0430](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/2/c225f20d0a614afe6723df5ac0fc3e7d8f4a3d31.jpeg)

---

<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:** [January 5, 2025, 10:13am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/164 "2025-01-05T10:13:13Z")

</div>

Hello to everyone familiar with HA internal sensor handling.  
After upgrading to HA 2025.1 I got these messages for Entities imported via MQTT Hub:

![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/5/65b4c2865ccc9b6d7984ac45afe028767857c654.png)

Details for error message:

> In the past, statistics were generated for “Gas Meter Gas Meter” (sensor.gaspayer\_gaspayer), but it no longer has a state class and therefore long-term statistics can no longer be generated for it.
> 
> Statistics cannot be generated until this entity has a supported state class.
> 
> If the state class was previously provided by an integration, this may be a bug. Please report the issue.
> 
> If you previously set the state class yourself, please correct it. The different state classes and their usage can be found in the developer documentation.  
> If the state class has been permanently removed, you may want to delete the corresponding long-term statistics from your database.
> 
> Do you want to permanently delete the long-term statistics of sensor.gaspayer\_gaspayer from your database?

HA links to this page:

> **[Sensor entity | Home Assistant Developer Docs](https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics)**
>
> A sensor is a read-only entity that provides some information. Information has a value and optionally, a unit of measurement. Derive entity platforms from homeassistant.components.sensor.SensorEntity

Is it somehow needed to set these classes for MQTT export? Has anyone experience about the syntax for Homie standard?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 5, 2025, 10:31am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/165 "2025-01-05T10:31:17Z")

</div>

> [@RonnyW](#):
>
> Is it somehow needed to set these classes for MQTT export? Has anyone experience about the syntax for Homie standard?

I can’t find anything in the `ha-homie` code that would enable you to set `state_class` other than manual configuration for each device.

But from what I remember when this change was introduced (a few months ago I think?), the warning that’s being shown was added because previously, a missing `state_class` would just be silently ignored and you wouldn’t have long-term statistics anyway.

---

<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:** [January 5, 2025, 10:38am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/166 "2025-01-05T10:38:05Z")

</div>

Thanks, Robert.  
So we can’t set it via MQTT, right? It’s more for integrations to set these class (like energy settings in Homey)?  
So there is nothing to do for now?

What statistics are meant in this case? Is HA calculating additional statistics for such energy data.  
I have to say that I did not go deeper with energy until the HA energy dashboard.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 5, 2025, 10:49am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/167 "2025-01-05T10:49:27Z")

</div>

> [@RonnyW](#):
>
> So we can’t set it via MQTT, right?

Not with _Homie_ you can’t. HA MQTT Discovery supports it.

> [@](#):
>
> It’s more for integrations to set these class (like energy settings in Homey)?

Yes and no. The `state_class` for an entity tells Home Assistant what kind of value it provides, either a measurement value, a “total” value or a “total increasing” value. The Homie integration will have no idea what the actual values that it’s importing into HA represent, so it should be the “Homie broadcaster” (your app) that sets it, _if that were possible_.

> [@](#):
>
> So there is nothing to do for now?

I don’t think so, no.

> [@](#):
>
> What statistics are meant in this case? Is HA calculating additional statistics for such energy data.

It’s for long-term statistics for sensors (_any_ sensor that provides a numerical value), similar to what Insights does with sensor data: averaging values over a longer period.

For instance, here’s my “outdoor temperature” sensor graph:

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

I store 10 days worth of actual values, which is shown as dark blue, and the long-term statistics part (calculated by HA by storing average values) is shown as light blue.

---

<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:** [January 5, 2025, 11:01am UTC](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463/168 "2025-01-05T11:01:23Z")

</div>

> [@robertklep](#):
>
> Not with _Homie_ you can’t. HA MQTT Discovery supports it.

That’s the part the app can support. The Homie topic is just the data storage, the HA autodiscovery links to it. I can check if I can add this class for autodiscovery export.  
I’m not sure how this can be mapped. Currently only based on capability id (meter\* vs. measure\*)?

[Previous page](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463.md?page=7)

[Next page](https://community.homey.app/t/app-pro-mqtt-hub-community-version/113463.md?page=9)
