Page 1 of 1
Updating text through MQTT [solved]
Posted: Tuesday 12 June 2018 22:46
by rbisschops
Hi all,
Probably a simple question, but i’m strugling with it.
What is the json string I need to create and push through MQTT to update a text dummy text sensor with a new text?
Thx
Ralph
Re: Updating text through MQTT
Posted: Tuesday 12 June 2018 23:19
by waaren
rbisschops wrote: ↑Tuesday 12 June 2018 22:46
...
What is the json string I need to create and push through MQTT to update a text dummy text sensor with a new text?
from
this wiki page
http://domoticzIP:domoticzPORT//json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEXT
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEXT = Text you want to display
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 8:49
by rbisschops
waaren wrote: ↑Tuesday 12 June 2018 23:19
rbisschops wrote: ↑Tuesday 12 June 2018 22:46
...
What is the json string I need to create and push through MQTT to update a text dummy text sensor with a new text?
from
this wiki page
http://domoticzIP:domoticzPORT//json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEXT
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEXT = Text you want to display
Thx @waaren, but thagt is not what I'm looking for. I found and tried the API call from a browser. This is working fine. I want to push the data through MQTT, so I need to create a JSON string. I tried:
and
and
Neither of these work.
Thx
Ralph
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 9:08
by waaren
maybe this will help
from
old topic on this forum
I think you mean: mosquitto_pub -h 192.168.1.120 -t 'domoticz/in' -m '{"command": "udevice", "idx": 19, "svalue": "Test Test Test"}'
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 14:07
by D'rMorris
The correct syntax is indeed:
{"command": "udevice", "idx": nnn, "svalue": "your text"}
I use a NodeRed function to update my location (latitude in this example) to a text sensor and there I use:
Code: Select all
msg.payload = {"command": "udevice", "idx": nnn, "svalue": String(msg.payload.lat)};
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 20:52
by rbisschops
Thx @waaren and @D'rMorris for the anwers,
however it does not seem to work. I'm also using NodeRed. It creates:
Code: Select all
{"command":"udevice","idx":229,"svalue":"unknown"}
However when pushed to Domoticz/in, nothing happens.
I dubble checked the idx twice.
For reference, this:
Code: Select all
{"command":"switchlight","idx":218,"switchcmd":"On"}
works perfectly. Its in the same NodeRed flow as the text change above. So imho the flow from NodeRed to Domoticz works.
Edit: For reference, I'm on the last stable version: 3.8153
What am I overlooking here?
Thx again!
Ralph
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 21:29
by D'rMorris
What happens if you update the text sensor first with an normal URL JSON?
As reference, this is my script in NodeRed:
Code: Select all
msg.payload = {"command": "udevice", "idx": nnn, "svalue": "test")};
return msg;
I'm also runinng the stable version.
Just to be sure: you are sending data to domoticz/in (all lowercase) right? Perhaps you can create an inject input, then a script function and then the MQTT output and a debug node? And then try to debug this way?
Re: Updating text through MQTT
Posted: Wednesday 13 June 2018 22:27
by rbisschops
@D'rMorris sometimes life is simple and an error easily overlooked. domoticz/in instead of Domoticz/in was thé golden tip!
Thx!!
Ralph
Re: Updating text through MQTT [solved]
Posted: Thursday 14 June 2018 6:42
by D'rMorris
rbisschops wrote:@D'rMorris sometimes life is simple and an error easily overlooked. domoticz/in instead of Domoticz/in was thé golden tip!
Thx!!
Ralph
Very welcome, glad you got it sorted out! Since the other flow was working, do you have multiple MQTT configutations defined? I have only 1 domoticz/in configuration and all my flows use that one.
Re: Updating text through MQTT [solved]
Posted: Thursday 14 June 2018 12:45
by rbisschops
D'rMorris wrote: ↑Thursday 14 June 2018 6:42
rbisschops wrote:@D'rMorris sometimes life is simple and an error easily overlooked. domoticz/in instead of Domoticz/in was thé golden tip!
Thx!!
Ralph
Very welcome, glad you got it sorted out! Since the other flow was working, do you have multiple MQTT configutations defined? I have only 1 domoticz/in configuration and all my flows use that one.
Same with me, I only use domoticz/in. As mentioned before, I also use NodeRed and a Mosquitto broker on a (separate) Pi. For now I mainly pull in Owntracks positioning information for my "anyone at home" scenario's.