feat: scheduled auto-sync for Zigbee & Z-Wave imports
Mirror the Proxmox auto-sync pattern for the Zigbee2MQTT and Z-Wave JS UI mesh imports. Connection config + MQTT credentials live in .env only, are never persisted to scan_config.json, and are never returned by any API or shown in the UI (single source of truth). - config: ZIGBEE_* / ZWAVE_* env settings; only sync_enabled+interval are persisted, connection/credentials stay env-only - routes: GET/POST /config, POST /sync-now; auto-sync reuses the exact manual _background_*_import + _persist_pending_import path (fresh import when empty, update-in-place when nodes exist, ScanRun trace) - scheduler: zigbee_sync / zwave_sync jobs with live enable + reschedule - frontend: reusable MeshAutoSync section in Settings (Zigbee, Z-Wave) - .env.example: documented both blocks - tests: scheduler jobs, router config/sync-now/auth, credential-never- persisted, SettingsModal sections Manual Zigbee/Z-Wave import behaviour is unchanged. ha-relevant: no
This commit is contained in:
@@ -93,3 +93,29 @@ class ZigbeeImportPendingResponse(BaseModel):
|
||||
coordinator_already_existed: bool = False
|
||||
links_recorded: int
|
||||
device_count: int
|
||||
|
||||
|
||||
class ZigbeeConfig(BaseModel):
|
||||
"""Non-secret Zigbee connection + auto-sync config (GET response).
|
||||
|
||||
MQTT connection fields (host/port/base_topic/tls) are env-only and
|
||||
read-only here — surfaced for display. ``host_configured`` reflects whether
|
||||
a server-side MQTT host is set (required for auto-sync). MQTT credentials
|
||||
(username/password) are never carried."""
|
||||
|
||||
mqtt_host: str = ""
|
||||
mqtt_port: int = Field(1883, ge=1, le=65535)
|
||||
base_topic: str = "zigbee2mqtt"
|
||||
mqtt_tls: bool = False
|
||||
sync_enabled: bool = False
|
||||
sync_interval: int = Field(3600, ge=300)
|
||||
host_configured: bool = False
|
||||
|
||||
|
||||
class ZigbeeSyncConfig(BaseModel):
|
||||
"""User-editable auto-sync config (POST body). The ONLY persisted Zigbee
|
||||
settings. Connection fields (host/port/credentials/topic/tls) are env-only
|
||||
and are deliberately not accepted here."""
|
||||
|
||||
sync_enabled: bool = False
|
||||
sync_interval: int = Field(3600, ge=300)
|
||||
|
||||
@@ -83,3 +83,30 @@ class ZwaveImportPendingResponse(BaseModel):
|
||||
coordinator_already_existed: bool = False
|
||||
links_recorded: int
|
||||
device_count: int
|
||||
|
||||
|
||||
class ZwaveConfig(BaseModel):
|
||||
"""Non-secret Z-Wave connection + auto-sync config (GET response).
|
||||
|
||||
MQTT connection fields (host/port/prefix/gateway_name/tls) are env-only and
|
||||
read-only here — surfaced for display. ``host_configured`` reflects whether
|
||||
a server-side MQTT host is set (required for auto-sync). MQTT credentials
|
||||
(username/password) are never carried."""
|
||||
|
||||
mqtt_host: str = ""
|
||||
mqtt_port: int = Field(1883, ge=1, le=65535)
|
||||
prefix: str = "zwave"
|
||||
gateway_name: str = "zwavejs2mqtt"
|
||||
mqtt_tls: bool = False
|
||||
sync_enabled: bool = False
|
||||
sync_interval: int = Field(3600, ge=300)
|
||||
host_configured: bool = False
|
||||
|
||||
|
||||
class ZwaveSyncConfig(BaseModel):
|
||||
"""User-editable auto-sync config (POST body). The ONLY persisted Z-Wave
|
||||
settings. Connection fields (host/port/credentials/prefix/gateway/tls) are
|
||||
env-only and are deliberately not accepted here."""
|
||||
|
||||
sync_enabled: bool = False
|
||||
sync_interval: int = Field(3600, ge=300)
|
||||
|
||||
Reference in New Issue
Block a user