Mqtt commands list for ESPeasy
Moderators: grovkillen, Stuntteam, TD-er
Mqtt commands list for ESPeasy
Maybe i haven't searched good enough.
But with the wiki i can't find the answer.
Also with the search function on this forum, i don't find the answer.
Is it possible to send a mqtt message to espeasy and get a mqtt message back with information?
What has the topic to be (the one i put in subscribe?) with which payload?
I am looking for sending a message and get the device and/or gpio information back?
Also with switching a gpio.
I now do this by nodered and setup the espeasy with domoticz helper.
Sending a domoticz style mqtt message, lets the espeasy switch the output.
But is it possible to send a message, without using the third party setup?
But with the wiki i can't find the answer.
Also with the search function on this forum, i don't find the answer.
Is it possible to send a mqtt message to espeasy and get a mqtt message back with information?
What has the topic to be (the one i put in subscribe?) with which payload?
I am looking for sending a message and get the device and/or gpio information back?
Also with switching a gpio.
I now do this by nodered and setup the espeasy with domoticz helper.
Sending a domoticz style mqtt message, lets the espeasy switch the output.
But is it possible to send a message, without using the third party setup?
Re: Mqtt commands list for ESPeasy
That's not how MQTT is supposed to work. MQTT works by sending out the data/event by the device where that event is available, to the broker, and anyone that has subscribed to that event (topic) will receive it. These free tutorials have taught me a lot on how MQTT works.
From an ESPEasy perspective, you can configure a MQTT Controller, and on each Device configuration (aka Task) you can enable that controller for the value to be sent out, for everyone to consume.
When subscribing to MQTT topics is desired, there is the MQTT Import plugin (P037) that is quite versatile in receiving any topic, for you to respond to in Rules.
When using Domoticz and a MQTT broker (often mosquitto) there is also P029 to directly control a GPIO pin from there.
When using the HA/OpenHAB MQTT controller, you can use any topic ending in /cmd to send commands to ESPEasy, as documented here
The entire list of available plugins is documented here
From an ESPEasy perspective, you can configure a MQTT Controller, and on each Device configuration (aka Task) you can enable that controller for the value to be sent out, for everyone to consume.
When subscribing to MQTT topics is desired, there is the MQTT Import plugin (P037) that is quite versatile in receiving any topic, for you to respond to in Rules.
When using Domoticz and a MQTT broker (often mosquitto) there is also P029 to directly control a GPIO pin from there.
When using the HA/OpenHAB MQTT controller, you can use any topic ending in /cmd to send commands to ESPEasy, as documented here
The entire list of available plugins is documented here
/Ton (PayPal.me)
Re: Mqtt commands list for ESPeasy
I think my question was wrong written.
I think i know how mqtt works. But couldn't find the command for espeasy.
I helped to switch from domoticz to openHab.
This is what i have know in a nodered function node and works. It switches gpio 0
The only thing left what i am looking for is a mqtt command, that if the espeasy receives it, it publish the status of gpio 0 back to mqtt.
Just like changing the gpio, i get a reply with topic Sonoff_indoor-plug/Dummy/state
how to get the state of gpio 0 (or Dummy) without switching it, is that possible?
I think i know how mqtt works. But couldn't find the command for espeasy.
I helped to switch from domoticz to openHab.
This is what i have know in a nodered function node and works. It switches gpio 0
Code: Select all
msg.topic = "Sonoff_indoor-plug/cmd";
msg.payload = "gpio,0,1";
return msg;
Just like changing the gpio, i get a reply with topic Sonoff_indoor-plug/Dummy/state
how to get the state of gpio 0 (or Dummy) without switching it, is that possible?
Re: Mqtt commands list for ESPeasy
Ok, if you want it 'on demand' you could add a rule that publishes the current state for gpio 0, or you could respond to every state-change of gpio 0 to publish that:
1) On demand:
to get that rule to publish the state for gpio 0 you should send this command:
By replacing the 0 by any other valid gpio number you can get the state for any of them. The topic includes the gpio number (%v200%)
Edit: Formatted gpio to 2 digits, with 0 prefilled.
-----------------------
2) Pinstate driven:
NB: Untested!
1) On demand:
Code: Select all
on getGpioState do
let 200,%eventvalue1|-1%
if %v200%>-1
publish,Sonoff_indoor-plug/gpio[int#200#D2]/state,[plugin#gpio#pinstate#%v200%]
endif
endon
Code: Select all
msg.topic = "Sonoff_indoor-plug/cmd";
msg.payload = "event,getGpioState=0";
return msg;
Edit: Formatted gpio to 2 digits, with 0 prefilled.
-----------------------
2) Pinstate driven:
Code: Select all
on system#boot do
monitor gpio,0
endon
on gpio#0 do
publish,Sonoff_indoor-plug/gpio0/state,%eventvalue1%
endon
/Ton (PayPal.me)
Re: Mqtt commands list for ESPeasy
Good to know that i need an event for it, and that there is not a standard payload which give a status back
I tried your version, but it always gives a 1 back.
Modified some things and this works
If i no problem that i put 3 times %eventvalue1% in the code.
Or is it better to make a variable in it, which is the %eventvalue1%, and replace the 3x %eventvalue1% by the variable?
I tried your version, but it always gives a 1 back.
Modified some things and this works
If i no problem that i put 3 times %eventvalue1% in the code.
Or is it better to make a variable in it, which is the %eventvalue1%, and replace the 3x %eventvalue1% by the variable?
Code: Select all
on getGpioState do
if %eventvalue1%>-1
publish,Sonoff_indoor-plug/gpio[%eventvalue1%]/state,[plugin#gpio#pinstate#%eventvalue1%]
endif
endon
Re: Mqtt commands list for ESPeasy
[] are used to refer to taskvalues and [var#XXX] or [int#XXX].
%...% are used to access system variables
N.B. sometimes you cannot use [] notation so for these we also have the same variables as [var#XXX} made accessible via %vXXX%
Anyway, you should not use [] wrapping %eventvalue1%
%...% are used to access system variables
N.B. sometimes you cannot use [] notation so for these we also have the same variables as [var#XXX} made accessible via %vXXX%
Anyway, you should not use [] wrapping %eventvalue1%
Re: Mqtt commands list for ESPeasy
Tried some thing, but i can't get it to work with variable.
The problems is in this part
The variable in that part isn't filled in, it keeps it as plain text.
Also tried the other variable option, without luck
This one works, but then i have a system variable between the [ ]
are there more options, to get the variable in the [plugin#gpio#pinstate]?
The problems is in this part
Code: Select all
[plugin#gpio#pinstate#%v200%]
Also tried the other variable option, without luck
Code: Select all
[plugin#gpio#pinstate#%[int#200#d2]]
Code: Select all
[plugin#gpio#pinstate#%eventvalue1%]
Re: Mqtt commands list for ESPeasy
That is supposed to work, used that many times, as the system variable is processed before the [] enclosed task variablehoeby wrote: ↑18 Oct 2022, 07:10 The problems is in this partThe variable in that part isn't filled in, it keeps it as plain text.Code: Select all
[plugin#gpio#pinstate#%v200%]
That won't work, having nested [] task variables. And the % shouldn't be there.hoeby wrote: ↑18 Oct 2022, 07:10 Also tried the other variable option, without luckCode: Select all
[plugin#gpio#pinstate#%[int#200#d2]]
If this works, then the first option should work as well, as it is essentially the same.hoeby wrote: ↑18 Oct 2022, 07:10 This one works, but then i have a system variable between the [ ]Code: Select all
[plugin#gpio#pinstate#%eventvalue1%]
This needs some more investigation, though today I'm a bit short on available time.
/Ton (PayPal.me)
Re: Mqtt commands list for ESPeasy
Just a few debugging tips:
Sometimes storing stuff in a variable first may be useful instead of writing long expressions.
N.B. This is a must for things that need to be computed.
Another things which can be very useful is to send it to a logentry.
Both "in action":
Sometimes storing stuff in a variable first may be useful instead of writing long expressions.
N.B. This is a must for things that need to be computed.
Another things which can be very useful is to send it to a logentry.
Both "in action":
Code: Select all
let,123,[plugin#gpio#pinstate#%v200%]
logentry,"pinstate: [plugin#gpio#pinstate#%v200%] via let: [int#123]"
Re: Mqtt commands list for ESPeasy
Edit: have to give it a new try with the info TD-er has giving
Last edited by hoeby on 18 Oct 2022, 21:25, edited 1 time in total.
Re: Mqtt commands list for ESPeasy
After trying and trying i have it working.
What did i change:
The variable didn't worked like in the examples.
I noticed that i only can use variable with 1 digit length
When i set this to the 3 digit example, nothing is stored
Maybe this has something to do with the older firmware in the esp (ESP_Easy_mega_20200516)
And the eventvalue was something that gives me errors
This was in one of the first examples, as Ath said, not tested.
I changed it to this, to get the errors out
The working code:
What did i change:
The variable didn't worked like in the examples.
I noticed that i only can use variable with 1 digit length
When i set this to the 3 digit example, nothing is stored
Maybe this has something to do with the older firmware in the esp (ESP_Easy_mega_20200516)
And the eventvalue was something that gives me errors
This was in one of the first examples, as Ath said, not tested.
Code: Select all
let 2,%eventvalue1|-1%
Code: Select all
let 2,%eventvalue%
Code: Select all
on getGpioState do
Let,2,%eventvalue%
if %v2%>-1
//logentry,'Pin:[int#2#D2], has state:[plugin#gpio#pinstate#%v2%]'
publish,Sonoff_indoor-plug/gpio[int#2#D2]/state,[plugin#gpio#pinstate#%v2%]
endif
endon
Re: Mqtt commands list for ESPeasy
Very likely, as it previously had a limit of upto 16 (??) variables.Maybe this has something to do with the older firmware in the esp (ESP_Easy_mega_20200516)
Not sure if I already removed that limit about 2.5 years ago.
Who is online
Users browsing this forum: No registered users and 6 guests