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 Home Assistant 2021.12 #106

Closed
emontnemery opened this issue Oct 28, 2021 · 2 comments
Closed

Adapt to changed mqtt.async_publish in Home Assistant 2021.12 #106

emontnemery opened this issue Oct 28, 2021 · 2 comments
Labels
fixed Upcoming fix/feature already on dev suspended Suspended: either unknown resolution or need further inspection

Comments

@emontnemery
Copy link
Contributor

mqtt.async_publish is a couroutine in HA core 2021.12: home-assistant/core#58441

This can be solved as suggested here: blakeblackshear/frigate-hass-integration#166

If mqtt.async_publish is called from a non-coroutine, use hass.async_create_task if it's not practical to convert the caller to a coroutine:

hass.async_create_task(mqtt.async_publish(hass, topic, payload))
@krahabb
Copy link
Owner

krahabb commented Nov 1, 2021

Hello @emontnemery ,
thank you very much for hinting at this.
While fixing my code I've also found the '@bind_hass' decorator was removed to both the 'sync' and 'async' publish functions while it reamains on other signatures like async_subscribe for instance.
Is this just a temporary inconsistency ? or maybe there's something bigger behind my overall weak knowledge of the core api?
I'm asking since I would like to implement a stable (the most) update to my code
Thank you

@krahabb krahabb added suspended Suspended: either unknown resolution or need further inspection fixed Upcoming fix/feature already on dev labels Nov 1, 2021
@krahabb krahabb closed this as completed Nov 22, 2021
@emontnemery
Copy link
Contributor Author

emontnemery commented Nov 22, 2021

We don't promote the @bind_hass decorator anymore as calling a function via the hass objects prevents most linters from doing their job. The change to mqtt.async_publish was anyway a breaking change so I removed the @bind_hass from the changed functions.

@krahabb krahabb mentioned this issue Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Upcoming fix/feature already on dev suspended Suspended: either unknown resolution or need further inspection
Projects
None yet
Development

No branches or pull requests

2 participants