commands via MQTT
Moderators: grovkillen, Stuntteam, TD-er
commands via MQTT
Hi!
I try to send commands to my ESPEASY enabled D1mini.
I connected an DFplayer and when I send "play,1" via the "tools" menu it plays the corresponding sound.
When i trigger it via http "http://192.168.0.202/control?cmd=play,1" it works too
but I can't manage to work with mqtt. I tried all mqtt controller. The D1mini can successfull connect to the broker, I can see the LWT message.
But the D1mini does not react to messages send to it.
My sysname: ESPDingDong_1
Controller subscribe: /%sysname%/#
Controller publish: /%sysname%/pub/
Enabled: true
The DFPlayer device is named "Klingel"
So I tried to send following messages to my broker:
[topic | payload]
/ESPDingDong_1/cmd | play,1
/ESPDingDong_1 | play,1
/ESPDingDong_1/Klingel/play | 1
/ESPDingDong_1/Klingel | play,1
but nothing happens. no output on serial or in the log.
I can see that the D1mini subscribed to my broker, but on the D1mini I can't see any incoming messages
I think I'm doing somthing wrong. Can someone tell me what
I try to send commands to my ESPEASY enabled D1mini.
I connected an DFplayer and when I send "play,1" via the "tools" menu it plays the corresponding sound.
When i trigger it via http "http://192.168.0.202/control?cmd=play,1" it works too
but I can't manage to work with mqtt. I tried all mqtt controller. The D1mini can successfull connect to the broker, I can see the LWT message.
But the D1mini does not react to messages send to it.
My sysname: ESPDingDong_1
Controller subscribe: /%sysname%/#
Controller publish: /%sysname%/pub/
Enabled: true
The DFPlayer device is named "Klingel"
So I tried to send following messages to my broker:
[topic | payload]
/ESPDingDong_1/cmd | play,1
/ESPDingDong_1 | play,1
/ESPDingDong_1/Klingel/play | 1
/ESPDingDong_1/Klingel | play,1
but nothing happens. no output on serial or in the log.
I can see that the D1mini subscribed to my broker, but on the D1mini I can't see any incoming messages
I think I'm doing somthing wrong. Can someone tell me what
Re: commands via MQTT
I mean, the first one '/ESPDingDong_1/cmd | play,1' (without the '|) should work.
The difference to my setup is only:
- My MQTT setup has no leading slash (should work with it too). I removed all of them, because they didn't correspond to the MQTT specifications.
- Controller Publish is set to default at me (%sysname%/%tskname%/%valname%)
- and I use an event for my devices (topic/payload = [device]/cmd event,[eventname]), but all commands should work.
Have you enabled your controller? If you reboot your ESPEasy-device, see you the connect-message from it ? You can see all topics with: 'mosquitto_sub -v -t "#" | ts'.
The difference to my setup is only:
- My MQTT setup has no leading slash (should work with it too). I removed all of them, because they didn't correspond to the MQTT specifications.
- Controller Publish is set to default at me (%sysname%/%tskname%/%valname%)
- and I use an event for my devices (topic/payload = [device]/cmd event,[eventname]), but all commands should work.
Have you enabled your controller? If you reboot your ESPEasy-device, see you the connect-message from it ? You can see all topics with: 'mosquitto_sub -v -t "#" | ts'.
Last edited by Micha_he on 13 Apr 2021, 15:50, edited 1 time in total.
Re: commands via MQTT
THANK YOU!
I removed the leading slashes and it works now using the "home assistant" Controller.
great!
I removed the leading slashes and it works now using the "home assistant" Controller.
great!
Re: commands via MQTT
Hi,
I read the post, but couldn't get it work from domoticz to esp
On the esp I have
1/ a controller with
Current Client ID: aquaOnOff_1
Controller Subscribe: %sysname%_%unit% = aquaOnOff_1
2/ an event
on TankLevelOKLow do
From domoticz I send
/aquaOnOff_1/cmd TankLevelOKLow,9
Nothing appears on the esp log
Tried before
1/ a controller with
Current Client ID: aquaOnOff_1
Controller Subscribe: domoticz/out
2/ idem
From domoticz I send
/domoticz/out/cmd TankLevelOKLow,9
Nothing appears on the esp log neither
What did I miss ?
I read the post, but couldn't get it work from domoticz to esp
On the esp I have
1/ a controller with
Current Client ID: aquaOnOff_1
Controller Subscribe: %sysname%_%unit% = aquaOnOff_1
2/ an event
on TankLevelOKLow do
From domoticz I send
/aquaOnOff_1/cmd TankLevelOKLow,9
Nothing appears on the esp log
Tried before
1/ a controller with
Current Client ID: aquaOnOff_1
Controller Subscribe: domoticz/out
2/ idem
From domoticz I send
/domoticz/out/cmd TankLevelOKLow,9
Nothing appears on the esp log neither
What did I miss ?
Re: commands via MQTT
Just make sure you are using the same topics on both ends (Domoticz and ESPEasy).
For example the leading slash really makes a difference.
- /bla -> Topic depth = 2, Root topic is ""/
- bla -> Topic depth = 1, Root topic is "bla"
Domoticz controller does not accept commands via a subtopic "cmd"
This is only supported in the OpenHAB MQTT controller.
For example the leading slash really makes a difference.
- /bla -> Topic depth = 2, Root topic is ""/
- bla -> Topic depth = 1, Root topic is "bla"
Domoticz controller does not accept commands via a subtopic "cmd"
This is only supported in the OpenHAB MQTT controller.
Re: commands via MQTT
Thanks for your reply
=> on the broker: domoticz/out/cmd TankLevelOKLow,9
But still nothing in the log of the espeasy
I my case
Because in the end the command is on the broker
If cmd command is not accepted by dz, what king of information is accepted from dz to espeasy?
I did it between 2 espeasy
1/ with domoticz/out
Publish domoticz/out/cmd,'{TankLevelOKLow,1}'
=> on the broker: domoticz/out/cmd {TankLevelOKLow,1}
2/ with %sysname%_%unit%
Publish aquaOnOff_1/cmd,'{TankLevelOKLow,1}'
=> on the broker: aquaOnOff_1/cmd {TankLevelOKLow,1}
And nothing appears on the aquaOnOff_1 log
I've changed the command in dz scriptFor example the leading slash really makes a difference.
- /bla -> Topic depth = 2, Root topic is ""/
- bla -> Topic depth = 1, Root topic is "bla"
Code: Select all
sudo mosquitto_pub -t domoticz/out/cmd -m TankLevelOKLow,9
But still nothing in the log of the espeasy
I'm not sure to understand if it applies when the mqtt command is done by an os command in dz...Domoticz controller does not accept commands via a subtopic "cmd"
I my case
Code: Select all
local mqttPub = 'sudo mosquitto_pub -t domoticz/out/cmd -m TankLevelOKLow,9'
dz.log("mqttPub " .. mqttPub, dz.LOG_DEBUG)
os.execute(mqttPub)
If cmd command is not accepted by dz, what king of information is accepted from dz to espeasy?
I did it between 2 espeasy
1/ with domoticz/out
Publish domoticz/out/cmd,'{TankLevelOKLow,1}'
=> on the broker: domoticz/out/cmd {TankLevelOKLow,1}
2/ with %sysname%_%unit%
Publish aquaOnOff_1/cmd,'{TankLevelOKLow,1}'
=> on the broker: aquaOnOff_1/cmd {TankLevelOKLow,1}
And nothing appears on the aquaOnOff_1 log
Re: commands via MQTT
Originally the controllers were designed to "send" data.
But MQTT is also capable of receiving data since you can subscribe to a topic.
So it is upto the controller to act on the received data.
The Domoticz MQTT controller does only accept commands for a very small set of plugins (e.g. Domoticz MQTT helper and switch and maybe one or two more)
The OpenHAB MQTT controller does also subscribe to the set subscription topic + "/cmd" and does accept almost any ESPEasy command.
So if you would like to receive commands, even though you use Domoticz, you should use OpenHAB MQTT controller.
This has the drawback that you cannot use the controller directly from a task as the OpenHAB MQTT controller does not send using the syntax required by Domoticz.
So you then must send to Domoticz via Rules and use the publish command to write messages in the specific syntax required by Domoticz.
Sadly you cannot have > 1 active MQTT controller right now.
But MQTT is also capable of receiving data since you can subscribe to a topic.
So it is upto the controller to act on the received data.
The Domoticz MQTT controller does only accept commands for a very small set of plugins (e.g. Domoticz MQTT helper and switch and maybe one or two more)
The OpenHAB MQTT controller does also subscribe to the set subscription topic + "/cmd" and does accept almost any ESPEasy command.
So if you would like to receive commands, even though you use Domoticz, you should use OpenHAB MQTT controller.
This has the drawback that you cannot use the controller directly from a task as the OpenHAB MQTT controller does not send using the syntax required by Domoticz.
So you then must send to Domoticz via Rules and use the publish command to write messages in the specific syntax required by Domoticz.
Sadly you cannot have > 1 active MQTT controller right now.
Re: commands via MQTT
You could use the Domoticz HTTP controller to send the outgoing data, and use the OpenHAB MQTT controller as described, receiving data and/or commands.
/Ton (PayPal.me)
Re: commands via MQTT
Thanks for this clarification
the flows are the following and it works, so I don't want to change everything So I think, I'm going to keep the http from domoticz to aquaOnOff, if not possible to have a full mqtt!
I'd like to change the flow between both espeasy, because they are side to side ; is there a solution to avoid wifi?
Perhaps another topic...
the flows are the following and it works, so I don't want to change everything So I think, I'm going to keep the http from domoticz to aquaOnOff, if not possible to have a full mqtt!
I'd like to change the flow between both espeasy, because they are side to side ; is there a solution to avoid wifi?
Perhaps another topic...
Who is online
Users browsing this forum: No registered users and 101 guests