need help with mqtt (domoticz/in) Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

need help with mqtt (domoticz/in)

Post by Eugene »

Hi Guys,

I feel i got stuck trying to deliver Wireless Mbus meters values to domoticz dummy device via mqtt. The wmbusmeters calls mosquitto_sub and posts the values for 3 counters into the mqtt domoticz/in topic. The problem i am facing is that dummy counters i created are not being updated on Domoticz side. Domoticz does not even show the mqtt message in the log however can see the messages with values posted in the mqtt explorer. The domoticz works fine with zigbee2mqtt meaning domoticz<->mqtt connection is operational. It seems that domoticz does not listen for domoticz/in topic for some reason

The example of the call i make when wmbusmeters read new value:
shell=/usr/bin/mosquitto_pub -u XX -P YY -h mqtt5 -t domoticz/in -m "{\"idx\":548,\"svalue\":\"$METER_TOTAL_M3\"}"

attaching screenshot of MQTT explorer and of Dummy devices i created in Domoticz.

I am on Domoticz Version: 2024.4

Please point me to the right direction. Thanks
Attachments
domoticz.png
domoticz.png (167.69 KiB) Viewed 337 times
mqtt.png
mqtt.png (145.64 KiB) Viewed 337 times
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: need help with mqtt (domoticz/in)

Post by FireWizard »

Hi @Eugene,

I think you are missing the command in the message, sent to domoticz/in.

Use: { "command": "udevice", "idx": 548, "svalue": "1234"}

"command": "udevice" is the default and may be omitted.

But this makes the message clearer.

However, I think that the value, you send in the part "svalue" is not a string value, but a numerical value. So check that your $METER_TOTAL_M3 is a string value.
If not, convert it first.

It looks okay, but this is an error that is made often.

Regards
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

Thanks for suggestions. I am not yet sure how can i control value type in the wmbusmeters but i tried running mosquitto_pub trying to pass number as svalue and nvalue but still no difference. Neither of those reached the device in Domoticz but showing up in MQTT Explorer well

/wmbusmeters # /usr/bin/mosquitto_pub -u XX -P YY -h mqtt5 -t domoticz/in -m "{\"command\":\"udevice\",\"idx\":549,\"nvalue\":12345}"

What is worrying me - i do not see anything with domoticz/in topic in the Domoticz logs. I guess it should be showing up there even if values are screwed and not matching expected types.

Thanks
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

made a workaround with curl calling domoticz API updating the values. Works with no issues.

I would appreciate thoughts on what did i do wrong with my mqtt

thanks.
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: need help with mqtt (domoticz/in)

Post by FireWizard »

Hi @Eugene,

I looked to a couple of things and at the end I decided to test your string in my Test sytem.

If I use the following string on the command line, it works and it sends its value to Domoticz:

Code: Select all

sudo /usr/bin/mosquitto_pub -h <IP address> -u username -P userpass -t domoticz/in -m "{\"command\": \"udevice\", \"idx\": 15, \"svalue\": \"12345\" }"
This works for me and gives a correct value in Domoticz in a "Custom" sensor.

I had to run mosquitto_pub as "root" user. Do not know why yet.
In my opinion my command is similar to yours. Also without \"command\": \"udevice\" it runs fine.

So there is not much, I can test or suggest anymore.

There is one thing, that might be tricky in my opinion.

You use mqtt5 as the host name.
This might look as a better solution, as you do not have to remember the IP address of your MQTT server (broker)

But it requires that all devices that needs to communicate with the MQTT server, such as the broker, the device that has MQTT Explorer installed and your Domoticz server, has to be aware of the IP address of mqtt5.

So you need either a (caching) DNS server on your local network AND all the network interfaces properly configured, so that they use the correct DNS server, or each device should have a hosts file, in which the mqtt5 is listed.
You might want to check that.

I assume however that this is at least correct for the device with MQTT Explorer and the MQTT broker, but for Domoticz I'm not sure.

Check and test it once more.

Regards
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

Hi, thanks for testing this for me.

Copied your command, ran as root too, still same behavior sadly. Domoticz does not appear to "hear" those messages for some reason. Mqtt explorer sees those messages well.

Is there a way to debug domoticz to get more details on what it is receiving from mosquitto?

Regarding the DNS hostname - i run domoticz, zwave js ui, zigbee2mqq and mosquitto in docker containers. The containers are bridged into shared docker network. I started using docker internal DNS since one of containers changed its IP for unknown reason.
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

interesting - i tried running tcpdump on the domoticz interface towards mosquitto and it appears that my messages sent with mosquitto_pub are not even reaching the domoticz :( other messages ( zwave, zigbee) are reaching domoticz with no issues.

also tried posting messages with mqtt explorer - those i see on mosquitto_sub but nothing seen on tcpdump on domoticz side.

something for me to think about :)

Do we control anywhere on domoticz side which topics it is subscribed to on mqtt?
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

sorry for spam, guys. i was digging into domoticz to mqtt integration, i am currently using "MQTT Autodiscovery" to connect to mosquitto. domoticz\in and domoticz\out topics mentions on the "MQTT client gateway".

Do i need a 2nd link to MQTT from domoticz without auto-discovery in this scenario to make domoticz listening to domoticz\in topic? or is the a way to force domoticz listeining to domoticz/in topic in the existing integration with auto-discovery enabled?

thanks
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: need help with mqtt (domoticz/in)

Post by FireWizard »

Hi @Eugene,
Do i need a 2nd link to MQTT from domoticz without auto-discovery in this scenario to make domoticz listening to domoticz\in topic?
Yes, I think so.

As I do not use "Auto Discovery", it was the normal MQTT interface, I used, when testing

But why not try it?

Regards
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

FireWizard wrote: Sunday 15 December 2024 18:52
But why not try it?
I confirm, second interface without auto-discovery towards same MQTT broker works fine, my devices are updated!
Now i need to rework my setup from curl to mosquitto_pub :)

FireWizard, thanks a lot for your help!
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: need help with mqtt (domoticz/in)

Post by FireWizard »

Hello @Eugene,

Great, it was my pleasure.

Can you mark this thread as "Solved"?

Regards.
Eugene
Posts: 29
Joined: Wednesday 21 December 2016 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: need help with mqtt (domoticz/in)

Post by Eugene »

I tried to solve it, getting "404 Not Found" in response :( I will try tomorrow again
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: need help with mqtt (domoticz/in)

Post by waltervl »

Eugene wrote: Sunday 15 December 2024 22:02 I tried to solve it, getting "404 Not Found" in response :( I will try tomorrow again
There is a bug on mark solve in the forum system after it was moved to another server and updated to latest version. Gizmocuz is working on it
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: need help with mqtt (domoticz/in)

Post by waltervl »

waltervl wrote: Monday 16 December 2024 0:06
Eugene wrote: Sunday 15 December 2024 22:02 I tried to solve it, getting "404 Not Found" in response :( I will try tomorrow again
There is a bug on mark solve in the forum system after it was moved to another server and updated to latest version. Gizmocuz is working on it
And solved!
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests