Hass-Custom-Alarm
Hass-Custom-Alarm copied to clipboard
Adapt to changed mqtt.async_publish in HA core 2021.12
mqtt.async_publish is a couroutine in HA core 2021.12: https://github.com/home-assistant/core/pull/58441
In addition to the change in this PR, either a hacs.json is needed, with minimum HA version set to 2021.12 or something like this would work to keep compatibility with old versions of Home Assistant Core:
hass.async_add_job(async_publish, hass, topic, payload)
Hi @emontnemery,
Thanks for your PR and sorry for the long delay. When I apply your PR to my system (HA 0.111.1), it works BUT I get this error in logs:
TypeError: object NoneType can't be used in 'await' expression
It works without errors if I replace the async_publish
with
self._hass.async_add_job(self._mqtt.async_publish, self._hass, self._state_topic, state_name, self._qos, True)
but I don't quite get why the await
bit causes errors and how to keep compatibility with old versions of HA - could you elaborate?
I don't use HACS.