msp1974 / homeassistant-jlrincontrol

An integration for JLR InControl to Home Assistant
MIT License
65 stars 11 forks source link

climate_temp_data: 'NoneType' object has no attribute 'get' in 3.0.0 Beta 2 #116

Closed ismarslomic closed 8 months ago

ismarslomic commented 8 months ago

Just upgraded to 3.0.0 Beta 2 and the integration fails at initiation/setup with following error. Installed on HA2024.1.6. I got Jaguar iPace Y21.

Diagnostic file: #117

This error originated from a custom integration.

Logger: custom_components.jlrincontrol.coordinator
Source: helpers/update_coordinator.py:300
Integration: Jaguar Landrover InControl (documentation)
First occurred: 19:04:50 (6 occurrences)
Last logged: 19:07:33

Unexpected error fetching jlrincontrol (jlrincontrol-xxx@xxx) data: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/jlrincontrol/coordinator.py", line 517, in async_update_data
    await self.async_get_vehicle_status(vehicle)
  File "/config/custom_components/jlrincontrol/coordinator.py", line 404, in async_get_vehicle_status
    temp = int(float(climate_temp_data.get("value", "42"))) / 2
                     ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
ismarslomic commented 8 months ago

As workaround i hardcoded temp=21 and successfully managed to initialise the integration. I guess we should put and if-statement to check whether climate_temp_data is None before calling the get() function. Leaving this to you @msp1974 , but let me know if you need my assistance.

msp1974 commented 8 months ago

Yes, seems EVs do not have this. Added an exception catch to prevent this error. Similar principle to checking if climate_temp_data is None. Will be in beta3

ismarslomic commented 8 months ago

Fix verified from dev. Closing the issue!