Skip to content

About

This repository contains API manual for SLZB-OS scripting language and example scripts

Resources

Stars

74 stars

Watchers

4 watching

Forks

Latest commit

 

History

122 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SLZB-OS Berry Scripting

SLZB-OS is the operating system for SLZB-06x, SLZB-MRx, and U-series Zigbee coordinators. It includes a built-in scripting engine powered by the Berry language that lets you automate your smart home directly on the coordinator — no additional server or hub required.

This repository contains the full scripting API documentation and ready-to-use examples.

What Can You Automate?

Smart Home Control

Turn Zigbee relays, lamps, and other devices on and off from scripts — triggered by buttons, schedules, or sensor data.

import ZHB
ZHB.waitForStart(0xff)
var lamp = ZHB.getDevice("Living Room Lamp")
lamp.sendOnOff(1)       # turn on
lamp.sendBri(200)       # set brightness
lamp.sendColor("#ff8800")  # warm orange

Button Automation

React to Zigbee button presses (single, double, long) to control any device.

import ZHB
ZHB.waitForStart(0xff)
var relay = ZHB.getDevice("Kitchen Relay")

def on_action(action, dev)
  if dev.getName() == "My Button" && action == "single"
    relay.sendOnOff(1)
  end
end
ZHB.on_action(on_action)

Monitoring and Alerts

Watch your Zigbee network and send notifications via Telegram, Discord, email, or any messaging service.

import TELEGRAM
TELEGRAM.send("Zigbee coordinator is online!")
import MQTT
MQTT.waitConnect(0xff)
MQTT.publish("alerts", "Sensor triggered!")

Scheduling

Reboot the device daily, check sensors on an interval, or run actions at specific times.

import TIME
TIME.waitSync(0xff)
var t = TIME.getAll()
SLZB.log("Current time: " .. t["hour"] .. ":" .. t["min"])

Hardware Control (Advanced)

Control GPIO pins, play melodies on the buzzer, drive LED strips, or send/receive IR commands on supported devices.

import GPIO
GPIO.pinMode(46, GPIO.MOD_OUTPUT)
GPIO.digitalWrite(46, 1)  # turn on LED

Getting Started

New to Berry scripting on SLZB-OS? Start here:

Getting Started Guide — How scripts work, metadata, and the event system.

Berry language resources:


Module Reference

Each module is documented in its own file with API details, examples, and cross-references.

AI Skills: Every doc in docs/modules/ — both modules and integrations — serves as a skill for the built-in AI Assistant in your SLZB device. The content is automatically extracted and loaded on-demand when the AI needs to write scripts. To keep this working correctly, all pages must follow this structure:

  • # Title — module/integration name (first line, used as skill summary)
  • ## Setup — configuration instructions (stripped from AI skill — setup is handled separately)
  • ## API Reference — summary table first (one row per function, event and class method, in the signature format below), then optional ### MOD.fn(...) -> ret detail sections with parameter tables, **Returns:** notes and inline code examples (included in AI skill)
  • ## Common Patterns — useful code templates (included in AI skill)
  • ## Notes — constraints, memory usage, edge cases (included in AI skill)
  • ## Examples — verbose standalone examples (stripped from AI skill — AI generates its own)
  • ## See Also — cross-references to related pages (stripped from AI skill)

The build script (gulpfile.js → buildSkills) strips ## Setup, ## Examples, and ## See Also to keep AI skills concise. Everything else is included. This applies to all .md files in docs/modules/.

Signature format. Every function, event and class method has a row in the ## API Reference table — that table is the single machine-readable source for the script editor (completions, argument hints, hover docs). A function may additionally get a ### detail section; its heading must repeat the table signature verbatim. Both use one form:

