From d9ada23f3ef3694bb7987686eac74e78ee08da48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Tue, 14 Apr 2026 13:40:10 +0000 Subject: [PATCH] =?UTF-8?q?custom=5Fcomponents/whatsapp=5Fbridge=5Fintegra?= =?UTF-8?q?tion/sensor.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../whatsapp_bridge_integration/sensor.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 custom_components/whatsapp_bridge_integration/sensor.py diff --git a/custom_components/whatsapp_bridge_integration/sensor.py b/custom_components/whatsapp_bridge_integration/sensor.py new file mode 100644 index 0000000..b46c6c1 --- /dev/null +++ b/custom_components/whatsapp_bridge_integration/sensor.py @@ -0,0 +1,22 @@ +from homeassistant.components.sensor import SensorEntity +from .const import DOMAIN, CONF_ACCOUNT_NAME + +async def async_setup_entry(hass, entry, async_add_entities): + """Add a sensor for each WhatsApp account.""" + async_add_entities([WhatsAppAccountEntity(entry)], True) + +class WhatsAppAccountEntity(SensorEntity): + """Representation of a WhatsApp Account as an entity.""" + def __init__(self, entry): + self._entry = entry + self._attr_name = f"WhatsApp {entry.title}" + self._attr_unique_id = f"{entry.entry_id}_status" + self._attr_icon = "mdi:whatsapp" + # Wir speichern die Nummer in den Attributen, damit der Service sie findet + self._attr_extra_state_attributes = { + "phone_number": entry.data.get("phone_number") + } + + @property + def state(self): + return "Ready" \ No newline at end of file