This commit introduces a complete integration for Mirabox StreamDock devices with Home Assistant, allowing users to control entities and monitor states directly from the hardware. Key features included: - Support for multiple Mirabox models: N1, N3, N4, N4Pro, XL, M3, M18, K1Pro, and various 293 variants. - Home Assistant WebSocket integration for real-time entity updates and service execution. - Dynamic LCD key rendering with support for custom icons, labels, and entity-state aware colors. - Input handling for physical buttons and rotary encoders (knobs). - Multi-page navigation support with configurable cycle keys and knobs. - Cross-platform transport layer using a custom HID library. - Configuration system using YAML with page-based layouts. - Linux udev rules for non-root USB access.
30 lines
664 B
Python
30 lines
664 B
Python
import yaml
|
|
import os
|
|
|
|
CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.yaml")
|
|
|
|
_defaults = {
|
|
"homeassistant": {
|
|
"url": "ws://homeassistant.local:8123/api/websocket",
|
|
"token": "",
|
|
},
|
|
"pages": [],
|
|
}
|
|
|
|
|
|
def load_config(path=None):
|
|
p = path or CONFIG_PATH
|
|
with open(p, "r") as f:
|
|
cfg = yaml.safe_load(f)
|
|
if not cfg:
|
|
cfg = {}
|
|
for k, v in _defaults.items():
|
|
if k not in cfg:
|
|
cfg[k] = v
|
|
return cfg
|
|
|
|
|
|
def save_config(cfg, path=None):
|
|
p = path or CONFIG_PATH
|
|
with open(p, "w") as f:
|
|
yaml.dump(cfg, f, default_flow_style=False, sort_keys=False) |