Skip to content

Models

Pydantic data models used across zigporter.

Pydantic data models shared across zigporter.

All models use Pydantic v2. They are used for serialising ZHA export snapshots, tracking migration state, and reporting pre-flight check results.

AutomationRef

Bases: BaseModel

A Home Assistant automation that references one or more ZHA entities.

Collected during export so the migrate wizard can update entity IDs inside automation configs after a device has been re-paired with Z2M.

ATTRIBUTE DESCRIPTION
automation_id

Internal HA automation ID (e.g. "1a2b3c4d5e6f").

TYPE: str

alias

Human-readable name shown in the HA UI.

TYPE: str

entity_references

Entity IDs from this device that appear in the automation.

TYPE: list[str]

CheckResult

Bases: BaseModel

Result of a single pre-flight connectivity or configuration check.

ATTRIBUTE DESCRIPTION
name

Short human-readable check name (e.g. "HA WebSocket").

TYPE: str

status

Outcome of the check.

TYPE: CheckStatus

message

Detail message shown to the user.

TYPE: str

blocking

If True and status is FAILED, the calling command should abort rather than proceed.

TYPE: bool

CheckStatus

Bases: str, Enum

Result severity for a single pre-flight check.

ATTRIBUTE DESCRIPTION
OK

Check passed with no issues.

FAILED

Check failed; the operation should be blocked if blocking=True.

WARNING

Check raised a concern but does not block the operation.

SKIPPED

Check was intentionally not run (e.g. missing optional config).

ZHADevice

Bases: BaseModel

A ZHA device as exported from Home Assistant.

Represents the complete state of a Zigbee device at export time, including its entities, area assignment, and any automations that reference it.

ATTRIBUTE DESCRIPTION
device_id

HA device registry ID (UUID string).

TYPE: str

ieee

IEEE 802.15.4 address in colon-separated hex (e.g. "00:11:22:33:44:55:66:77").

TYPE: str

name

Integration-assigned device name.

TYPE: str

name_by_user

User-customised label shown in the HA UI.

TYPE: str | None

manufacturer

Device manufacturer as reported by the Zigbee coordinator.

TYPE: str | None

model

Device model string.

TYPE: str | None

area_id

HA area registry ID, if the device is assigned to a room.

TYPE: str | None

area_name

Human-readable area name corresponding to area_id.

TYPE: str | None

device_type

Zigbee device role: "EndDevice", "Router", or "Coordinator".

TYPE: str

quirk_applied

True if a ZHA quirk patch was active on the device.

TYPE: bool

quirk_class

Fully-qualified Python class name of the applied quirk.

TYPE: str | None

entities

All entities registered to this device.

TYPE: list[ZHAEntity]

automations

Automations that reference at least one entity of this device.

TYPE: list[AutomationRef]

ZHAEntity

Bases: BaseModel

A single entity belonging to a ZHA device.

ATTRIBUTE DESCRIPTION
entity_id

HA entity ID (e.g. "climate.living_room_thermostat").

TYPE: str

name

Integration-assigned name.

TYPE: str

name_by_user

User-customised label, overrides name in the UI.

TYPE: str | None

platform

Integration platform (always "zha" for ZHA entities).

TYPE: str

unique_id

Stable identifier used by HA to track the entity across renames.

TYPE: str | None

device_class

HA device class (e.g. "temperature", "motion").

TYPE: str | None

disabled

True if the entity is disabled in HA.

TYPE: bool

state

Last-known state string at export time (e.g. "on", "22.5").

TYPE: str | None

attributes

Full state attributes dict at export time.

TYPE: dict

ZHAExport

Bases: BaseModel

Top-level container for a ZHA device inventory snapshot.

Written to ~/.config/zigporter/zha-export.json by zigporter export and read back by zigporter migrate.

ATTRIBUTE DESCRIPTION
exported_at

UTC timestamp when the export was created.

TYPE: datetime

ha_url

HA base URL used during the export (e.g. "http://homeassistant.local:8123").

TYPE: str

devices

All ZHA devices found in the HA registry at export time.

TYPE: list[ZHADevice]