MQTT string in EspEasy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

MQTT string in EspEasy

#1 Post by uah007 » 02 Apr 2023, 13:03

Is it possible to somehow pass a new WifiSSID and WifiKey value to EspEasy using MQTT?

bidrohini
Normal user
Posts: 105
Joined: 03 Nov 2022, 16:24

Re: MQTT string in EspEasy

#2 Post by bidrohini » 02 Apr 2023, 16:47

Maybe it is possible by using the plugin MQTT Import.

https://espeasy.readthedocs.io/en/lates ... /P037.html

TD-er
Core team member
Posts: 8752
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT string in EspEasy

#3 Post by TD-er » 02 Apr 2023, 17:08

Maybe you can send it as some kind of event.
See the command options for C005: https://espeasy.readthedocs.io/en/lates ... d-handling

You can then try to formulate an event of which one of the eventvalues are the new credentials.

Another option is to make a build with the provisioning option included.
Then on the Settings Archive page you can define an URL which will then be used as a base URL (http only, not https) and you can then formulate events in the rules to call provisioning commands to fetch settings/credentials/rules from a server.
You can even fetch firmware updates via such provisioning. (tested on ESP32 only)

This is still a work-in-progress, and I still need to write documentation for it.

User avatar
Ath
Normal user
Posts: 3517
Joined: 10 Jun 2018, 12:06
Location: NL

Re: MQTT string in EspEasy

#4 Post by Ath » 02 Apr 2023, 20:48

It will prove to be quite hard to send anything to a unit if it isn't connected to a (WiFi)network, if it doesn't yet have the correct credentials... :shock:
A valid way to set the credentials is to send the matching commands via USB-serial, you shouldn't forget to save the settings or it won't be able to reconnect after a reboot...
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8752
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT string in EspEasy

#5 Post by TD-er » 02 Apr 2023, 21:58

Not if you're making your own custom builds with a deployment SSID included.
For obvious reasons is this only possible for 'custom' builds.
But it is really useful for quick deployment on lots of units, where you have some special AP configured for the initial deployment.

Since you can even let it then update the firmware, you can have a basic FW pre-flashed when ordering the ESP chips and then automatically let it connect to a default AP and let it download settings and a firmware which doesn't have such a deployment AP pre-configured.

User avatar
uah007
Normal user
Posts: 15
Joined: 15 Oct 2022, 23:04
Location: Ukraine, Kyiv

Re: MQTT string in EspEasy

#6 Post by uah007 » 03 Apr 2023, 09:06

It turned out to be implemented by handling the event.
%eventvalue% is used as the WifiSSID argument, but under one condition.
The passed value must start with a digit.
Therefore, I added a number in front of the text transmitted value, and then

Code: Select all

WiFiSSID,{substring:1:20:%eventvalue%}

TD-er
Core team member
Posts: 8752
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT string in EspEasy

#7 Post by TD-er » 03 Apr 2023, 09:24

Only the first eventvalue is checked for being a numerical.
So you can add a dummy first eventvalue and then use the 2nd eventvalue.

You can also use an * to make sure it isn't only trying to match numericals.
See: https://espeasy.readthedocs.io/en/lates ... as-command

This can even be used to send commands to be executed in rules.
https://espeasy.readthedocs.io/en/lates ... as-command
But be aware of the security issues that might arise.

Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests