Cant get MQTT output into domoticz Topic is solved

Moderator: leecollings

MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Cant get MQTT output into domoticz

Post by MikeyMan »

Hi All,

i'm fiddling around with NodeRed, to get some API output into domoticz.
I think i've come some ways already.

I've been able to post an MQTT message in the right folder:
2022-09-02 11_57_20-MQTT Explorer.png
2022-09-02 11_57_20-MQTT Explorer.png (9.27 KiB) Viewed 2297 times
And added the dummy to domoticz:
2022-09-02 Domoticz.png
2022-09-02 Domoticz.png (14.4 KiB) Viewed 2298 times
However, the data isn't showing up.
Any thoughts?
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cant get MQTT output into domoticz

Post by waltervl »

Do you have a MQTT Client gateway created that is listening to the broker? See wiki:
https://www.domoticz.com/wiki/MQTT#Add_ ... Gateway.22

What does the Domoticz log file say? does it see an incoming message?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

I think i did:
2022-09-02 13_48_01-domoticz.png
2022-09-02 13_48_01-domoticz.png (45.67 KiB) Viewed 2282 times
And i see the 'out' folder being filled nicely.

I see some stuff coming along from my earlier more difficult tries:
2022-09-02 13_49_22-mqtt.png
2022-09-02 13_49_22-mqtt.png (123.75 KiB) Viewed 2282 times
So something is happening i'd think.
thought i'd try it out with a simple text. But no clue why nothing is coming along.
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

Also; having to manually create devices and idx's isnt the most convenient...
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

Trying this:

http://10.0.0.4:8080/json.htm?type=comm ... value=text

i also get an error... No clue if this is correct though.

{
"status" : "ERR"
}
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Cant get MQTT output into domoticz

Post by waltervl »

Perhaps add nvalue=0 in url or "nvalue":0 in MQTT load.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

waltervl wrote: Friday 02 September 2022 15:01 Perhaps add nvalue=0 in url or "nvalue":0 in MQTT load.
No luck i'm afraid... :(
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

Even deleted the MQTT hardware and re-added, but no luck
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Cant get MQTT output into domoticz

Post by FireWizard »

Could you please post your Node Red flow?
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

FireWizard wrote: Saturday 03 September 2022 9:45 Could you please post your Node Red flow?

Of course... Work in progress of course ;)

Code: Select all

[{"id":"743a62898f598be4","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"aba1dab9e8709847","type":"http request","z":"743a62898f598be4","name":"Get Version","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.199:8443/enduser-mobile-web/1/enduserAPI/apiVersion","tls":"d141c56ce52dcd5d","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":610,"y":120,"wires":[["d58a15c4c09ebd12","9c0b16ffc945e95a","8690d30946cad6ca"]]},{"id":"d58a15c4c09ebd12","type":"debug","z":"743a62898f598be4","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":100,"wires":[]},{"id":"9c0b16ffc945e95a","type":"debug","z":"743a62898f598be4","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.protocolVersion","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":160,"wires":[]},{"id":"1c61a2e3f17004cc","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":120,"wires":[["aba1dab9e8709847"]]},{"id":"8690d30946cad6ca","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"Tahoma","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":920,"y":240,"wires":[]},{"id":"fc6d9990e9735efe","type":"http request","z":"743a62898f598be4","name":"Get Devices","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.161:8443/enduser-mobile-web/1/enduserAPI/setup/devices","tls":"d141c56ce52dcd5d","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":430,"y":420,"wires":[["792793a85f7af9e3","0f5c255927c3a287"]]},{"id":"0d0b145a46d08eb6","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":420,"wires":[["fc6d9990e9735efe"]]},{"id":"27bcb8ebe2e66553","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":1350,"y":420,"wires":[]},{"id":"14b2125b610f82a3","type":"debug","z":"743a62898f598be4","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.label","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":500,"wires":[]},{"id":"792793a85f7af9e3","type":"debug","z":"743a62898f598be4","name":"debug 9","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":500,"wires":[]},{"id":"390f410fdeae6dec","type":"change","z":"743a62898f598be4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"domoticz/in/\" & msg.payload.label","tot":"jsonata"},{"t":"delete","p":"payload.creationTime","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":420,"wires":[["0d414e1eda85b389","164e4e3ca1fddfca","1f4ca39d34a2136f"]]},{"id":"0d414e1eda85b389","type":"debug","z":"743a62898f598be4","name":"debug 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":500,"wires":[]},{"id":"0f5c255927c3a287","type":"split","z":"743a62898f598be4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":420,"wires":[["14b2125b610f82a3","390f410fdeae6dec"]]},{"id":"164e4e3ca1fddfca","type":"function","z":"743a62898f598be4","name":"function 1","func":"//if(msg.payload.deviceURL === \"io://2017-8871-5701/3196925\")\n//{\n//    return msg;\n//}\n\nif (msg.payload.deviceURL === \"io://2017-8871-5701/3196925\") \n    {\n    msg.payload = { \"idx\": 388, \"svalue\": \"test\", \"nvalue\": 0}    \n    return msg;\n    }\n\n\n//{ \"command\": \"udevice\", \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n//{ \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":420,"wires":[["27bcb8ebe2e66553","5569758a44d2d493"]]},{"id":"5569758a44d2d493","type":"debug","z":"743a62898f598be4","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1200,"y":500,"wires":[]},{"id":"1f4ca39d34a2136f","type":"debug","z":"743a62898f598be4","name":"debug 12","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1220,"y":320,"wires":[]},{"id":"d141c56ce52dcd5d","type":"tls-config","name":"TLS","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""},{"id":"92e5b2c.00a8b5","type":"mqtt-broker","name":"MQTT (NAS)","broker":"10.0.0.4","port":"1883","clientid":"Node_Red_Client","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Cant get MQTT output into domoticz

Post by FireWizard »

Hello @MikeyMan,

Thanks for posting your flow.

I will look at it later today or tomorrow.

But before that, can you confirm, as I saw some issues in your screenshots, the following:

1. Your Domoticz is running with IP address 10.0.0.4. Running the default port 8080.
2. Your MQTT broker is using this IP address 10.0.0.4 as well with the default port 1883. Is it Mosquitto? See screenshot 02 Sep 2022, 13:50
3. In Domoticz you created a "Text" device, with IDX 388.

You wrote:
Also; having to manually create devices and idx's isnt the most convenient...
For now to start it is the best way to do it manually. Later on you may want to go to "auto detection".

You tried to send some data to Domoticz. From where? Browser or did you try Node Red?

At least there is one thing, that is incorrect.
See your screenshot of MQTT Explorer (Your post of 02 Sep 2022, 11:56 ).

The JSON object you published ( {"command":"udevice", "idx":388,"svalue":"test"} ) has been published to the wrong topic and so Domoticz will never be able to handle it correctly.
The topic should be: domoticz/in and not domoticz/in/Zonwering Balkonraam

Regards
Last edited by FireWizard on Wednesday 12 April 2023 23:29, edited 1 time in total.
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

Thanks for the hints. I thought that based on the topic, you could differentiate between the devices, same as domotic does on the out folder? Could be the wrong assumption of course :)

Would make it easier to see what messages come in for which device?

As per your questions:
Domoticz is running on 10.0.0.30:8080 (Rpi)
NodeRed is running on 10.0.0.4:1880
Mosquitto is running on 10.0.0.4:1883

Edit:removed the topic, but no luck yet...
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Cant get MQTT output into domoticz

Post by FireWizard »

Hello @MikeyMan,

You wrote:
I thought that based on the topic, you could differentiate between the devices, same as domotic does on the out folder? Could be the wrong assumption of course :)

Would make it easier to see what messages come in for which device?
It is possible to install more than one hardware device "MQTT Client Gateway with LAN interface".
In this case you can configure these with different topics, e.g. domoticz/in/topic1 and domoticz/in/topic2.
Disable domoticz/out on one of them.

