Hello community,
so far, I found every solution for my home automation issues here in this forum. Now, I’ve got a problem, I cannot really solve myself. I want to publish a mqtt message like:
sensor/Testdevice/values/{“temperature”: 20, “humidity”: 40}
I’ve got a sensor for the humidity and temperature values in:
sensor.temperature_158d0001b8f488.state
states.sensor.humidity_158d0001b8f488.state
For testing, I wrote a script:
script:
mqtttest:
sequence:
- service: mqtt.publish
data:
topic: "sensor/Testdevice/values"
payload: >-
{
"temperature": {{ states.sensor.temperature_158d0001b8f488.state }},
"humidity": {{ states.sensor.humidity_158d0001b8f488.state }}
}
When I sniff my mqtt-message with “MQTT - Lightweight Client” I get the message:
sensor/Testdevice/values/{“temperature”: {{ states.sensor.temperature_158d0001b8f488.state }}, “humidity”: {{ states.sensor.humidity_158d0001b8f488.state }}}
Sure, I want the Sensor values instead of the plain name. I also testet it with:
payload: >-
{
"temperature": {{ states.sensor.temperature_158d0001b8f488.state | int }},
"humidity": {{ states.sensor.humidity_158d0001b8f488.state | int }}
}
because I though it would be an unit issue, but no difference.
Does somebody know, where I can get back to the right track?
Thank you very much