Scaffold a new IoT device integration module with InfluxDB metrics
Scaffold a new IoT device integration for the iot-fetcher platform.
name (required): The integration name in snake_case (e.g. my_device)interval (optional): Scheduler interval, defaults to every(5).minutesfetcher-core/python/src/{name}.py following this pattern:import os
import logging
from influx import write_influx, Point
logger = logging.getLogger(__name__)
# Configuration from environment
# TODO: Add required env vars
host = os.environ.get('{NAME}_HOST', '')
def {name}():
if not host:
logger.error("[{name}] {NAME}_HOST environment variable not set, ignoring...")
return
try:
_fetch_{name}()
except Exception:
logger.warning("[{name}] Unexpected error", exc_info=True)
def _fetch_{name}():
logger.info("[{name}] Fetching data...")
# TODO: Implement device communication
points = [
Point("{name}_measurement")
.tag("source", "{name}")
.field("value", 0.0)
]
write_influx(points)
Register in fetcher-core/python/src/main.py:
from {name} import {name}sys.argv[1] in [...] list in the CLI handlerfor m in [...] list in the CLI handlerschedule.every(5).minutes.do({name}) (adjust interval as needed)Add environment variables to fetcher-core/python/.env.template:
Summary: Print what was created and what the developer needs to do next:
_fetch_{name}().envfetcher-core/python/requirements.txt