However, I doubt, if you install many hardware devices of type "MQTT Client Gateway with LAN interface", that it will become easier/clearer.
Domoticz is running on 10.0.0.30:8080 (Rpi)
In this case your test of sending a message to Domoticz (see your post 02 Sep 2022, 14:24 ), http://10.0.0.4:8080/json.htm?type=comm ... value=text. is wrong and should be http://10.0.0.30:8080/json.htm?type=com ... value=text
Edit:removed the topic, but no luck yet...
You should not remove the topic, but change the topic to "domoticz/in" (without quotes)

Let's go to your flow.

I do not know your network setup, but I saw a few things that attracted my attention.

1. In the first HTTP Request node, you use IP address 10.0.0.199, while in the second you use 10.0.0.161. Is that correct?

2. In the "Change" node, you use a JSONata expression in order to set the topic. As discussed earlier, in Domoticz the topic, that Domoticz subscribes to, has been set to domoticz/in. As said before you can define multiple hardware devices for MQTT, but this is currently not the case.
In my opinion you can remove the complete Change node. There is no need to delete msg.payload.creationTime .

3. In the "Function" node, you can remove "nvalue": 0, as there is no need for it. It does not harm either.

4. In the MQTT output node, insert the topic domoticz/in.

That should work for you.

I see also a number of things in your screenshot, posted 02 Sep 2022, 13:50

What is happening with the Shelly and Heishamon. There is one client that failed to start and to connect with the MQTT server at IP address 10.0.0.4.
I see also that you did sent a lot of messages to domoticz/in, which Domoticz cannot understand. (Invalid/Unhandled data received!)

You cannot define your own payload for MQTT, but has to confirm to the Domoticz JSON format.
An example you can find at: https://piandmore.wordpress.com/2019/02 ... -domoticz/ and at https://www.domoticz.com/wiki/MQTT

Let me know.

Regards
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

Thanks for the tips! I'm struggling a bit from my holiday address, but I'll get back asap.
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

FireWizard wrote: Saturday 03 September 2022 21:40 Hello @MikeyMan,

You wrote:

It is possible to install more than one hardware device "MQTT Client Gateway with LAN interface".
In this case you can configure these with different topics, e.g. domoticz/in/topic1 and domoticz/in/topic2.
Disable domoticz/out on one of them.
I was hoping that the in-folder could work the same as the out folder. With a topic per device. But if that's not the case, we'll have to make it work

However, I doubt, if you install many hardware devices of type "MQTT Client Gateway with LAN interface", that it will become easier/clearer.
Agree, probably not.
In this case your test of sending a message to Domoticz (see your post 02 Sep 2022, 14:24 ), http://10.0.0.4:8080/json.htm?type=comm ... value=text. is wrong and should be http://10.0.0.30:8080/json.htm?type=com ... value=text
That was mighty stupid of me... I am doing too many things at the same time. Amongst others, I was trying to move my domoticz setup from pi to Nas, with master slave. That's why I messed up the IPs. My apologies.

Although the good news is that the JSON itself was correct. And with the right op it's working now.
You should not remove the topic, but change the topic to "domoticz/in" (without quotes)
Did that now. However I can't seem to get mqtt working with port forwarding from my holiday address.
Let's go to your flow.

I do not know your network setup, but I saw a few things that attracted my attention.

1. In the first HTTP Request node, you use IP address 10.0.0.199, while in the second you use 10.0.0.161. Is that correct?
Yes, I changed the IP address of the tahoma box.
2. In the "Change" node, you use a JSONata expression in order to set the topic. As discussed earlier, in Domoticz the topic, that Domoticz subscribes to, has been set to domoticz/in. As said before you can define multiple hardware devices for MQTT, but this is currently not the case.
In my opinion you can remove the complete Change node. There is no need to delete msg.payload.creationTime .
Think youre right. I was trying to make the output more readable. Change node was the first thing I tried. But with the function node that's now obsolete.
3. In the "Function" node, you can remove "nvalue": 0, as there is no need for it. It does not harm either.
Tried that on a suggestion earlier in this topic. I'll remove it again.
4. In the MQTT output node, insert the topic domoticz/in.

