Files
GsmNode/Home Assistant Plugin/custom_components/gsmnode/binary_sensor.py
T
tajniak81 d6956395c8 Rebrand CommGate to gsmnode and adopt new design system
Rename the whole project from CommGate to gsmnode and re-skin every
surface onto the new signal-green + ink design system (Space Grotesk /
IBM Plex Sans / JetBrains Mono, flat surfaces, two-arrow routing mark,
lowercase gsm+node wordmark).

- Web App + API panel: rewrite token layer, gn-* utilities, data-gsm-theme,
  new logo/favicon assets; both builds verified.
- Phone App (Flutter): green theme, new mark/wordmark widgets, adaptive
  launcher icons; rename Android applicationId/package to app.gsmnode.phone;
  bump AGP to 8.6.0 and google_fonts to 8.1.0; debug APK build verified.
- API Server (Go): panel routes, User-Agent, health service id, branding.
- Home Assistant Plugin: rename integration domain sms_gateway to gsmnode
  (folder, DOMAIN, services, entity ids, classes); py_compile verified.
- Update all READMEs; add .gitignore (excludes Design/, build artifacts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 08:53:14 +02:00

67 lines
2.1 KiB
Python

"""API Server connectivity binary sensor."""
from __future__ import annotations
import logging
from datetime import timedelta
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
)
from .client import GsmNodeClient
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=30)
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the connectivity sensor for a config entry."""
client: GsmNodeClient = hass.data[DOMAIN][entry.entry_id]
coordinator: DataUpdateCoordinator[bool] = DataUpdateCoordinator(
hass,
_LOGGER,
name="gsmnode_health",
update_method=client.health,
update_interval=SCAN_INTERVAL,
)
await coordinator.async_config_entry_first_refresh()
async_add_entities([GsmNodeHealthSensor(coordinator, entry)])
class GsmNodeHealthSensor(CoordinatorEntity[DataUpdateCoordinator[bool]], BinarySensorEntity):
"""Reports whether the API Server is reachable."""
_attr_has_entity_name = True
_attr_name = "API Server"
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
def __init__(self, coordinator: DataUpdateCoordinator[bool], entry: ConfigEntry) -> None:
super().__init__(coordinator)
self._attr_unique_id = f"{entry.entry_id}_api_health"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, entry.entry_id)},
name="gsmnode",
manufacturer="gsmnode",
)
@property
def is_on(self) -> bool:
"""True when the API Server responded OK on the last check."""
return bool(self.coordinator.data)