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