MOD.fn(name:type, opt:type?, other:int=1, ...rest:int) -> ret
MOD.on_event(callback:function(arg:type, dev:ZigbeeDevice) -> nil) -> nil
  • Types: int, real, string, bool, nil, bytes, list, map, function, a class name (ZigbeeDevice, File); unions as string|int, element types as list<string>. Inside a table cell escape the union bar: `string\|int`.
  • ? marks an optional parameter, =value an optional parameter with a known default, ...name:type a variadic tail.
  • -> ret is mandatory; use -> nil when nothing is returned. A **Returns:** line or a | Key | Type | Description | table may follow to describe the value in more detail (e.g. the keys of a returned map).
  • Class methods are written with the class name as prefix under a ### Class Name heading: ZigbeeDevice.getName() -> string.
  • A callback parameter carries its own shape inline — callback:function(action:string, dev:ZigbeeDevice) -> nil — so events are self-describing (the editor uses it to type the callback's arguments); function without a shape means "any function".
  • A | Parameter | Type | Description | table after a heading is optional and only adds descriptions — the signature stays the single source of truth for names, types, optionality and defaults.

Modules

Module Description Min Firmware Devices
SLZB Core functions — delays, logging, reboot, device info v2.8.0 All
ZB Low-level Zigbee chip access — read/write bytes, socket control v2.8.0 All
WEBSERVER Receive HTTP requests via webhook endpoint v2.8.2.dev0 All
ZHB Zigbee Hub — control relays, lamps, sensors, buttons v2.9.6 All*
HTTP Make outgoing HTTP/HTTPS GET and POST requests v2.9.8 All
TIME Date, time, and NTP synchronization v3.0.6 All
FS File system — read, check, delete files v3.0.6 All
GPIO Direct GPIO pin control, PWM, frequency generation v3.1.6.dev3 All
MQTT Subscribe and publish MQTT messages v3.2.4 All
BUZZER Play melodies on the built-in buzzer v3.2.5.dev1 Ultima only
BUTTON Override physical button actions v3.2.5.dev1 All
AMBILIGHT WS2812B LED strip effects and colors v3.2.5.dev1 Ultima only
IR Transmitter Send infrared commands to TVs, ACs, and other IR devices v3.2.5.dev1 Ultima only
IR Receiver Receive IR signals from remote controls, learn and replay codes v3.2.5.dev1 Ultima only
RF Sub-1 GHz RF transceiver add-on (CC1101): sniff, replay and store 315/433/868/915 MHz OOK commands v3.3.5 Ultima + RF add-on
LTE 4G/LTE add-on modem: raw AT commands, connection status, read / send / receive SMS v3.3.8.dev8 Ultima / U2L + 4G/LTE add-on
WG WireGuard VPN client: tunnel / peer state, last handshake, reconnect, state change callback v3.3.8.dev8 All
Audio Player Play mp3 files from HTTP stream or from internal memory v3.3.3.dev0 Ultima only
NETWORK Network state — readiness, Ethernet/Wi-Fi status, IP addresses v2.9.7 All
SSE Server-Sent Events for real-time push to browsers v3.2.5.dev1 All
TIMER Repeating and one-shot timers v3.2.5.dev1 All
BLE Receiving BLE advertisements v3.3.3.dev7 U series and Ultima
ISC Inter-script communication — send messages between running scripts v3.3.8.dev7 U series and Ultima
UI Show messages to the user in the web interface v3.3.8.dev7 U series and Ultima
BEAPP App backend — web-app page lifecycle and messaging v3.3.8.dev7 U series and Ultima
TCP_SERVER Raw TCP server class — accept connections, exchange binary-safe data v3.3.8.dev8 U series and Ultima
TCP_CLIENT Raw TCP client class — outgoing connections to plain-TCP services v3.3.8.dev8 U series and Ultima
UDP_SERVER UDP server class — receive datagrams on a port, multicast groups v3.3.8.dev8 U series and Ultima
UDP_CLIENT UDP client class — send datagrams, read the replies v3.3.8.dev8 U series and Ultima
USBH Your gateway to USB serial devices: list, open, read / write, baud rate, DTR / RTS v3.4.2.dev1 U series and Ultima

Integrations

Modules for connecting to external services. Configure credentials via the Scripts Integrations UI page or directly in scripts.

Integrations are fully supported on U-series devices (SLZB-06xU, SLZB-MRxU, Ultima). Non-U devices have limited RAM and may experience slow downs when using integrations — avoid using them on non-U hardware.

Integration Description
TELEGRAM Send and receive Telegram messages via Bot
WHATSAPP Send WhatsApp messages via CallMeBot
TEAMS Send notifications to Microsoft Teams via webhook
SLACK Send messages to Slack channels via webhook
DISCORD Send notifications to Discord via webhook
PUSHOVER Push notifications with priority levels and sounds
PROWL Push notifications to iOS via Prowl with priority levels and links
NTFY Push notifications via ntfy.sh
EMAIL Send email alerts via SMTP
HA Call Home Assistant services and read entity states
IFTTT Trigger IFTTT applets via webhooks
OPENWRT OpenWrt router — presence detection, clients, system info
WOL Wake-on-LAN — wake computers and devices on your network
HUE Control Philips Hue lights via Bridge v1 API
WLED Control WLED-powered LED strips
SLWF03 SMLIGHT SLWF-03 Sound WLED controller (WLED alias)
SLWF09 SMLIGHT SLWF-09 ETH POE WLED controller (WLED alias)
ESPHOME Control any ESPHome device via REST API
SLWF01 SMLIGHT SLWF-01 A/C Controller (ESPHome alias)
SLWF08 SMLIGHT SLWF-08 HDMI-CEC controller (ESPHome alias)
WEATHER Get weather forecasts from OpenWeatherMap
AIRQUALITY Get air quality index and pollutant data
SUN Get sunrise and sunset times (v3.3.3.dev0)
GSHEETS Log data to Google Sheets via Apps Script
INFLUXDB Write time-series data to InfluxDB v2 for Grafana
KODI Control Kodi media center — playback, volume, notifications
TASMOTA Control Tasmota WiFi devices — plugs, lights, switches
NUKI Control Nuki smart locks via Bridge HTTP API
PING ICMP ping — check if hosts are reachable on your network
WEBHOOK Generic HTTP client — connect any REST API
n8n Trigger n8n workflows from Zigbee events (uses WEBHOOK)
Node-RED Trigger Node-RED flows from Zigbee events (uses WEBHOOK)
Frigate React to AI camera detections — people, cars, animals (uses MQTT)
OpenHAB Control OpenHAB items and rules (uses HTTP)
Domoticz Control Domoticz switches, scenes, and sensors (uses HTTP)
Jeedom Execute Jeedom commands and scenarios (uses HTTP)
ioBroker Read and set ioBroker states via Simple API (uses HTTP)

Guides

In-depth tutorials for common use cases:

Guide Description
Zigbee Button & Action Events Handle button clicks, rotary encoders, and multi-button remotes

Examples

Ready-to-use scripts in the examples/ folder:

Example Description Modules Used
reboot_every_day.be Reboot device every 24 hours SLZB
zb_reboot_on_drop.be Reboot Zigbee chip when all clients disconnect ZB
get_file_size.be Read and display file size FS
http_get.be Fetch JSON from an API HTTP
http_post.be Send JSON data via POST HTTP
report_stats.be Track Zigbee device report counts, serve via webhook ZB, WEBSERVER
simple_thermostat.be Thermostat using Zigbee sensor + relay ZHB
reboot_at_3am.be Reboot device daily at 3:00 AM TIME
log_datetime.be Log current date and time TIME
alarm.be Gentle wake-up alarm with gradual LED brightness and buzzer melodies TIME, AMBILIGHT, BUZZER
blink_led.be Blink an LED on/off every second GPIO
read_analog.be Read voltage on an analog pin GPIO
mqtt_subscribe.be Subscribe to MQTT topic and log messages MQTT
mqtt_publish_temperature.be Publish Zigbee sensor temperature to MQTT MQTT, ZHB
play_melody.be Play an RTTTL melody on the buzzer BUZZER
doorbell.be Zigbee button triggers a doorbell sound BUZZER, ZHB
button_toggle_relay.be Physical button toggles a Zigbee relay BUTTON, ZHB
effects_demo.be Cycle through all LED effects AMBILIGHT
color_cycle_on_button.be Zigbee button cycles LED colors AMBILIGHT, ZHB
send_nec_command.be Send an NEC IR command IR
zigbee_button_sends_ir.be Zigbee button sends IR commands to TV IR, ZHB
log_ir_codes.be Log all received IR codes (discovery tool) IR
ir_to_zigbee_bridge.be Control Zigbee devices with an IR remote IR, ZHB

Community examples:


AI-Assisted Scripting

SLZB-OS includes a built-in AI Assistant that can create Berry scripts, control the device, and configure integrations via natural language.

The AI uses a skills system: instead of loading all module docs at once, it loads only the specific modules needed for each task (e.g., telegram + zhb for "notify me on Telegram when button pressed"). Each module doc in docs/modules/ is automatically converted to a skill at build time.


Ukrainian Documentation

A Ukrainian version of the base documentation is available in README_UA.md. Note: It covers only the core modules (SLZB, ZB, WEBSERVER, FS). For the full and up-to-date reference, please use the English documentation above.

About

This repository contains API manual for SLZB-OS scripting language and example scripts

Resources

Stars

74 stars

Watchers

4 watching

Forks

Contributors