Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to changed mqtt.async_publish in HA core 2021.12 #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emontnemery
Copy link

mqtt.async_publish is a couroutine in HA core 2021.12: home-assistant/core#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)

@akasma74
Copy link
Owner

akasma74 commented Apr 29, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants