I have not found a way to initiate a command from my smartphone from outside my WLAN to Node-RED. I tried Telegram (chats arrive at the bot, but do not initiate anything in Node-RED, because they arrive from the wrong direction) and e-mail (polling interval too long). Other push solutions seem to cost some amount and maybe they only send push information TO the phone (?).
So I started playing with Tasker and the MQTT publisher plugin. It works flawlessly within my WLAN. I did not use any user login to mosquitto so far and don't want to change all devices inside the LAN.
Then I started a second mosquitto call with the configuration file:
[...] port 1888 allow_anonymous false password_file /etc/mosquitto/mosquitto.pw
and redirected a port xxxx from outside to the port 1888. Surely an extra ssl option would have been useful, but until now I do not see a requirement for that.
The user credentials in the mosquitto.pw file are created with the command
I could have transferred all desired topics manually from one broker to the other or I could have used the bridge option of Mosquitto.
But then I realised the concept "listener" within Mosquitto, which can define another instance of the first mosquitto listening to another port with different settings.
This is my current configuration: I created the following file
per_listener_settings true port 1883 # maybe not required here allow_anonymous true listener 1888 allow_anonymous false password_file /etc/mosquitto/mosquitto2.pw mount_point external/
With the mount_point option clients from outside only have access to topics starting with "external/", but do not see this extra topic. Mosquitto will add the prefix automatically for all communications via this port.
subcribe to Mosquitto port 1883 (without login):
publish something to Mosquitto port 1888 (with the user credentials from the password file):
and vice versa.
If you omit the mount_point option the clients from outside have access to all topics (which may be useful for other people). You could also play with ACL rights for certain topics.