SAIC-iSmart-API/saic-home-assistant-addon

[Python] Addon 0.3.0 crashes with marvel r (HA_discovery)

Closed this issue · 23 comments

2023-07-31 13:23:09,580 Connected to MQTT broker
2023-07-31 13:23:10,202 Registering for abnormal messages
2023-07-31 13:23:10,435 Registering for moving messages
2023-07-31 13:23:10,692 Registering for region messages
2023-07-31 13:23:10,928 Registering for engineStart messages
2023-07-31 13:23:11,157 Registering for startVehicleStatus messages
2023-07-31 13:23:11,387 Registering for offCar messages
2023-07-31 13:23:11,624 Registering for speeding messages
2023-07-31 13:23:21,655 Setting active query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 30 seconds
2023-07-31 13:23:21,656 Setting after shutdown query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 120 seconds
2023-07-31 13:23:21,656 Setting inactive query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 86400 seconds
2023-07-31 13:23:21,656 Setting refresh mode to periodic
2023-07-31 13:23:21,657 Updating vehicle status
2023-07-31 13:23:37,736 Updating charging status
2023-07-31 13:23:53,755 Refreshing vehicle status succeeded...
2023-07-31 13:23:53,757 'handle_vehicle_LSJExxxxxxxxxxxxx' task crashed with an exception
Traceback (most recent call last):
File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle
self.ha_discovery.publish_ha_discovery_messages()
File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages
self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode],
File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select
self.__publish_ha_discovery_message('select', name, payload)
File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message
final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload
File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes
'device': self.__get_device_node(),
File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node
color_name = str(self.__vin_info.color_name, encoding='utf8')
TypeError: decoding to str: need a bytes-like object, NoneType found

and than it stops ...
what next??

restart addon no result
restart HA and then start addon no result
uninstall addon and install addon filled configurastion and start addon
result is the same, stops after a few minutes with the same messages

Which Car do you have?

I'm having the same problem for a Marvel R after upgrade to 0.3.0. Application crashes after a short while and this wasn't the case before last update. I'm getting the same error as WBoerhoop

Traceback (most recent call last):
File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle
self.ha_discovery.publish_ha_discovery_messages()
File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages
self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode],
File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select
self.__publish_ha_discovery_message('select', name, payload)
File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message
final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload
File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes
'device': self.__get_device_node(),
File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node
color_name = str(self.__vin_info.color_name, encoding='utf8')
TypeError: decoding to str: need a bytes-like object, NoneType found

Please switch the log level to DEBUG to get a better log. Remove your VIN and username before posting the log.
I can't reproduce it with my MG5, seems to be an Marvel R specific problem. Any idea @nanomad ?

As a workaround you can try to set the ha discovery to false to deactivate it.

@markuswizard Can you tell me your value of saic/{username}/vehicles/{VIN}/info/color?

Found out that some cars won't send any color code. In vehicle.py there is an IF to check the color code:
image

So we run into problems with the discovery code:
image

Hi Tonno87, new log with DEBUG on

SAIC MQTT Gateway (Python)

2023-08-03 22:51:16,349 Connected to MQTT broker
2023-08-03 22:51:16,968 Registering for abnormal messages
2023-08-03 22:51:17,170 Registering for moving messages
2023-08-03 22:51:17,386 Registering for region messages
2023-08-03 22:51:17,593 Registering for engineStart messages
2023-08-03 22:51:17,806 Registering for startVehicleStatus messages
2023-08-03 22:51:18,021 Registering for offCar messages
2023-08-03 22:51:18,229 Registering for speeding messages
2023-08-03 22:51:18,234 Starting process for car LSJExxxxxxxxxxxxx
2023-08-03 22:51:18,236 Not checking for new messages since all cars have RefreshMode.OFF
2023-08-03 22:51:18,236 Waiting 60 seconds to check for new messages
2023-08-03 22:51:28,252 Setting active query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 30 seconds
2023-08-03 22:51:28,253 Setting after shutdown query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 120 seconds
2023-08-03 22:51:28,253 Setting inactive query interval in vehicle handler for VIN LSJExxxxxxxxxxxxx to 86400 seconds
2023-08-03 22:51:28,253 Setting refresh mode to periodic
2023-08-03 22:51:28,253 Refresh mode set to periodic
2023-08-03 22:51:28,254 Updating vehicle status
2023-08-03 22:51:29,003 API request returned no application data and no error message.
2023-08-03 22:51:44,348 Updating charging status
2023-08-03 22:51:45,107 API request returned no application data and no error message.
2023-08-03 22:52:00,351 Refreshing vehicle status succeeded...
2023-08-03 22:52:00,352 'handle_vehicle_LSJExxxxxxxxxxxxx' task crashed with an exception
Traceback (most recent call last):
File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle
self.ha_discovery.publish_ha_discovery_messages()
File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages
self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode],
File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select
self.__publish_ha_discovery_message('select', name, payload)
File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message
final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload
File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes
'device': self.__get_device_node(),
File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node
color_name = str(self.__vin_info.color_name, encoding='utf8')
TypeError: decoding to str: need a bytes-like object, NoneType found

not many differences

@markuswizard Can you tell me your value of saic/{username}/vehicles/{VIN}/info/color?

Found out that some cars won't send any color code. In vehicle.py there is an IF to check the color code: image

So we run into problems with the discovery code: image

Hi, yes. The Marvel dosen't seem to have any colors under the info topic. Only brand, model, year and series.

image

Okay, so i'm sure we found the problem and will fix it soon. For the moment:

image

ok thanks, for the moment i will set discovery on False

boonit commented

hi, i've got the same issue. even with HA_DISCOVERY_ENABLED on False it crashes.

2023-08-10 11:06:48,149 'handle_vehicle_XXXXXXXXXX' task crashed with an exception Traceback (most recent call last): File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle self.ha_discovery.publish_ha_discovery_messages() File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode], File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select self.__publish_ha_discovery_message('select', name, payload) File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes 'device': self.__get_device_node(), File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node color_name = str(self.__vin_info.color_name, encoding='utf8') TypeError: decoding to str: need a bytes-like object, NoneType found

That's right, I also had this problem after I set the discovery to False. Now the addon is off and auto boot is off.
The error message is identical.

Actually for me too. The HA_DISCOVERY_ENABLED = false didn't do the trick and I still got the same error message.

oh, I'm so curious when the new version/fix will be available....

hi, i've also got the same issue with HA_DISCOVERY_ENABLED set to False it crashes.
2023-09-13 07:25:14,604 Connected to MQTT broker 2023-09-13 07:25:14,616 No vehicle handler found for VIN xxxxxxxxxxxxxxxxx 2023-09-13 07:25:14,617 Command for unknown vin xxxxxxxxxxxxxxxxx received 2023-09-13 07:25:14,654 No vehicle handler found for VIN xxxxxxxxxxxxxxxxx 2023-09-13 07:25:14,655 Command for unknown vin xxxxxxxxxxxxxxxxx received 2023-09-13 07:25:15,325 Registering for abnormal messages 2023-09-13 07:25:15,573 Registering for moving messages 2023-09-13 07:25:15,819 Registering for region messages 2023-09-13 07:25:16,073 Registering for engineStart messages 2023-09-13 07:25:16,326 Registering for startVehicleStatus messages 2023-09-13 07:25:16,574 Registering for offCar messages 2023-09-13 07:25:16,843 Registering for speeding messages 2023-09-13 07:25:16,855 Starting process for car xxxxxxxxxxxxxxxxx 2023-09-13 07:25:16,869 Not checking for new messages since all cars have RefreshMode.OFF 2023-09-13 07:25:16,869 Waiting 60 seconds to check for new messages 2023-09-13 07:25:26,887 Setting active query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 30 seconds 2023-09-13 07:25:26,887 Setting after shutdown query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 120 seconds 2023-09-13 07:25:26,888 Setting inactive query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 86400 seconds 2023-09-13 07:25:26,888 Setting refresh mode to periodic 2023-09-13 07:25:26,888 Refresh mode set to periodic 2023-09-13 07:25:26,889 Updating vehicle status 2023-09-13 07:25:27,693 API request returned no application data and no error message. 2023-09-13 07:25:42,969 Updating charging status 2023-09-13 07:25:43,765 API request returned no application data and no error message. 2023-09-13 07:25:59,365 Refreshing vehicle status succeeded... 2023-09-13 07:25:59,367 'handle_vehicle_xxxxxxxxxxxxxxxxx' task crashed with an exception Traceback (most recent call last): File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle self.ha_discovery.publish_ha_discovery_messages() File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode], File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select self.__publish_ha_discovery_message('select', name, payload) File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes 'device': self.__get_device_node(), File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node color_name = str(self.__vin_info.color_name, encoding='utf8') TypeError: decoding to str: need a bytes-like object, NoneType found

