Skip to content

Commit

Permalink
Turbokongen/issue104 (#105)
Browse files Browse the repository at this point in the history
* Fix #104

* Remember all instances
  • Loading branch information
turbokongen authored May 5, 2024
1 parent dd9e32c commit d399131
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions custom_components/ams/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""AMS hub platform."""
import asyncio
import logging
import threading
from copy import deepcopy
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion custom_components/ams/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit d399131

Please sign in to comment.