Add separate power/energy URLs and multipliers for REST smart plugs (#472)

REST/Webhook smart plugs can now fetch power and energy data from
  individual URLs instead of requiring all values in a single status
  response. Each value falls back to the shared Status URL when no
  separate URL is set, preserving backward compatibility. Added power
  and energy multipliers for unit conversion (e.g. 0.001 for Wh→kWh).
This commit is contained in:
maziggy
2026-04-03 08:31:08 +02:00
parent d327c70006
commit 76adf70fd4
18 changed files with 391 additions and 144 deletions
+18
View File
@@ -1610,6 +1610,24 @@ async def run_migrations(conn):
except OperationalError:
pass # Already applied
# Migration: Add separate REST power/energy URLs and multipliers
try:
await conn.execute(text("ALTER TABLE smart_plugs ADD COLUMN rest_power_url VARCHAR(500)"))
except OperationalError:
pass # Already applied
try:
await conn.execute(text("ALTER TABLE smart_plugs ADD COLUMN rest_power_multiplier REAL DEFAULT 1.0"))
except OperationalError:
pass # Already applied
try:
await conn.execute(text("ALTER TABLE smart_plugs ADD COLUMN rest_energy_url VARCHAR(500)"))
except OperationalError:
pass # Already applied
try:
await conn.execute(text("ALTER TABLE smart_plugs ADD COLUMN rest_energy_multiplier REAL DEFAULT 1.0"))
except OperationalError:
pass # Already applied
# Migration: Add batch_id column to print_queue for batch grouping
try:
await conn.execute(