diff --git a/custom_components/ams/__init__.py b/custom_components/ams/__init__.py index 710a8d5..bfe15d3 100755 --- a/custom_components/ams/__init__.py +++ b/custom_components/ams/__init__.py @@ -1,4 +1,5 @@ """AMS hub platform.""" +import asyncio import logging import threading from copy import deepcopy @@ -409,10 +410,15 @@ def _check_for_new_sensors_and_update(self, sensor_data): _LOGGER.debug("Got %s new devices from the serial", len(new_devices)) _LOGGER.debug("DUMP %s", sensor_data) - self._hass.async_create_task(self._signal_new_sensor()) + asyncio.run_coroutine_threadsafe(self._signal_new_sensor(), + self._hass.loop).result() else: # _LOGGER.debug("sensors are the same, updating states") - async_dispatcher_send(self._hass, SIGNAL_UPDATE_AMS) + asyncio.run_coroutine_threadsafe(self._signal_update_sensors(), + self._hass.loop).result() async def _signal_new_sensor(self) -> None: async_dispatcher_send(self._hass, SIGNAL_NEW_AMS_SENSOR) + + async def _signal_update_sensors(self) -> None: + async_dispatcher_send(self._hass, SIGNAL_UPDATE_AMS) diff --git a/custom_components/ams/manifest.json b/custom_components/ams/manifest.json index e2ef0d5..d21ead5 100755 --- a/custom_components/ams/manifest.json +++ b/custom_components/ams/manifest.json @@ -8,5 +8,5 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/turbokongen/hass-AMS/issues", "requirements": ["pyserial==3.5", "crccheck==1.0"], - "version": "2.0.2" + "version": "2.0.3" }