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

MIT License
66 stars 20 forks source link

Crash with version v0.6.1-rc2 #223

Closed ifilgud closed 4 months ago

ifilgud commented 4 months ago

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

nanomad commented 4 months ago

@ifilgud Are you sure you are running RC2?

The hash function has been implemented in commit https://github.com/SAIC-iSmart-API/saic-python-mqtt-gateway/commit/215cca936e2611c0d4c4310e77a064d6651711b0

ifilgud commented 4 months ago

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

nanomad commented 4 months ago

Cool, thanks :)