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 #42

Open
emontnemery opened this issue Oct 28, 2021 · 3 comments
Open

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

emontnemery opened this issue Oct 28, 2021 · 3 comments

Comments

@emontnemery
Copy link

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

This is a breaking change, and the custom component will stop working if not adapted.
This can be solved as suggested here: blakeblackshear/frigate-hass-integration#166

@pixeldoc2000
Copy link

pixeldoc2000 commented Dec 12, 2021

HA 2021.12 Log Messatge:

2021-12-12 22:00:00 ERROR (MainThread) [homeassistant.components.automation.zigbee_map_aktualisieren] While executing automation automation.zigbee_map_aktualisieren
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 508, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1259, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 363, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/config/custom_components/zigbee2mqtt_networkmap/__init__.py", line 91, in update_service
    mqtt.async_publish(topic+'/bridge/networkmap/routes', 'graphviz')
TypeError: async_publish() missing 1 required positional argument: 'payload'

Looks like the Code in Question is:

    # Service to publish a message on MQTT.
    async def update_service(call):
        """Service to send a message."""
        tmpVar.received_update = False
        tmpVar.update_data = None
        tmpVar.last_update = None
        mqtt.async_publish(topic+'/bridge/networkmap/routes', 'graphviz')          # <------------

@SlavikS-PL
Copy link

change this line to:
await mqtt.async_publish(hass, topic+'/bridge/networkmap/routes', 'graphviz')
and restart HASS

@pixeldoc2000
Copy link

pixeldoc2000 commented Dec 17, 2021

@SlavikS-PL
Awesome, it works again, THX!
I've messed around with it code myself, trying to fix it myself without any luck.

Maybe this must be changed too:
await mqtt.async_subscribe(topic+'/bridge/networkmap/graphviz', message_received)
to:
await mqtt.async_subscribe(hass, topic+'/bridge/networkmap/graphviz', message_received)
?

EDIT: There is already a pull request with the fix: #44

MeanderingWanderer added a commit to MeanderingWanderer/zigbee2mqtt.io that referenced this issue Jun 8, 2022
Why should this be removed?
integration broken for HA >= 2021.12

Problem detailed here
rgruebel/ha_zigbee2mqtt_networkmap#42
and here,  hacs/integration#2517
Koenkk pushed a commit to Koenkk/zigbee2mqtt.io that referenced this issue Jun 9, 2022
Why should this be removed?
integration broken for HA >= 2021.12

Problem detailed here
rgruebel/ha_zigbee2mqtt_networkmap#42
and here,  hacs/integration#2517
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

No branches or pull requests

3 participants