Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 40f74f9b8b | |||
| 5e1c07cecf | |||
| 2cfb881cc0 | |||
| c5d216e458 | |||
| 4f08cbbd6d |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,10 +1,15 @@
|
|||||||
# CHANGELOG - Whatsapp Bridge Integration
|
# CHANGELOG - Whatsapp Bridge Integration
|
||||||
|
|
||||||
|
## Release 0.2.1 - 2026-06-15
|
||||||
|
- **Fix:** Resolved device assignment duplication. Instead of a rigid global gateway card duplicating across all account tabs, a distinct and separate Home Assistant device is now generated for each configured account (*Larissa, Rene, Work*).
|
||||||
|
- **Fix:** Globalized the live status sensor and the broadcast entity. They are now instantiated exactly once for the entire integration (rather than incorrectly duplicating per account) and exist as free entities without device assignment to maintain a clean UI layout.
|
||||||
|
- **Optimization:** Code refactoring within `sensor.py` to prevent entity duplication when utilizing multiple profiles.
|
||||||
|
|
||||||
## Release 0.2.0 - 2026-06-15
|
## Release 0.2.0 - 2026-06-15
|
||||||
- New: Setup of a main device (WhatsApp Bridge Gateway) in the Home Assistant device registry.
|
- **New:** Setup of a main device (WhatsApp Bridge Gateway) in the Home Assistant device registry.
|
||||||
- New: Integrated global service `whatsapp_bridge.send_broadcast`, which operates independently of individual profile entities and can send messages to any number or group ID.
|
- **New:** Integrated global service `whatsapp_bridge.send_broadcast`, which operates independently of individual profile entities and can send messages to any number or group ID.
|
||||||
- New: Added status sensor (`sensor.whatsapp_bridge_status`). This queries the add-on's new API and provides the current connection status (`CONNECTED`, `WAITING_FOR_SCAN`, `INITIALIZING`, `OFFLINE`) directly within Home Assistant.
|
- **New:** Added status sensor (`sensor.whatsapp_bridge_status`). This queries the add-on's new API and provides the current connection status (`CONNECTED`, `WAITING_FOR_SCAN`, `INITIALIZING`, `OFFLINE`) directly within Home Assistant.
|
||||||
- Improved: The sensor is assigned to the new main device, which significantly simplifies automations (e.g., alert on connection loss).
|
- **Improved:** The sensor is assigned to the new main device, which significantly simplifies automations (e.g., alert on connection loss).
|
||||||
|
|
||||||
## Release 0.1.7
|
## Release 0.1.7
|
||||||
- Previous stable version
|
- Previous stable version
|
||||||
@@ -9,20 +9,20 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry):
|
async def async_setup_entry(hass: HomeAssistant, entry):
|
||||||
"""Set up entry, create general device and forward to sensor platform."""
|
"""Set up entry, create specific contact device and forward to sensor platform."""
|
||||||
# Lege die Daten im hass-Objekt ab
|
# Lege die Daten im hass-Objekt ab
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][entry.entry_id] = entry.data
|
hass.data[DOMAIN][entry.entry_id] = entry.data
|
||||||
|
|
||||||
# 1. Hauptgerät (General Device) im Device Registry anlegen
|
# 1. Eigenes Gerät SPEZIFISCH für diesen Account/Kontakt anlegen
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
device_registry.async_get_or_create(
|
device_registry.async_get_or_create(
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
identifiers={(DOMAIN, "general_gateway")},
|
identifiers={(DOMAIN, entry.entry_id)}, # Einzigartig pro Eintrag
|
||||||
name="WhatsApp Bridge Gateway",
|
name=f"WhatsApp {entry.title}",
|
||||||
manufacturer="Bahmcloud",
|
manufacturer="Bahmcloud",
|
||||||
model="Bridge Server v0.2.0",
|
model="Kontakt-Endpunkt",
|
||||||
sw_version="0.2.0",
|
sw_version="0.2.1",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Forward the setup to the sensor platform to create entities
|
# Forward the setup to the sensor platform to create entities
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"documentation": "https://git.bahmcloud.de/bahmcloud/Whatsapp-Bridge-Integration",
|
"documentation": "https://git.bahmcloud.de/bahmcloud/Whatsapp-Bridge-Integration",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": ["@bahmcloud"],
|
"codeowners": ["@bahmcloud"],
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"config_flow": true
|
"config_flow": true
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ from .const import DOMAIN
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Polling-Intervall (15 Sekunden)
|
|
||||||
SCAN_INTERVAL = timedelta(seconds=15)
|
SCAN_INTERVAL = timedelta(seconds=15)
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
@@ -37,22 +36,19 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
update_interval=SCAN_INTERVAL,
|
update_interval=SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ersten Abruf vor dem Erstellen der Entitäten erzwingen
|
|
||||||
try:
|
try:
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
except UpdateFailed:
|
except UpdateFailed:
|
||||||
_LOGGER.warning("Erster Status-Abruf fehlgeschlagen. Add-on läuft eventuell noch an.")
|
_LOGGER.warning("Erster Status-Abruf fehlgeschlagen. Add-on läuft eventuell noch an.")
|
||||||
|
|
||||||
# Basis-Entitäten: Account-Sensor und der neue Live-Status-Sensor
|
# Jeder Account bekommt immer seine eigene Entität
|
||||||
entities = [
|
entities = [WhatsAppAccountEntity(entry)]
|
||||||
WhatsAppAccountEntity(entry),
|
|
||||||
WhatsAppStatusSensor(coordinator, entry)
|
|
||||||
]
|
|
||||||
|
|
||||||
# Prüfen, ob die Broadcast-Entität schon existiert
|
# Globale Entitäten (Status & Broadcast) NUR EINMALIG für die gesamte Integration anlegen
|
||||||
if not hass.data[DOMAIN].get("broadcast_registered"):
|
if not hass.data[DOMAIN].get("global_entities_registered"):
|
||||||
|
entities.append(WhatsAppStatusSensor(coordinator))
|
||||||
entities.append(WhatsAppBroadcastEntity())
|
entities.append(WhatsAppBroadcastEntity())
|
||||||
hass.data[DOMAIN]["broadcast_registered"] = True
|
hass.data[DOMAIN]["global_entities_registered"] = True
|
||||||
|
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
@@ -75,14 +71,14 @@ class WhatsAppAccountEntity(SensorEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Ordnet diesen Sensor dem Hauptgerät zu."""
|
"""Ordnet diesen Sensor seinem spezifischen Personen-Gerät zu."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, "general_gateway")},
|
identifiers={(DOMAIN, self._entry.entry_id)},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class WhatsAppBroadcastEntity(SensorEntity):
|
class WhatsAppBroadcastEntity(SensorEntity):
|
||||||
"""Virtual 'All Accounts' Entity."""
|
"""Virtual 'All Accounts' Entity (Global, keinem spezifischen Gerät zugeordnet)."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._attr_name = "WhatsApp Broadcast (All)"
|
self._attr_name = "WhatsApp Broadcast (All)"
|
||||||
self._attr_unique_id = "whatsapp_bridge_broadcast_all"
|
self._attr_unique_id = "whatsapp_bridge_broadcast_all"
|
||||||
@@ -95,22 +91,14 @@ class WhatsAppBroadcastEntity(SensorEntity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
return "Global"
|
return "Global"
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Ordnet diesen Sensor dem Hauptgerät zu."""
|
|
||||||
return DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, "general_gateway")},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class WhatsAppStatusSensor(SensorEntity):
|
class WhatsAppStatusSensor(SensorEntity):
|
||||||
"""Echter Live-Status-Sensor, gekoppelt an die Add-on API."""
|
"""Echter Live-Status-Sensor (Global, keinem spezifischen Gerät zugeordnet)."""
|
||||||
|
|
||||||
def __init__(self, coordinator, entry):
|
def __init__(self, coordinator):
|
||||||
self.coordinator = coordinator
|
self.coordinator = coordinator
|
||||||
self._entry = entry
|
|
||||||
self._attr_name = "WhatsApp Bridge Status"
|
self._attr_name = "WhatsApp Bridge Status"
|
||||||
self._attr_unique_id = f"{entry.entry_id}_bridge_live_status"
|
self._attr_unique_id = "whatsapp_bridge_live_status_global"
|
||||||
self._attr_icon = "mdi:whatsapp"
|
self._attr_icon = "mdi:whatsapp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -148,13 +136,6 @@ class WhatsAppStatusSensor(SensorEntity):
|
|||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Ordnet diesen Sensor dem Hauptgerät zu."""
|
|
||||||
return DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, "general_gateway")},
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Registrieren beim Live-Coordinator."""
|
"""Registrieren beim Live-Coordinator."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
|||||||
Reference in New Issue
Block a user