Introducing Lua Scripting in 1Home Automations
Prefer video? Take an in-depth overview of Lua Scripting here:
Certain smart home projects demand more advanced logic, integrations, or custom data handling.
That is why we introduced Lua scripting into 1Home Automations.
A New Layer of Flexibility
With Lua scripting, you can now go beyond standard triggers, conditions, and actions.
Inside the 1Home dashboard you will find a built-in editor with inputs and outputs, syntax templates, helpers for KNX read/write, time functions, HTTP and JSON, and the ability to test and log scripts directly.
This makes it possible to implement project requirements that were previously out of reach and gives integrators the freedom to deliver custom solutions without leaving the 1Home environment.
Simulating a Sunrise
One of the most common requests from clients is to wake up gradually, not with a sudden light switch. With Lua, this becomes simple.
- Create a new automation in your dashboard.
- Give it a name (e.g., Sunrise Light).
- Set a trigger; trigger type - Time, Date & Astronomical
- Run it at Sunrise, on weekdays
- Add a Lua scripting block - this opens the built-in Lua editor.
Inside the editor, you’ll find:
- Inputs & Outputs: connect devices and pass data.
- Helpers: shortcuts for Lua syntax, KNX commands, math, HTTP requests, and JSON parsing.
- Run & Settings: test scripts directly and adjust timeouts.
- On the left side of the Dashboard you’ll find Inputs and Outputs. Add a new Input to add a new device, in this case a light.
- On the right side, under helpers we can now find our light
- Expand it and select the setLevel(...) example
An example code will appear in the script editor that you can test run.
For this automation to work as intended we need to make the changes in brightness gradual. We achieve this by using a “for loop”. With a for loop and short pauses between increments, the light smoothly ramps from 0 to 100 percent. It’s also accessible in helpers under “Lua Syntax”.
- Adjust the for loop to affect brightness from 0 to 100 in increments of 10. Paste the example code from before within the for loop and change (value) to (brightness).
- In Helpers, go to time and insert time.sleep
Last but not least we want to log the progress of the automation.
- Go to helpers > log >log.info and change the code as follows:
Because this automation takes 10 Seconds, make sure there is enough timeout for the automation to run.
The result is now a natural sunrise effect built entirely in 1Home Automations.
Bringing in Weather Data
Another powerful example is weather-based automation without a dedicated weather station.
Using a weather API, like the free-for-personal-use Open-Meteo API, Lua can fetch outside temperature, wind speed, and weather conditions, then send the values directly into KNX.
- Create a new automation
- Set a new trigger; trigger type Time, Date & Astronomical
- Set it to run every minute
- Add a Lua Script Block
- In the Helpers under “Examples” find “Weather API Example”
This script sends an HTTP GET request with your server’s latitude and longitude and parses the response for: temperature, wind speed, direction, day/night status, and weather codes.
This data can now be sent to a KNX Bus.
- Go to Helpers > KNX > knx.write_9_xxx(...)
- Change the group address within the script to whichever one you need
- Input the data you want to send (in this example it’s outside temperature)
With the KNX Traffic Monitor, every telegram can be tracked to confirm the automation works exactly as expected.
This data can be displayed on a touch panel, used in thermostat logic, or applied to protect blinds when wind speeds are too high.
Beyond the Basics
Lua scripting is not limited to lighting effects or weather data. It can be used to convert values between protocols, prepare calculations before sending commands, or integrate external data sources directly into KNX workflows.
And if writing scripts feels daunting, there is help at hand. By providing context, ChatGPT can generate Lua snippets that can then be tested and refined directly in the 1Home dashboard.
Why It Matters
For KNX professionals, Lua scripting is more than a feature. It is a new level of flexibility that makes projects faster to deliver, more versatile, and more future-ready.
It combines the simplicity of the 1Home Automations block-based automation with the freedom of coding, unlocking new possibilities for those unique client requests that demand something extra.
Lua Scripting will be available on all 1Home devices that include 1Home Automations, including System Manager and Server KNX Pro.