I'm having the same problem.

2023-09-22 11:00:34,088 Connected to MQTT broker
2023-09-22 11:00:34,648 Registering for abnormal messages
2023-09-22 11:00:34,837 Registering for moving messages
2023-09-22 11:00:35,023 Registering for region messages
2023-09-22 11:00:35,215 Registering for engineStart messages
2023-09-22 11:00:35,398 Registering for startVehicleStatus messages
2023-09-22 11:00:35,583 Registering for offCar messages
2023-09-22 11:00:35,777 Registering for speeding messages
2023-09-22 11:00:35,786 Starting process for car xxxxxxxxxxxxxxxxx
2023-09-22 11:00:35,794 Not checking for new messages since all cars have RefreshMode.OFF
2023-09-22 11:00:35,794 Waiting 60 seconds to check for new messages
2023-09-22 11:00:45,809 Setting active query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 30 seconds
2023-09-22 11:00:45,809 Setting after shutdown query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 120 seconds
2023-09-22 11:00:45,810 Setting inactive query interval in vehicle handler for VIN xxxxxxxxxxxxxxxxx to 86400 seconds
2023-09-22 11:00:45,810 Setting refresh mode to periodic
2023-09-22 11:00:45,810 Refresh mode set to periodic
2023-09-22 11:00:45,810 Updating vehicle status
2023-09-22 11:00:54,548 API request returned no application data and no error message.
2023-09-22 11:01:09,766 Updating charging status
2023-09-22 11:01:10,481 API request returned no application data and no error message.
2023-09-22 11:01:26,059 Refreshing vehicle status succeeded...
2023-09-22 11:01:26,061 'handle_vehicle_xxxxxxxxxxxxxxxxx' task crashed with an exception
Traceback (most recent call last):
File "/usr/src/app/./mqtt_gateway.py", line 110, in handle_vehicle
self.ha_discovery.publish_ha_discovery_messages()
File "/usr/src/app/home_assistant_discovery.py", line 18, in publish_ha_discovery_messages
self.__publish_select(mqtt_topics.REFRESH_MODE, 'Gateway refresh mode', [m.value for m in RefreshMode],
File "/usr/src/app/home_assistant_discovery.py", line 308, in __publish_select
self.__publish_ha_discovery_message('select', name, payload)
File "/usr/src/app/home_assistant_discovery.py", line 356, in __publish_ha_discovery_message
final_payload = self.__get_common_attributes(unique_id, sensor_name) | payload
File "/usr/src/app/home_assistant_discovery.py", line 313, in __get_common_attributes
'device': self.__get_device_node(),
File "/usr/src/app/home_assistant_discovery.py", line 326, in __get_device_node
color_name = str(self.__vin_info.color_name, encoding='utf8')
TypeError: decoding to str: need a bytes-like object, NoneType found

Please check it out with the new version 0.4.0

Thanks , as far i can see version 0.4.0 is working, start building a page suitable for screen and iphone already.
What i miss is the setting where i can change the loading limit "socTarget/set | [40,50,60,70,80,90,100] "
How and where can i make these setting??

But thumbs up

Please check it out with the new version 0.4.0

Works great with my Marvel R!

Thanks , as far i can see version 0.4.0 is working, start building a page suitable for screen and iphone already. What i miss is the setting where i can change the loading limit "socTarget/set | [40,50,60,70,80,90,100] " How and where can i make these setting??

But thumbs up

This is a MQTT topic:

saic/xxxxxxxx@gmail.com/vehicles/LSJExxxxxxxxxxx/drivetrain/socTarget is 100, but you can set it to 80 with:

saic/xxxxxxxx@gmail.com/vehicles/LSJExxxxxxxxxxx/drivetrain/socTarget/set 80

Link

Fixed with 0.4.0