- Standardize multilog to s25000 n4 (~100KB cap) to prevent filling /data - Use VeDbusService register=False + deferred register() in dbus-generator-ramp and dbus-vrm-history - Add @exit_on_error decorator to template GLib callback - Document best practices in README and template README Made-with: Cursor
dbus-template
Venus OS D-Bus service template. Use this as a starting point for new services.
Getting Started
- Copy this directory:
cp -r _template/ dbus-your-service-name/ - Rename
dbus-template.pyto match your service (e.g.your_service.py) - Update
config.pywith your service name, product ID, and settings - Update
service/runto point to your renamed main script - Update
install.sh: setSERVICE_NAMEandMAIN_SCRIPTvariables - Update
build-package.sh: setPACKAGE_NAMEand the file copy list - Replace this README with your own documentation
Files
| File | Purpose |
|---|---|
dbus-template.py |
Main service with D-Bus registration boilerplate |
config.py |
Configuration constants (service name, product ID, timing) |
service/run |
daemontools entry point |
service/log/run |
multilog configuration |
install.sh |
Venus OS installation (velib symlink, service registration, rc.local) |
uninstall.sh |
Removes service symlink |
build-package.sh |
Creates a deployable .tar.gz package |
D-Bus Paths
Update these for your service:
| Path | Type | Description |
|---|---|---|
/ProductName |
string | Service display name |
/Connected |
int | Connection status (0/1) |
/Settings/Template/Enabled |
int | Enable/disable via settings |
Venus OS Best Practices
The template follows these Venus OS wiki guidelines:
register=False--VeDbusServiceis created withregister=False, paths are added, thenregister()is called to prevent race conditions with consumers.@exit_on_error-- Applied to theGLib.timeout_addcallback so unhandled exceptions crash the process instead of silently dropping the callback.daemon=True-- Set on background threads so they don't prevent process exit.- multilog -- Log size capped at
s25000 n4(~100KB) to avoid filling the/datapartition.
Checklist
- Unique service name in
config.py(com.victronenergy.yourservice) - Unique product ID in
config.py(check existing services to avoid conflicts) - All file references updated in
service/run,install.sh,build-package.sh - Custom D-Bus paths added
- Settings paths updated
@exit_on_erroron allGLib.timeout_addcallbacks- Background threads use
daemon=True - README replaced with your own documentation