spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

MqttItem.publish does not work anymore with 23.09.1 #421

Closed dobernhardt closed 9 months ago

dobernhardt commented 9 months ago

After the update to 23.09.1 I see errors in my rules related to MqttItem.publish.

  File "/habapp/config/rules/tasmota.py", line 44, in _turnedOnline
    MqttItem.get_create_item(f"tasmota/{self._id}/cmnd/STATUS").publish("5")
  File "/usr/local/lib/python3.11/site-packages/HABApp/mqtt/items/mqtt_item.py", line 45, in publish
    return publish(self.name, payload, qos=qos, retain=retain)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/HABApp/mqtt/connection/publish.py", line 90, in publish
    run_func_from_async(topic, payload, qos, retain)
  File "/usr/local/lib/python3.11/site-packages/HABApp/core/asyncio.py", line 86, in run_func_from_async
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable

When looking into the code it looks like that in the publish method of the mqtt connection the topic (which is a str) is passes as the first argument into run_func_from_async which expects a callable.

It probably is just missing the async_publish as a first argument. I will give it a try tomorrow and can provide a PR.

alfista2600 commented 9 months ago

I have one low-importance rule that publishes to MQTT that seems to not be working. I just left it in a 1.1.2 docker container for the time being after troubleshooting for a bit. I don't think I saw any errors, though.

dobernhardt commented 9 months ago

It really was just simply the missing callable argument. PR created https://github.com/spacemanspiff2007/HABApp/pull/422

spacemanspiff2007 commented 9 months ago

Thank you for reporting, is fixed with the new release