TL;DR: what if users could specify a .wit file (WASM Interface Type) as the platform? It might be great for embedded applications such as home automation.
Some home automation devices let the user define custom automations, such as "when the sun rises and it's not a weekend or a holiday, turn on the lights in the kitchen and open the curtains". Some of these devices let you define the automations in a language such as Lua. I'm trying to wrap my head around the way Roc could be used instead for this use case.
I'm guessing one option is simply to include the Roc compiler in the device, and compile the user's script on the device. But these devices typically have very limited resources, so unless the Roc compiler is extremely lean, a more likely approach would be for the manufacturer to offer a tool (online or local) to let the user compile the script and upload the result (an executable or a dynamic lib).
But this assumes that Roc is popular enough to motivate the manufacturer to specifically work on Roc support. Hopefully this will happen one day, but in the meantime perhaps a more realistic scenario would be for the device manufacturer to include a WASM runtime. The user would just use their language of choice (Roc, of course), and compile it to WASM.
However, I'm wondering which Roc platform the user would use in this scenario. I suppose it has to be a device-specific platform (possibly written by the device manufacturer, or by the community). Unless perhaps there are some standardized WASM APIs for Home Automation, and the user could then use a Roc platform targeting this API?
Does this make sense? Am I misunderstanding the way Roc platforms would be used in this kind of context?
Oh, I just read about WIT (Wasm Interface Type). Perhaps the device manufacturer could not only include a WASM runtime in their device, but also define and publish a .wit file describing their specific WASM API.
Roc could support using a .wit file as the platform: under the hood, a Roc platform would be auto-generated based on the .wit file, and the compiler would produce a .wasm file that could be uploaded to the device. Wdyt?
You could go crazy and have the compiler running in a web service, if the device has enough power to send the script via TCP an endpoint could compile and return the binary...
I'm not very familiar with the Home Automation scene... how do people write scripts for them currently?
I could imagine the device or operating system manufacturers adding support for Roc scripts in the same way a Lua
Did some quick research (thanks Gemini) ... It looks super achievable. You could build a web service using something like basic-webserver, or even basic-cli if you just want a single run script, then build and wrap it in a small Docker container. You can load that into something like Home Assistant as a background service.
So I think the answer to your question is someone would need to write an MQTT package for Roc and then that would be pretty straightforward to integrate.
The nice thing about Roc is our support for cross-compilation, so you could simply roc build --target arm64musl ... to build the program.
Thanks Luke. AFAIK, the way most hobbyists do home automation is through Home Assistant and/or Node-RED. Your solutions would work perfectly for these cases. :+1:
For hotels and non-hobbyist home automation, there are professional home automation systems, some based on open standards (such as Matter and KNX) and others proprietary. Many of these systems are designed to be configured by an integrator, not by the end user. These systems often allow the integrator to write scripts. These scripts may run on a local server with plenty of resources, or it may run on a tiny embedded device. I was thinking of this last use case.
I have some home automation experience, integrating with Home Assistant sounds like a great first step.
My basic-cli and basic-webserver setup (on a raspberry pi) for solar production monitoring and automatic car charging is still running flawlessly by the way :)
Thanks for your messages! It looks like WIT was discussed before in:
#beginners > Example for using as a embedded language.
I should have searched first, but I didn't know what I didn't know. :sweat_smile:
My Home Automation with WASM use case is way too niche. But I think that Roc could really become the friendliest language for WebAssembly! E.g., for serverless microservices, plugins, smart contracts, online games (as with the wasm4 platform), etc.
Yeah, WASM could the perfect benevolent trojan horse for more Roc adoption :)
For those who want to know more about the home automation landscape, this recent video is a great overview: https://youtu.be/dVM3fzPavMg
I just ordered something new for my home automation setup, zigbee connected smoke alarms. I came to the radical conclusion that I should know that there is a fire in my house when I am not at home :p
Last updated: Jun 16 2026 at 16:19 UTC