# MQTT topic messages to variable

**URL:** <https://community.homey.app/t/mqtt-topic-messages-to-variable/44689>\
**Category:** Questions & Help\
**Created:** [March 15, 2021, 8:25am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689 "2021-03-15T08:25:56Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![RobvandeGoor](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robvandegoor/32/20328_2.png) [@RobvandeGoor](https://community.homey.app/u/RobvandeGoor)\
**Post date:** [March 19, 2021, 8:25pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/41 "2021-03-19T20:25:16Z")

</div>

Sure I will do right away. Are there any specific things I have to look at?

---

<div class="post-metadata">

**Author:** ![scanno](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/scanno/32/8358_2.png) [@scanno](https://community.homey.app/u/scanno)\
**Post date:** [March 19, 2021, 8:26pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/42 "2021-03-19T20:26:54Z")

</div>

Just if it still works. Other apps seem to have problems with the last change.  
For the rest, its also build against SDK3

---

<div class="post-metadata">

**Author:** ![RobvandeGoor](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robvandegoor/32/20328_2.png) [@RobvandeGoor](https://community.homey.app/u/RobvandeGoor)\
**Post date:** [March 19, 2021, 8:35pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/43 "2021-03-19T20:35:26Z")

</div>

What I saw with the previous update, that I had to restart the Tasmota MQTT app…

I have updated MQTT client to V2.4.0 but I need due to this update I had to restart the Tasmota MQTT.

For the rest no issues, I receive all the different MQTT topics and messages. I don’t see any issue at the moment.

---

<div class="post-metadata">

**Author:** ![scanno](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/scanno/32/8358_2.png) [@scanno](https://community.homey.app/u/scanno)\
**Post date:** [March 19, 2021, 8:41pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/44 "2021-03-19T20:41:09Z")

</div>

Thx. Regarding restarting of the Tasmota app, that is needed because when updating the mqtt client is stopped and the topic subscriptions are gone.

---

<div class="post-metadata">

**Author:** ![RobvandeGoor](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robvandegoor/32/20328_2.png) [@RobvandeGoor](https://community.homey.app/u/RobvandeGoor)\
**Post date:** [March 19, 2021, 8:45pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/45 "2021-03-19T20:45:58Z")

</div>

Yes I know and not a problem.  
But What I do not understand is when you reboot Homey. In that case I have to manual restart soma apps like Tasmota MQTT because the MQTT client was not available yet. Maybe this has something to do with the latest firmeware update of Homey. In the past I never had this issue that there was a sorting order needed.

Never the less… The MQTT Client works fine. 😌👌🏻

---

<div class="post-metadata">

**Author:** ![Caros](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caros/32/12410_2.png) [@Caros](https://community.homey.app/u/Caros)\
**Post date:** [January 22, 2022, 1:44pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/46 "2022-01-22T13:44:00Z")

</div>

Does anyone knows how to get values from labels with spaces? For example, this is what I get in MQTT client:

received '{“temp”:18.9,“hum”:52.4,“ppmw”:7173,“Speed status”:42.5,“Internal fault”:0,“Frost cycle”:0,“Filter dirty”:0,“AirQuality (%)”:200,“AirQbased on”:64,“CO2level (ppm)”:763,

If I want to get the temp, the hum or the ppmw I use this in MQTT Hub:  
“valueTemplate”: “$.temp”,  
“valueTemplate”: “$.hum”,  
“valueTemplate”: “$.ppmw”,

This is working for me, but now I want to show the actual ppm on the device, instead of the ppmw. The label is: “CO2level (ppm)”. But when I use this:

```
"valueTemplate": "$.CO2level (ppm)"

```

it’s not showing any value. I assume that it has something to do with the space. Do I have to escape it somehow?

---

<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 22, 2022, 1:45pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/47 "2022-01-22T13:45:50Z")

</div>

> [@Caros](#):
>
> `$.CO2level (ppm)`

`$["CO2level (ppm)"]`

---

<div class="post-metadata">

**Author:** ![Caros](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caros/32/12410_2.png) [@Caros](https://community.homey.app/u/Caros)\
**Post date:** [January 22, 2022, 1:51pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/48 "2022-01-22T13:51:50Z")

</div>

That’s fast!  
I still get: unexpected $ token.

And don’t i also need the dot (.) somewhere?

---

<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 22, 2022, 1:54pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/49 "2022-01-22T13:54:21Z")

</div>

> [@Caros](#):
>
> I still get: unexpected $ token.

Try single quotes: `$['CO2level (ppm)']`

---

<div class="post-metadata">

**Author:** ![Caros](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caros/32/12410_2.png) [@Caros](https://community.homey.app/u/Caros)\
**Post date:** [January 22, 2022, 1:56pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/50 "2022-01-22T13:56:06Z")

</div>

Same:

“measure\_humidity”: {  
“capability”: “measure\_humidity”,  
“stateTopic”: “itho/ithostatus”,  
“setTopic”: “”,  
“valueTemplate”: “$.hum”,  
“outputTemplate”: “”,  
“displayName”: “Humidity”  
},  
“measure\_co2”: {  
“capability”: “measure\_co2”,  
“stateTopic”: “itho/ithostatus”,  
“setTopic”: “”,  
“valueTemplate”: $[‘CO2level (ppm)’]  
“outputTemplate”: “”,  
“displayName”: “CO2”  
}

---

<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 22, 2022, 1:57pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/51 "2022-01-22T13:57:15Z")

</div>

> [@Caros](#):
>
> “valueTemplate”: $[‘CO2level (ppm)’]

`"valueTemplate": "$['CO2level (ppm)']"`

---

<div class="post-metadata">

**Author:** ![Caros](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caros/32/12410_2.png) [@Caros](https://community.homey.app/u/Caros)\
**Post date:** [January 22, 2022, 1:59pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/52 "2022-01-22T13:59:04Z")

</div>

That’s it! Thanks a lot:)

---

<div class="post-metadata">

**Author:** ![Caros](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caros/32/12410_2.png) [@Caros](https://community.homey.app/u/Caros)\
**Post date:** [January 22, 2022, 2:22pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/53 "2022-01-22T14:22:46Z")

</div>

Since you react so fast, do you know wether Homey also have a capability like co2 and humidity for a fan/rpm?

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [January 22, 2022, 2:26pm UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/54 "2022-01-22T14:26:45Z")

</div>

> **[Tutorial: Device Capabilities - Homey Apps SDK v3](https://apps-sdk-v3.developer.homey.app/tutorial-device-capabilities.html)**

---

<div class="post-metadata">

**Author:** ![Rick\_Delput](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rick_delput/32/56448_2.png) [@Rick\_Delput](https://community.homey.app/u/Rick_Delput)\
**Post date:** [August 2, 2022, 8:36am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/56 "2022-08-02T08:36:59Z")

</div>

hi, i can not add a co2  
the dim, temperature and the humidity works,  
but when i wil add a co2 do i get an error message

 ![WhatsApp Image 2022-08-02 at 10.31.28 AM (1)](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/f/2f1c176bff1beb51f56d878c300f0e691e4b2a35.jpeg)  
 ![WhatsApp Image 2022-08-02 at 10.31.28 AM](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/6/1687179932cdc13ac96d6ea9f7ba7289ef53a908.jpeg)

```auto
{
  "dim": {
    "capability": "dim",
    "stateTopic": "itho/state",
    "setTopic": "itho/cmd",
    "valueTemplate": "round((value / 255) * 100)",
    "outputTemplate": "round((value / 100) * 255)",
    "displayName": "Dim level" 
  },
  "measure_temperature": {
    "capability": "measure_temperature",
    "stateTopic": "itho/ithostatus",
    "setTopic": "",
    "valueTemplate": "$.temp",
    "outputTemplate": "",
    "displayName": "Temperature"
  },
  "measure_humidity": {
    "capability": "measure_humidity",
    "stateTopic": "itho/ithostatus",
    "setTopic": "",
    "valueTemplate": "$.hum",
    "outputTemplate": "",
    "displayName": "Humidity"
 },
“measure_co2”: {
“capability”: “measure_co2”,
“stateTopic”: “itho/ithostatus”,
“setTopic”: “”,
“valueTemplate”: $[‘CO2level (ppm)’]
“outputTemplate”: “”,
“displayName”: “CO2”
}

```

---

<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:** [August 2, 2022, 8:41am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/57 "2022-08-02T08:41:01Z")

</div>

> [@Rick\_Delput](#):
>
> “valueTemplate”: $[‘CO2level (ppm)’]

That’s not valid, try this:

```auto
"valueTemplate": "$['CO2level (ppm)']",

```

---

<div class="post-metadata">

**Author:** ![Rick\_Delput](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rick_delput/32/56448_2.png) [@Rick\_Delput](https://community.homey.app/u/Rick_Delput)\
**Post date:** [August 2, 2022, 8:49am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/58 "2022-08-02T08:49:08Z")

</div>

it didnt work

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

```auto
{
“dim”: {
“capability”: “dim”,
“stateTopic”: “itho/state”,
“setTopic”: “itho/cmd”,
“valueTemplate”: “round((value / 255) * 100)”,
“outputTemplate”: “round((value / 100) * 255)”,
“displayName”: “Dim level”
},
“measure_temperature”: {
“capability”: “measure_temperature”,
“stateTopic”: “itho/ithostatus”,
“setTopic”: “”,
“valueTemplate”: “$.temp”,
“outputTemplate”: “”,
“displayName”: “Temperature”
},
“measure_humidity”: {
“capability”: “measure_humidity”,
“stateTopic”: “itho/ithostatus”,
“setTopic”: “”,
“valueTemplate”: “$.hum”,
“outputTemplate”: “”,
“displayName”: “Humidity”
},
“measure_co2”: {
“capability”: “measure_co2”,
“stateTopic”: “itho/ithostatus”,
“setTopic”: “”,
"valueTemplate": "$['CO2level (ppm)']"
“outputTemplate”: “”,
“displayName”: “CO2”
}

```

---

<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:** [August 2, 2022, 8:52am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/59 "2022-08-02T08:52:07Z")

</div>

You’re using smart quotes instead of regular quotes in your JSON.

---

<div class="post-metadata">

**Author:** ![Rick\_Delput](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rick_delput/32/56448_2.png) [@Rick\_Delput](https://community.homey.app/u/Rick_Delput)\
**Post date:** [August 2, 2022, 8:54am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/60 "2022-08-02T08:54:13Z")

</div>

this is what i have now and that works good.  
i want onley a co2 meter

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/5/d518676a4eb0f18ebd3e4ec1fbf428f604d77525.jpeg)

```auto
{
  "dim": {
    "capability": "dim",
    "stateTopic": "itho/state",
    "setTopic": "itho/cmd",
    "valueTemplate": "round((value / 255) * 100)",
    "outputTemplate": "round((value / 100) * 255)",
    "displayName": "Dim level" 
  },
  "measure_temperature": {
    "capability": "measure_temperature",
    "stateTopic": "itho/ithostatus",
    "setTopic": "",
    "valueTemplate": "$.temp",
    "outputTemplate": "",
    "displayName": "Temperature"
  },
  "measure_humidity": {
    "capability": "measure_humidity",
    "stateTopic": "itho/ithostatus",
    "setTopic": "",
    "valueTemplate": "$.hum",
    "outputTemplate": "",
    "displayName": "Humidity"
  }
}

```

---

<div class="post-metadata">

**Author:** ![Rick\_Delput](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rick_delput/32/56448_2.png) [@Rick\_Delput](https://community.homey.app/u/Rick_Delput)\
**Post date:** [August 2, 2022, 8:58am UTC](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689/61 "2022-08-02T08:58:27Z")

</div>

what am I doing wrong,  
this is my first time using this

[Previous page](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689.md?page=2)

[Next page](https://community.homey.app/t/mqtt-topic-messages-to-variable/44689.md?page=4)
