DAVIZINHO
(DAVIZINHO)
March 7, 2020, 10:26pm
1
Hello,
I want to send the value of the sensor by mqtt_publish to my domoticz server. This will very usefull for me.
Now i create a automation with mqtt_publish service and works if I send a number value like this:
payload: '{ "command": "udevice", "idx": 174, "nvalue": 0, "svalue": "59"}'
topic: domoticz/in
If i launch this automation it works great and push the “59” value in my device throught mqtt.
But i want to use the value of a sensor: “sensor.weight”.
How can i do this?? its important respect the quotes or it will not works
thanks a lot for the support!
I think you’re looking for the payload_template
service data attribute.
Take a look here:
1 Like
123
(Taras)
March 8, 2020, 5:43am
3
payload_template: '{ "command": "udevice", "idx": 174, "nvalue": 0, "svalue": "{{states('sensor.weight')}}"}'
topic: domoticz/in
1 Like
DAVIZINHO
(DAVIZINHO)
March 8, 2020, 1:43pm
4
wow, this is my fault!. I use the payload and not the “payload_template”.
thanks a lot for this!!! i will try this night!
the solution you say to me @123 not works but this one yes:
payload_template: '{ "command": "udevice", "idx": 174, "nvalue": 0, "svalue": "{{ states.sensor.weight.state }}"}'
thanks a lot again
123
(Taras)
March 8, 2020, 2:30pm
5
DAVIZINHO:
not works
What is the error message?
These two are equivalent:
{{ states('sensor.weight') }}
{{ states.sensor.weight.state }}
Here’s an example in the Template Editor. Notice that both forms produce the same result (94
).
The primary difference is the first one is a function that will return unknown
if the entity does not exist. The second one will produce an error message if the entity doesn’t exist.
1 Like
DAVIZINHO
(DAVIZINHO)
March 8, 2020, 3:50pm
6
in the first i think the problem is the ’ character.
than closes the first of the sentence
in the second, not apears this ’ and works fine.
Thanks a lot, its work like a charm and allow to me to integrate the both systems!