Updating text through MQTT [solved]

Moderator: leecollings

Post Reply
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Updating text through MQTT [solved]

Post 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
Last edited by rbisschops on Wednesday 13 June 2018 22:27, edited 1 time in total.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Updating text through MQTT

Post 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&param=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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT

Post 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&param=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:

Code: Select all

{"text":"home","idx":229}
and

Code: Select all

{"svalue":"home","idx":229}
and

Code: Select all

{"data":"home","idx":229}
Neither of these work.

Thx

Ralph
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Updating text through MQTT

Post 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"}'
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT

Post 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)};
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT

Post 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
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT

Post 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?
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT

Post 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
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT [solved]

Post 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.
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT [solved]

Post 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.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest