SAIC-iSmart-API / saic-python-mqtt-gateway

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with version v0.6.1-rc2

ifilgud opened this issue · comments

The changed line 61 in discovery.py makes python crash with this error:

2024-04-17 10:03:52,518 [ ERROR ] 'handle_vehicle_VINXXX' task crashed with an exception - main
Traceback (most recent call last):
File "/home/pi/saic-python-mqtt-gateway/mqtt_gateway.py", line 129, in handle_vehicle
self.ha_discovery.publish_ha_discovery_messages()
File "/home/pi/saic-python-mqtt-gateway/integrations/home_assistant/discovery.py", line 100, in publish_ha_discovery_messages
self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode],
File "/home/pi/saic-python-mqtt-gateway/integrations/home_assistant/discovery.py", line 602, in __publish_select
return self.__publish_ha_discovery_message('select', name, payload, custom_availability)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/saic-python-mqtt-gateway/integrations/home_assistant/discovery.py", line 666, in __publish_ha_discovery_message
final_payload = self.__get_common_attributes(unique_id, sensor_name, custom_availability) | payload
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/saic-python-mqtt-gateway/integrations/home_assistant/discovery.py", line 617, in __get_common_attributes
common_attributes.update(custom_availability.to_dict())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/saic-python-mqtt-gateway/integrations/home_assistant/discovery.py", line 61, in to_dict
'availability': [r.to_dict() for r in set(self.__rules)],
^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'HaCustomAvailabilityEntry'
2024-04-17 10:03:52,669 [ ERROR ] Task was destroyed but it is pending!
task: <Task pending name='Task-1' coro=<Client._resend_qos_messages() running at /srv/saic-python-mqtt-gateway/lib/python3.12/site-packages/gmqtt/client.py:176>> - asyncio
sys:1: RuntimeWarning: coroutine 'Client._resend_qos_messages' was never awaited

The added set(...) triggers the error.
I'm using python 3.12 and the venv pip packages are updated.

What could be the issue? Reverting the change in that line makes it works fine

@ifilgud Are you sure you are running RC2?

The hash function has been implemented in commit 215cca9

I just did a git pull on my cloned repo, which is on main branch.
I tagged this as RC2 because it was the latest that seemed to be in my repo, but it's weird.
I checked the commits that came with the pull command and it didn't make sense, because I had never changed to any other branch than main and I had only a couple of commits from RC2, but not everything.

I've tested a new clean version of main branch and it works fine, so it looks like a werid mixture of tags made by git in my local. Probably a full RC2 branch would also work fine, sorry.

I think we can close this then

Cool, thanks :)