
Open media
The Programs section is where you manage the automation programs installed in your HomeGenie system. Programs can be created using the visual programming editor, which automatically generates the underlying code, or by writing the code directly in C#, JavaScript, or Python using the built-in editor.
Regardless of the authoring method (visual or textual) or the specific language used, all programs utilize the common HomeGenie API to interact with system modules and data.
Your system's intelligence is fundamentally shaped by the programs it runs, dictating capabilities, automating tasks, and implementing custom logic. Mastering program creation and management within this section is therefore key to truly tailoring your HomeGenie's capabilities.
Specifically, from the Programs page, you can:
.zip
archive including code and data).While you manage individual programs directly here, remember that the Package Manager allows you to bundle collections of these programs into distributable packages, facilitating easier sharing or deployment across systems.
Tapping the more_vert icon next to a program's title opens its context menu, offering the following actions:
.zip
archive (containing its script and data folder), ideal for individual backup or sharing.Using the HomeGenie API, programs can dynamically extend the system with new features and functionality. This includes the capability to add new UI fields to widgets or introduce new system-wide settings required to configure these added features.
Consequently, disabling such a program will also temporarily remove all its contributions (like custom UI fields or dedicated settings) until the program is re-enabled.
The program editor includes a widgets preview area, allowing you to monitor and interact with modules used by the program while editing. It also features several tabs:
Flags are settings available in the Program Data tab:
This flag can be used to run a program in an unattended mode. When active, if an internal error occurs during execution, the program will be automatically restarted. Use this option wisely.
Sometimes it's useful to reuse a program's logic but apply it to different parameters or target devices. When this flag is enabled, the program can be cloned (duplicated) using the context menu (more_vert) option in the main Programs list.
HomeGenie programs typically consist of two main code blocks: Setup and Main.
The Setup code runs once when the program loads, is enabled, or restarts. Its primary role is initialization and integration with HomeGenie. This often involves brief code using API methods like:
Program.AddFeature(...)
: Defines a specific capability or named attribute that can be enabled or configured on a per-module basis for relevant device types (e.g., Lights, Sensors). This adds a control to the module's Settings dialog and allows the program logic (typically in the Main code) to target only those modules where the feature is active.Program.AddOption(...)
: Adds configuration options that control the program's overall behavior (e.g., API keys, file paths, global thresholds), rather than individual modules. These settings appear on the main System -> Settings page, typically under a section for the program, allowing users to customize its general operation. The program's code can then read these values to adapt accordingly.While Setup can also initialize variables, subscribe to system events, or start timers, its core function is preparing the program and linking its unique capabilities (features, settings) into the HomeGenie environment.
The Main code contains the program's core operational logic – the actions performed each time the program is triggered. This code block executes when the program is:
Crucially, if the Setup code section is empty, the program lacks any self-activating triggers (event subscriptions or timers). It effectively becomes an on-demand or scheduled script. In this case, the Main code will only execute via methods 1, 2, or 3 above.
In essence, Main code defines what the program does, while Setup code defines how it integrates and initializes itself, determining (in part) when the Main code might run automatically.
A Context code block is available only for C# programs. It can contain static fields, helper classes, structs, or custom method definitions used by the Setup or Main code blocks within that program.