Skip to content

Example: Smart Greenhouse

Read + write with a control loop. All four property types.

python
from odevice import App, Device, Number, Boolean, Enum

greenhouse = Device(
    id="gh-01",
    name="Smart Greenhouse",
    properties={
        "temperature": Number(unit="°C", min=0, max=50, view="gauge"),
        "humidity": Number(unit="%", min=0, max=100, view="gauge"),
        "fan": Boolean(writable=True),
        "mode": Enum(options=["auto", "manual", "night", "day"], writable=True),
    },
)

@greenhouse.on_write("fan")
async def set_fan(value):
    # control physical relay
    return value

Run: python examples/smart-greenhouse/main.py

Demonstrates: gauge, switch, enum select, write callbacks, control loop feedback.

Built for self-hosted IoT runtimes.