I want to make a Scriptable Widget for iOS 14 that subscribes to an MQTT broker and displays that information. What are the capabilities of Scriptable to use a JS library - or can Scriptable include an MQTT library?
Scriptable can only do HTTP requests through the Request API. There is no underlying functionality for sockets so a 3rd party library won’t work.
Your best bet is to have a hosted service somewhere that subscribes to the MQTT topic and makes it available over https. Something like AWS IoT + S3 + API gateway would do the job.
io.adafruit.com has an MQTT broker that’s also available via a simple HTTP API. It’s free for a limited number of topics and requests per minute.
Another option would be to run Node-Red on your home network and use to create an HTTP-to-MQTT gateway.
Thank you - that might work. I might also go look for some packages that I might self-host for this purpose.
Using MQTT in Scriptable sounds really interesting for me. Have there been any changes?
I’ve wanted this for a long time. There is a workaround: there’s a shortcut action for sending a command over ssh. My mqtt server is running on a raspberry pi, so I have shortcuts that just ssh in and run a command. I set up my more complex scenes (I use mqtt for home automation) in node red, which is also running on the pi, but it would be nice to be able to move that to scriptable to more easily integrate my mac devices
I am using MQTT in a widget already. Domoticz API offers all I needed to make it work. Get status, send commands etc.