That should work for you.
I'll fiddle around some more. Although without visibility on the mqtt server. Probably a bit in the blind.
I see also a number of things in your screenshot, posted 02 Sep 2022, 13:50

What is happening with the Shelly and Heishamon. There is one client that failed to start and to connect with the MQTT server at IP address 10.0.0.4.
I see also that you did sent a lot of messages to domoticz/in, which Domoticz cannot understand. (Invalid/Unhandled data received!)

You cannot define your own payload for MQTT, but has to confirm to the Domoticz JSON format.
An example you can find at: https://piandmore.wordpress.com/2019/02 ... -domoticz/ and at https://www.domoticz.com/wiki/MQTT

Let me know.

Regards
Again, thans for your elaborate help, keep you posted
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Cant get MQTT output into domoticz

Post by FireWizard »

Hi @MikeyMan,

Can you send a screenshot of the output of the Debug Node, called "debug 11", at least if you use the latest Node Red release (3.0.2).
This is the Debug Node, connected to the Function node, called "function 1".

Regards
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

FireWizard wrote: Monday 05 September 2022 11:21 Hi @MikeyMan,

Can you send a screenshot of the output of the Debug Node, called "debug 11", at least if you use the latest Node Red release (3.0.2).
This is the Debug Node, connected to the Function node, called "function 1".

Regards
Here you go:
0ADC8214-92EB-40AF-8849-4E60785E1AC2.png
0ADC8214-92EB-40AF-8849-4E60785E1AC2.png (278.63 KiB) Viewed 2119 times
Took removal of the time stamp out.

Writing value to text with JSON succeeded. Even remotely ;)
Still no luck from nodered though.

