Skip to content

Commit 80cae1d

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 ead612a commit 80cae1d

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
@@ -263,7 +263,7 @@ async def async_added_to_hass(self):
263263
@callback
264264
def template_sensor_state_listener(event):
265265
"""Handle device state changes."""
266-
self.hass.async_create_task(self.async_write_ha_state())
266+
self.async_write_ha_state()
267267

268268
@callback
269269
def template_sensor_startup(event):
@@ -272,7 +272,7 @@ def template_sensor_startup(event):
272272
self.hass, self._entity, template_sensor_state_listener
273273
)
274274

275-
self.hass.async_create_task(self.async_write_ha_state())
275+
self.async_write_ha_state()
276276

277277
self.hass.bus.async_listen_once(
278278
EVENT_HOMEASSISTANT_START, template_sensor_startup

0 commit comments

Comments
 (0)