Ewon Flexy Script
A timed Flexy BASIC script that runs directly on the Ewon Flexy 205 gateway. Every 5 minutes it reads all defined device tags, builds a WaterlyConnect JSON payload, and POSTs it to the API. No external server, no middleware — the gateway handles everything on-device.
300sDefault poll interval
0External servers needed
BASICFlexy native scripting
Prerequisites
- An Ewon Flexy 205 device with Internet connectivity.
- Access to the Flexy web interface (for loading BASIC scripts via the BASIC IDE).
- Waterly credentials: API token, device ID, and submission URL. Email support@waterly.com to request them.
- Outbound HTTPS access from the Flexy to
app.waterlyapp.com.
Load the Script
- 1Open the Flexy web interface in your browser and navigate to Setup ▸ Scripting ▸ BASIC IDE.
- 2Paste the full contents of
flexy-basic.txtinto the editor. - 3Click Save & Run. The script starts immediately and will fire on the 300-second timer.
- 4Optionally enable Autorun so the script restarts automatically after a device reboot.
Configure Credentials
At the top of the SendData routine, replace the placeholder values with your Waterly credentials before saving:
$token$ = "<YOUR_API_TOKEN>"
$deviceId$ = "<YOUR_DEVICE_ID>"
$url$ = "https://app.waterlyapp.com/connect/submit"
Keep your API token private. Do not commit it to Git or share it outside the Flexy device. Use Ewon's built-in user security to restrict script editor access.
How It Works
- Timer fires every 300 seconds —
TSET 1,300sets the interval;ONTIMER 1,"Goto SendData"calls the routine. - Timestamp is captured as Flexy system time in Unix seconds via
GETSYS PRG,"TIMESEC". - Tag loop iterates over all defined Flexy tags using
GETSYS PRG,"NBTAGS", reading name and current value for each. - JSON payload is assembled in-memory and POSTed to WaterlyConnect via
REQUESTHTTPXwith the required auth headers. - Response handling — the
onEventroutine prints the HTTP status code to Flexy diagnostic logs. - Runs at startup as well as on each timer tick — first submission happens immediately when the script is loaded.
Script Structure
//Timer: fires every 300 seconds (5 minutes)
TSET 1,300
ONTIMER 1,"Goto SendData"
GOTO SendData //also run immediately at startup
SendData:
$token$ = "<YOUR_API_TOKEN>"
$deviceId$ = "<YOUR_DEVICE_ID>"
$url$ = "https://app.waterlyapp.com/connect/submit"
//Auth headers required by WaterlyConnect
header$ = "Content-Type=application/json&" +
"x-waterly-request-type=WaterlyConnect&" +
"x-waterly-connect-token=" + $token$
currentTime% = GETSYS PRG, "TIMESEC" //Unix timestamp
//Loop all defined tags on this Flexy device
NumberOfTags% = GETSYS PRG, "NBTAGS"
FOR a% = 0 TO NumberOfTags% - 1
SETSYS TAG, "LOAD", -a%
tagName$ = GETSYS TAG, "Name"
tagValue$ = GETSYS TAG, "TagValue"
//... build tagList$ JSON array
NEXT a%
//POST the assembled JSON payload
REQUESTHTTPX $url$, "POST", header$, json$
Files
BASIC script
The complete Flexy BASIC script ready to paste into the BASIC IDE on your device.
Download .txtPackage README
Step-by-step setup, optional conditional group logic, and debugging guidance.
Open README