Skip to content

Commit

Permalink
Merge pull request #150 from elad-bar/fix-async-dispatcher
Browse files Browse the repository at this point in the history
Fix async dispatcher send
  • Loading branch information
elad-bar authored May 17, 2024
2 parents 2de043b + f42d6ee commit 102ba01
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.7

- Fix async dispatcher send

## 2.1.6

- Fix update interface state [#145](https://github.com/elad-bar/ha-edgeos/issues/145)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/edgeos/managers/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.dispatcher import dispatcher_send

from ..common.connectivity_status import ConnectivityStatus
from ..common.consts import (
Expand Down Expand Up @@ -400,7 +400,7 @@ def _async_dispatcher_send(self, signal: str, *args: Any) -> None:
self._local_async_dispatcher_send(signal, None, *args)

else:
async_dispatcher_send(self._hass, signal, self._entry_id, *args)
dispatcher_send(self._hass, signal, self._entry_id, *args)

async def async_send_heartbeat(self, max_age=HEARTBEAT_MAX_AGE):
ts = None
Expand Down
8 changes: 4 additions & 4 deletions custom_components/edgeos/managers/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.dispatcher import dispatcher_send

from ..common.connectivity_status import ConnectivityStatus
from ..common.consts import (
Expand Down Expand Up @@ -395,15 +395,15 @@ def _set_status(self, status: ConnectivityStatus):
status,
)

def set_local_async_dispatcher_send(self, dispatcher_send):
self._local_async_dispatcher_send = dispatcher_send
def set_local_async_dispatcher_send(self, callback):
self._local_async_dispatcher_send = callback

def _async_dispatcher_send(self, signal: str, *args: Any) -> None:
if self._hass is None:
self._local_async_dispatcher_send(signal, self._entry_id, *args)

else:
async_dispatcher_send(self._hass, signal, self._entry_id, *args)
dispatcher_send(self._hass, signal, self._entry_id, *args)

def _increase_counter(self, key):
counter = self.data.get(key, 0)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/edgeos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/elad-bar/ha-edgeos/issues",
"requirements": ["aiohttp"],
"version": "2.1.6"
"version": "2.1.7"
}

0 comments on commit 102ba01

Please sign in to comment.