Skip to content

Commit f312e4a

Browse files
committed
Use dispatcher instead of bus
1 parent 6549593 commit f312e4a

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

custom_components/bluecon/ConfigEntryNotificationInfoStorage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from homeassistant.core import HomeAssistant
44
from typing import Any
55
from .const import SIGNAL_ENTITY_UPDATED
6+
from homeassistant.helpers.dispatcher import dispatcher_send
67

78
class ConfigEntryNotificationInfoStorage(INotificationInfoStorage):
89
def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
@@ -15,7 +16,7 @@ def retrieveCredentials(self) -> dict[str, dict[str, Any]] | None:
1516
def storeCredentials(self, credentials: dict[str, dict[str, Any]]):
1617
new = {**self.__entry.options,
1718
"credentials": credentials}
18-
self.__hass.bus.fire(SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)
19+
dispatcher_send(self.__hass, SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)
1920

2021
def retrievePersistentIds(self) -> list[str] | None:
2122
return self.__entry.options["persistentIds"]
@@ -29,4 +30,4 @@ def storePersistentId(self, persistentId: str):
2930

3031
new = {**self.__entry.options,
3132
"persistentIds": stored_persistent_ids}
32-
self.__hass.bus.fire(SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)
33+
dispatcher_send(self.__hass, SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)

custom_components/bluecon/ConfigEntryOAuthTokenStorage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from homeassistant.config_entries import ConfigEntry
33
from homeassistant.core import HomeAssistant
44
from .const import SIGNAL_ENTITY_UPDATED
5+
from homeassistant.helpers.dispatcher import dispatcher_send
56

67
class ConfigEntryOAuthTokenStorage(IOAuthTokenStorage):
78
def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
@@ -14,4 +15,4 @@ def retrieveOAuthToken(self) -> OAuthToken:
1415
def storeOAuthToken(self, oAuthToken: OAuthToken):
1516
new = {**self.__entry.options,
1617
"token": oAuthToken.toJson()}
17-
self.__hass.bus.fire(SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)
18+
dispatcher_send(self.__hass, SIGNAL_ENTITY_UPDATED.format(self.__entry.entry_id), new)

custom_components/bluecon/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .ConfigEntryOAuthTokenStorage import ConfigEntryOAuthTokenStorage
33
from .ConfigEntryNotificationInfoStorage import ConfigEntryNotificationInfoStorage
44
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
5-
from homeassistant.helpers.dispatcher import dispatcher_send
5+
from homeassistant.helpers.dispatcher import dispatcher_send, async_dispatcher_connect
66
from bluecon import BlueConAPI, INotification, CallNotification, CallEndNotification
77
from homeassistant.core import HomeAssistant, callback
88
from homeassistant.config_entries import ConfigEntry
@@ -34,12 +34,12 @@ async def cleanup(event):
3434
await bluecon.stopNotificationListener()
3535

3636
@callback
37-
async def updateConfigEntry(event):
37+
async def updateConfigEntry(data):
3838
_LOGGER.warning(f"Updating config entry {entry.entry_id}")
39-
hass.config_entries.async_update_entry(entry, options=event.data)
39+
hass.config_entries.async_update_entry(entry, options=data)
4040

4141
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, cleanup)
42-
hass.bus.async_listen(SIGNAL_ENTITY_UPDATED.format(entry.entry_id), updateConfigEntry)
42+
async_dispatcher_connect(hass, SIGNAL_ENTITY_UPDATED.format(entry.entry_id), updateConfigEntry)
4343
hass.data[DOMAIN][entry.entry_id] = bluecon
4444

4545
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

custom_components/bluecon/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "bluecon",
33
"name": "Fermax Blue",
4-
"version": "0.1.8",
4+
"version": "0.1.9",
55
"documentation": "https://hass-bluecon.afonsogarcia.dev/",
66
"issue_tracker": "https://github.com/AfonsoFGarcia/hass-bluecon/issues",
77
"requirements": ["bluecon==0.1.2", "aiohttp", "oscrypto", "protobuf", "http-ece"],

0 commit comments

Comments
 (0)