Skip to content

Commit 5df6b2c

Browse files
committed
Fix TypeError: coroutine was expected, got None
- Replace async_create_task() calls with direct calls to async_write_ha_state() - async_write_ha_state() is synchronous, not a coroutine - Fixes issue reported in #54 comments where users got TypeError - Updated both template_sensor_state_listener and template_sensor_startup callbacks
1 parent f7ddf68 commit 5df6b2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

custom_components/attributes/sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def async_added_to_hass(self):
266266
@callback
267267
def template_sensor_state_listener(event):
268268
"""Handle device state changes."""
269-
self.hass.async_create_task(self.async_write_ha_state())
269+
self.async_write_ha_state()
270270

271271
@callback
272272
def template_sensor_startup(event):
@@ -275,7 +275,7 @@ def template_sensor_startup(event):
275275
self.hass, self._entity, template_sensor_state_listener
276276
)
277277

278-
self.hass.async_create_task(self.async_write_ha_state())
278+
self.async_write_ha_state()
279279

280280
self.hass.bus.async_listen_once(
281281
EVENT_HOMEASSISTANT_START, template_sensor_startup

0 commit comments

Comments
 (0)