nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.33k stars 121 forks source link

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

Closed emontnemery closed 2 years ago

emontnemery commented 2 years ago

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

This can be solved as suggested here: https://github.com/blakeblackshear/frigate-hass-integration/pull/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))
nielsfaber commented 2 years ago

Thanks for the heads-up.

I think this change has no impact on alarmo since are only 2 cases where mqtt.async_publish is called, both are async functions.

https://github.com/nielsfaber/alarmo/blob/3e467c0cc188a107a7a13098f21ab63655fba203/custom_components/alarmo/mqtt.py#L82

https://github.com/nielsfaber/alarmo/blob/3e467c0cc188a107a7a13098f21ab63655fba203/custom_components/alarmo/mqtt.py#L152

I will update my Alarmo development environment to latest dev release to double check this.

nielsfaber commented 2 years ago

I think this change has no impact on alarmo since are only 2 cases where mqtt.async_publish is called, both are async functions.

I don't know why I made this statement earlier, but they were not async routines so I made changes for this https://github.com/nielsfaber/alarmo/commit/45054375a30e7bba93811e3cb8a54118172d5b9a

I will make sure to release it soon, thanks for the heads-up.