M5-T09: add exposed_entities table and ExposableEntity provider framework

This commit is contained in:
2026-06-22 14:50:40 +02:00
parent 14b846549e
commit 360cddc05b
8 changed files with 1114 additions and 5 deletions
@@ -0,0 +1,44 @@
"""add exposed_entity_toggle table
Revision ID: 20260622_10_exposed_entities
Revises: 20260622_09_modbus_tables
Create Date: 2026-06-22 00:00:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "20260622_10_exposed_entities"
down_revision: Union[str, None] = "20260622_09_modbus_tables"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# exposed_entity_toggle — per-entity on/off switch for MQTT / HA Discovery.
op.create_table(
"exposed_entity_toggle",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("key", sa.String(length=255), nullable=False),
sa.Column("enabled", sa.Boolean(), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("key", name="uq_exposed_entity_toggle_key"),
)
# Index on key for fast single-key lookups (toggle by key).
op.create_index(
"ix_exposed_entity_toggle_key",
"exposed_entity_toggle",
["key"],
unique=True,
)
def downgrade() -> None:
# Drop index then table — only removes what this revision created.
op.drop_index("ix_exposed_entity_toggle_key", table_name="exposed_entity_toggle")
op.drop_table("exposed_entity_toggle")