Basic MQTT comunication
Moderators: grovkillen, Stuntteam, TD-er
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Basic MQTT comunication
Hello All,
I am trying MQTT communicate between ESPEasy and Domoticz. From Domoticz I send MQTT message as below:
mosquitto_pub -u mylogin -P mypass -t domoticz/out -m {"idx" : 323, "nvalue" : 1,}
in ESPEasy logs i got:
266188840: inputswitchstate is deprecatedinputSwitchState,3,1.00
266188844: EVENT: TDevice#State=0
via ESPEasy Rueles I try to read value of the nvalue argument send in MQTT message as below:
on TDevice#State do
if [%eventvalue%] = 0
Let,3,1
else
Let,3,0
endif
endon
How to properly read the value of the nvalue argument ?
And second query is what should be send in MQTT message in order to event value was 1 no 0 (266188844: EVENT: TDevice#State=0) ?
Kind Regards
Przemo
I am trying MQTT communicate between ESPEasy and Domoticz. From Domoticz I send MQTT message as below:
mosquitto_pub -u mylogin -P mypass -t domoticz/out -m {"idx" : 323, "nvalue" : 1,}
in ESPEasy logs i got:
266188840: inputswitchstate is deprecatedinputSwitchState,3,1.00
266188844: EVENT: TDevice#State=0
via ESPEasy Rueles I try to read value of the nvalue argument send in MQTT message as below:
on TDevice#State do
if [%eventvalue%] = 0
Let,3,1
else
Let,3,0
endif
endon
How to properly read the value of the nvalue argument ?
And second query is what should be send in MQTT message in order to event value was 1 no 0 (266188844: EVENT: TDevice#State=0) ?
Kind Regards
Przemo
Re: Basic MQTT comunication
What version of ESPEasy (bin filename please) are you using? As that "deprecated" message has been resolved some time ago, AFAIK.
In what plugin are you expecting to receive that value? Did you enable the (Domoticz MQTT) Controller for that plugin and set the matching idx value?
Have you changed your Unit ID from 0 to something else in the range 1..254? The Unit ID should not be 0.
In what plugin are you expecting to receive that value? Did you enable the (Domoticz MQTT) Controller for that plugin and set the matching idx value?
Have you changed your Unit ID from 0 to something else in the range 1..254? The Unit ID should not be 0.
/Ton (PayPal.me)
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Re: Basic MQTT comunication
ESPEasy ver: ESP_Easy_mega_20220427_normal_ESP8266_4M1M.bin
#In what plugin are you expecting to receive that value?
I try to find out how via MQTT send the value from Domoticz to Wemos D1 and receive via rules in ESPEasy
#Did you enable the (Domoticz MQTT) Controller for that plugin and set the matching idx value?
Yes in the ESP I added MQTT Controller and add MQTT Helper in devices and Switch Input with the same idx.
#Have you changed your Unit ID from 0 to something else in the range 1..254? The Unit ID should not be 0.
If you mean Unit Number of the ESPEasy I had 0 but after changing on 1 I have the same result. Still I am not able to read the value via ESPEasy rules
#In what plugin are you expecting to receive that value?
I try to find out how via MQTT send the value from Domoticz to Wemos D1 and receive via rules in ESPEasy
#Did you enable the (Domoticz MQTT) Controller for that plugin and set the matching idx value?
Yes in the ESP I added MQTT Controller and add MQTT Helper in devices and Switch Input with the same idx.
#Have you changed your Unit ID from 0 to something else in the range 1..254? The Unit ID should not be 0.
If you mean Unit Number of the ESPEasy I had 0 but after changing on 1 I have the same result. Still I am not able to read the value via ESPEasy rules
Re: Basic MQTT comunication
The OpenHAB MQTT controller does allow for receiving commands.
The Domoticz MQTT controller is much more basic compared to the OpenHAB one.
However you still need the formatting for Domoticz or else you end up formatting it yourself in rules using publish.
You can also use the MQTT import plugin, which can be configured to subscribe to a topic and then receive data.
Not sure if it was already merged in the April build, but there has been some improvement lately on the MQTT import plugin to allow for parsing JSON messages too, to fetch some specific values.
Before these changes you could only receive numerical values as published messages.
The Domoticz MQTT controller is much more basic compared to the OpenHAB one.
However you still need the formatting for Domoticz or else you end up formatting it yourself in rules using publish.
You can also use the MQTT import plugin, which can be configured to subscribe to a topic and then receive data.
Not sure if it was already merged in the April build, but there has been some improvement lately on the MQTT import plugin to allow for parsing JSON messages too, to fetch some specific values.
Before these changes you could only receive numerical values as published messages.
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Re: Basic MQTT comunication
I set MQTT import plugin in the same way like on the webpage https://letscontrolit.com/wiki/index.ph ... QTT_Import
and I try to send MQTT message:
sudo mosquitto_pub -u myid -P mypass -t "cmdMQTT" -m "{"TaskName":"sniff", "cmdMQTT":1.00, "Value2":2.00, "Value3":3.00, "Value4":4.00}"
On the ESPEasy device in logs I got:
64429055: IMPT : Bad Import MQTT Command cmdMQTT
64429056: ERR : Illegal Payload {TaskName:sniff, cmdMQTT:1.00, Value2:2.00, Value3:3.00, Value4:4.00} sniff
Where I make mistake in the MQTT message ? How is proper format ?
and I try to send MQTT message:
sudo mosquitto_pub -u myid -P mypass -t "cmdMQTT" -m "{"TaskName":"sniff", "cmdMQTT":1.00, "Value2":2.00, "Value3":3.00, "Value4":4.00}"
On the ESPEasy device in logs I got:
64429055: IMPT : Bad Import MQTT Command cmdMQTT
64429056: ERR : Illegal Payload {TaskName:sniff, cmdMQTT:1.00, Value2:2.00, Value3:3.00, Value4:4.00} sniff
Where I make mistake in the MQTT message ? How is proper format ?
Re: Basic MQTT comunication
Please don't use the wiki, as it is outdated.
Please use the ReadTheDocs: https://espeasy.readthedocs.io/en/lates ... #p037-page
Please use the ReadTheDocs: https://espeasy.readthedocs.io/en/lates ... #p037-page
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Re: Basic MQTT comunication
I checked the link don't find out how is the proper message in order to changing the value.
When I send:
sudo mosquitto_pub -u myid -P mypass -t "cmdMQTT" -m "svalue":"28.1;17.8;2;1010.3;0"
in logs is illegal payload:
Conn. IP Init
78857950: IMPT : Bad Import MQTT Command cmdMQTT
78857950: ERR : Illegal Payload svalue:28.1;17.8;2;1010.3;0 sniff
can you support me by example message ?
When I send:
sudo mosquitto_pub -u myid -P mypass -t "cmdMQTT" -m "svalue":"28.1;17.8;2;1010.3;0"
in logs is illegal payload:
Conn. IP Init
78857950: IMPT : Bad Import MQTT Command cmdMQTT
78857950: ERR : Illegal Payload svalue:28.1;17.8;2;1010.3;0 sniff
can you support me by example message ?
Re: Basic MQTT comunication
Have you monitored the correct command from Domoticz, that is sent when the device in Domoticz is switched on/off? (it seems like you are using a switch, but it's not fully clear to me yet what you intend to do)
/Ton (PayPal.me)
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Re: Basic MQTT comunication
I don't use any switch to send MQTT message. Message is send via scripts create in Domoticz. My point is to find out how I can send the MQTT message from domoticz script and to receive via ESPEasy in the rules. The main problem is that I don't know how is proper message send via MQTT which allow to change values in "MQTT import" plugin ?
Re: Basic MQTT comunication
The MQTT import plugin can handle either "plain" numerical values, or JSON formatted data.
What you're sending is not proper JSON.
This is when using JSON syntax:
What you're sending is not proper JSON.
This is when using JSON syntax:
Code: Select all
{"svalue": [28.1,17.8,2,1010.3,0]}
-
- New user
- Posts: 6
- Joined: 09 Jul 2022, 12:59
Re: Basic MQTT comunication
I checked your syntax and the same illegal payload is return in the logs:
145948876: IMPT : Bad Import MQTT Command cmdMQTT
145948876: ERR : Illegal Payload {svalue: [28.05, 25.03, 0, 1009.01, 0]} sniff
when I sent message like:
...-m "28.22;10.22;11.22;23.34"
then only first value was changed. If you use MQTT import plugin can you check how message is send in order to update other values ?
145948876: IMPT : Bad Import MQTT Command cmdMQTT
145948876: ERR : Illegal Payload {svalue: [28.05, 25.03, 0, 1009.01, 0]} sniff
when I sent message like:
...-m "28.22;10.22;11.22;23.34"
then only first value was changed. If you use MQTT import plugin can you check how message is send in order to update other values ?
Re: Basic MQTT comunication
That's why I suggested to go with the flow, and configure a matching item in Domoticz to send out messages, and monitor that using your MQTT tools. Then you will get the correct syntax, for free and without any hasslePrzemo2014 wrote: ↑10 Jul 2022, 22:52 ...to find out how I can send the MQTT message from domoticz script and to receive via ESPEasy in the rules. The main problem is that I don't know how is proper message send via MQTT which allow to change values in "MQTT import" plugin ?
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 20 guests