Updating text through MQTT [solved]

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

Updating text through MQTT [solved]

Post by rbisschops » Tuesday 12 June 2018 22:46

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: 816
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Updating text through MQTT

Post by waaren » 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
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

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

Re: Updating text through MQTT

Post by rbisschops » Wednesday 13 June 2018 8:49

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: 816
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Updating text through MQTT

Post by waaren » Wednesday 13 June 2018 9:08

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"}'
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

D'rMorris
Posts: 310
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT

Post by D'rMorris » Wednesday 13 June 2018 14:07

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: 79
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT

Post by rbisschops » Wednesday 13 June 2018 20:52

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: 310
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT

Post by D'rMorris » Wednesday 13 June 2018 21:29

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: 79
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: Updating text through MQTT

Post by rbisschops » Wednesday 13 June 2018 22:27

@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: 310
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Updating text through MQTT [solved]

Post by D'rMorris » 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.

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

Re: Updating text through MQTT [solved]

Post by rbisschops » Thursday 14 June 2018 12:45

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 3 guests