Code: Select all

 [{"id":"743a62898f598be4","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"aba1dab9e8709847","type":"http request","z":"743a62898f598be4","name":"Get Version","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.199:8443/enduser-mobile-web/1/enduserAPI/apiVersion","tls":"d141c56ce52dcd5d","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":610,"y":120,"wires":[["d58a15c4c09ebd12","9c0b16ffc945e95a","8690d30946cad6ca"]]},{"id":"d58a15c4c09ebd12","type":"debug","z":"743a62898f598be4","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":100,"wires":[]},{"id":"9c0b16ffc945e95a","type":"debug","z":"743a62898f598be4","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.protocolVersion","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":160,"wires":[]},{"id":"1c61a2e3f17004cc","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":120,"wires":[["aba1dab9e8709847"]]},{"id":"8690d30946cad6ca","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"Tahoma","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":920,"y":240,"wires":[]},{"id":"fc6d9990e9735efe","type":"http request","z":"743a62898f598be4","name":"Get Devices","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.161:8443/enduser-mobile-web/1/enduserAPI/setup/devices","tls":"d141c56ce52dcd5d","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":430,"y":420,"wires":[["792793a85f7af9e3","0f5c255927c3a287"]]},{"id":"0d0b145a46d08eb6","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":420,"wires":[["fc6d9990e9735efe"]]},{"id":"27bcb8ebe2e66553","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":1350,"y":420,"wires":[]},{"id":"14b2125b610f82a3","type":"debug","z":"743a62898f598be4","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.label","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":500,"wires":[]},{"id":"792793a85f7af9e3","type":"debug","z":"743a62898f598be4","name":"debug 9","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":500,"wires":[]},{"id":"390f410fdeae6dec","type":"change","z":"743a62898f598be4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"domoticz/in/\"","tot":"jsonata"},{"t":"delete","p":"payload.creationTime","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":420,"wires":[["0d414e1eda85b389","164e4e3ca1fddfca","1f4ca39d34a2136f"]]},{"id":"0d414e1eda85b389","type":"debug","z":"743a62898f598be4","name":"debug 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":500,"wires":[]},{"id":"0f5c255927c3a287","type":"split","z":"743a62898f598be4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":420,"wires":[["14b2125b610f82a3","390f410fdeae6dec"]]},{"id":"164e4e3ca1fddfca","type":"function","z":"743a62898f598be4","name":"function 1","func":"//if(msg.payload.deviceURL === \"io://2017-8871-5701/3196925\")\n//{\n//    return msg;\n//}\n\nif (msg.payload.deviceURL === \"io://2017-8871-5701/3196925\") \n    {\n    msg.payload = { \"idx\": 388, \"svalue\": \"test 1\" } \n  //  msg.topic = { \"domoticz/in\" }\n    return msg;\n    }\n\n\n//{ \"command\": \"udevice\", \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n//{ \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":420,"wires":[["27bcb8ebe2e66553","5569758a44d2d493"]]},{"id":"5569758a44d2d493","type":"debug","z":"743a62898f598be4","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1200,"y":500,"wires":[]},{"id":"1f4ca39d34a2136f","type":"debug","z":"743a62898f598be4","name":"debug 12","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1220,"y":320,"wires":[]},{"id":"d141c56ce52dcd5d","type":"tls-config","name":"TLS","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""},{"id":"92e5b2c.00a8b5","type":"mqtt-broker","name":"MQTT (NAS)","broker":"10.0.0.4","port":"1883","clientid":"Node_Red_Client","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

At this point of course frankly this has nothing to do with an api call, but just trying to get the simplest output into domoticz.

Tried an even simpler flow:

Code: Select all

 [{"id":"743a62898f598be4","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"aba1dab9e8709847","type":"http request","z":"743a62898f598be4","name":"Get Version","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.199:8443/enduser-mobile-web/1/enduserAPI/apiVersion","tls":"d141c56ce52dcd5d","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":610,"y":120,"wires":[["d58a15c4c09ebd12","9c0b16ffc945e95a","8690d30946cad6ca"]]},{"id":"d58a15c4c09ebd12","type":"debug","z":"743a62898f598be4","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":100,"wires":[]},{"id":"9c0b16ffc945e95a","type":"debug","z":"743a62898f598be4","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.protocolVersion","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":160,"wires":[]},{"id":"1c61a2e3f17004cc","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":120,"wires":[["aba1dab9e8709847"]]},{"id":"8690d30946cad6ca","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"Tahoma","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":920,"y":240,"wires":[]},{"id":"fc6d9990e9735efe","type":"http request","z":"743a62898f598be4","name":"Get Devices","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://10.0.0.161:8443/enduser-mobile-web/1/enduserAPI/setup/devices","tls":"d141c56ce52dcd5d","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":430,"y":420,"wires":[["792793a85f7af9e3","0f5c255927c3a287"]]},{"id":"0d0b145a46d08eb6","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":420,"wires":[["fc6d9990e9735efe"]]},{"id":"27bcb8ebe2e66553","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":1350,"y":420,"wires":[]},{"id":"14b2125b610f82a3","type":"debug","z":"743a62898f598be4","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.label","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":500,"wires":[]},{"id":"792793a85f7af9e3","type":"debug","z":"743a62898f598be4","name":"debug 9","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":500,"wires":[]},{"id":"390f410fdeae6dec","type":"change","z":"743a62898f598be4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"domoticz/in/\"","tot":"jsonata"},{"t":"delete","p":"payload.creationTime","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":420,"wires":[["0d414e1eda85b389","164e4e3ca1fddfca","1f4ca39d34a2136f"]]},{"id":"0d414e1eda85b389","type":"debug","z":"743a62898f598be4","name":"debug 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":500,"wires":[]},{"id":"0f5c255927c3a287","type":"split","z":"743a62898f598be4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":420,"wires":[["14b2125b610f82a3","390f410fdeae6dec"]]},{"id":"164e4e3ca1fddfca","type":"function","z":"743a62898f598be4","name":"function 1","func":"//if(msg.payload.deviceURL === \"io://2017-8871-5701/3196925\")\n//{\n//    return msg;\n//}\n\nif (msg.payload.deviceURL === \"io://2017-8871-5701/3196925\") \n    {\n    msg.payload = { \"idx\": 388, \"svalue\": \"test 1\" } \n  //  msg.topic = { \"domoticz/in\" }\n    return msg;\n    }\n\n\n//{ \"command\": \"udevice\", \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n//{ \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":420,"wires":[["27bcb8ebe2e66553","5569758a44d2d493"]]},{"id":"5569758a44d2d493","type":"debug","z":"743a62898f598be4","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1200,"y":500,"wires":[]},{"id":"1f4ca39d34a2136f","type":"debug","z":"743a62898f598be4","name":"debug 12","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1220,"y":320,"wires":[]},{"id":"da22f822bb4835c8","type":"inject","z":"743a62898f598be4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":640,"wires":[["887e1a675e7b7458"]]},{"id":"887e1a675e7b7458","type":"function","z":"743a62898f598be4","name":"function 1","func":"//if(msg.payload.deviceURL === \"io://2017-8871-5701/3196925\")\n//{\n//    return msg;\n//}\n\n\n    msg.payload = { \"idx\": 388, \"svalue\": \"Testing MQTT to Domoticz\" } \n    return msg;\n\n//{ \"command\": \"udevice\", \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n//{ \"idx\" : 7, \"nvalue\" : 0, \"svalue\" : \"90;2975.00\" }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":640,"wires":[["f708f986c4e688fe","f5d9c199645c3960"]]},{"id":"f708f986c4e688fe","type":"mqtt out","z":"743a62898f598be4","name":"","topic":"domoticz/in","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"92e5b2c.00a8b5","x":670,"y":640,"wires":[]},{"id":"f5d9c199645c3960","type":"debug","z":"743a62898f598be4","name":"debug 13","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":700,"wires":[]},{"id":"d141c56ce52dcd5d","type":"tls-config","name":"TLS","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""},{"id":"92e5b2c.00a8b5","type":"mqtt-broker","name":"MQTT (NAS)","broker":"10.0.0.4","port":"1883","clientid":"Node_Red_Client","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
And this is working somehow.

Seems that the switch node is the culprit?
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Cant get MQTT output into domoticz

Post by FireWizard »

Hello @MikeyMan

In your post of 05 Sep 2022, 17:29, you wrote:
Writing value to text with JSON succeeded. Even remotely ;)
Still no luck from nodered though.
As I see the output is correct and so should display the text "test" and "test 1" respectively, if at least the sensor with idx 388 is a "Text" sensor.
That should work and this text string has been sent by the MQTT output node of your Node Red flow.
So I do not understand
Still no luck from nodered
On 05 Sep 2022, 17:43 you wrote:
And this is working somehow.
Well does it work or not. You should see the text "test" and "test 1" The word "somehow" does not make it clearer.

You wrote also:
Seems that the switch node is the culprit?
So it is time to look at the output of the API call.
Can you show the output of "debug 9"?

Regards
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cant get MQTT output into domoticz

Post by MikeyMan »

FireWizard wrote: Monday 05 September 2022 21:41 Hello @MikeyMan

In your post of 05 Sep 2022, 17:29, you wrote:
Writing value to text with JSON succeeded. Even remotely ;)
Still no luck from nodered though.
As I see the output is correct and so should display the text "test" and "test 1" respectively, if at least the sensor with idx 388 is a "Text" sensor.
That should work and this text string has been sent by the MQTT output node of your Node Red flow.
So I do not understand
Still no luck from nodered
On 05 Sep 2022, 17:43 you wrote:
And this is working somehow.
Well does it work or not. You should see the text "test" and "test 1" The word "somehow" does not make it clearer.

You wrote also:
Seems that the switch node is the culprit?
So it is time to look at the output of the API call.
Can you show the output of "debug 9"?

Regards
Thing is, when I enter the topic manually in the mqtt output node, it is working. When I replace the msg.topic in the change node, it doesn't. So might be I wasn't using that in the right way, although the output looked correct in mqtt explorer.

Don't know what the difference between these two is. In the screenshot, the output of the debug node looks slightly different.

As you can see from the NodeRed JSON, I'm not really using the API call yet. That's the next step, now that output is showing up in domoticz :)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests