Files
ha-reticulum/custom_components/reticulum/entity.py
claude b40c527515 Add Reticulum/LXMF integration for Home Assistant
Custom integration connecting Home Assistant to a Reticulum network over a
TCPClientInterface and exchanging LXMF messages, with an Assist conversation
bridge, notify entity, sensors (incl. interface telemetry), buttons, services,
bus events and device triggers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 18:08:12 +03:00

40 lines
1.3 KiB
Python

"""Base entity for the Reticulum integration."""
from __future__ import annotations
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo, Entity
from .const import DOMAIN, SIGNAL_STATE_UPDATED
from .reticulum_client import ReticulumManager
class ReticulumEntity(Entity):
"""Base class wiring entities to the manager state updates."""
_attr_should_poll = False
_attr_has_entity_name = True
def __init__(self, manager: ReticulumManager, entry_id: str) -> None:
self._manager = manager
self._entry_id = entry_id
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, entry_id)},
name="Reticulum",
manufacturer="Reticulum Network Stack",
model="LXMF Peer",
sw_version=manager.state.lxmf_address or None,
configuration_url="https://reticulum.network/",
)
async def async_added_to_hass(self) -> None:
"""Subscribe to state-update signals."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_STATE_UPDATED, self._handle_update
)
)
def _handle_update(self) -> None:
self.async_write_ha_state()