Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensors "Vehicle Info" and "Tyres" unavailable in 3.0.0 Beta 2 #117

Closed
ismarslomic opened this issue Feb 2, 2024 · 8 comments
Closed

Sensors "Vehicle Info" and "Tyres" unavailable in 3.0.0 Beta 2 #117

ismarslomic opened this issue Feb 2, 2024 · 8 comments

Comments

@ismarslomic
Copy link
Collaborator

After upgrading to 3.0.0 Beta 2, Im missing Vehicle Info and Tyres sensors. I see following 2 errors in logs:

  1. Error adding entities for domain sensor with platform jlrincontrol
  2. Error while setting up jlrincontrol platform for sensor

Stack trace below is identical for both errors.

Diagnostics: config_entry-jlrincontrol-84eb59d8570d73fb8a3c684b79454890.json.txt

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:507
Integration: Sensor (documentation, issues)
First occurred: 20:12:11 (1 occurrences)
Last logged: 20:12:11

Error adding entities for domain sensor with platform jlrincontrol
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 93, in _get_from_to_ratio
    return unit_conversion[from_unit], unit_conversion[to_unit]
                                       ~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in __async_calculate_state
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/jlrincontrol/sensor.py", line 219, in extra_state_attributes
    unit_conversion.PressureConverter.convert(
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 73, in convert
    return cls.converter_factory(from_unit, to_unit)(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 83, in converter_factory
    from_ratio, to_ratio = cls._get_from_to_ratio(from_unit, to_unit)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 95, in _get_from_to_ratio
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: None is not a recognized pressure unit.

@ismarslomic
Copy link
Collaborator Author

To be more specific:

  • The Tyres sensor is created, but has state Unavailable
  • The Vehicle Info sensor is not created at all

@msp1974
Copy link
Owner

msp1974 commented Feb 2, 2024

In the config options, can you set a pressure unit option and see if this resolves it. Need to look at why it is None and not defaulted.

@ismarslomic
Copy link
Collaborator Author

Changing the Pressure unit override from bar to Default indeed resolved creation of the "Tyres" and "Vehicle Info" sensors.

@ismarslomic
Copy link
Collaborator Author

ismarslomic commented Feb 2, 2024

Interesting note: in HA UI the pressure unit radio button bar was selected, but in diagnostic file it was set to None. When I selected Default in UI, then Pa is shown in diagnostic file. And switching back to bar updated diagnostic file to bar.

So yeah, it seems to be some issue with default value

msp1974 added a commit that referenced this issue Feb 2, 2024
@msp1974
Copy link
Owner

msp1974 commented Feb 2, 2024

Setting default value will be in beta3

@ismarslomic
Copy link
Collaborator Author

I tried to verify the fix for default pressure from dev branch, by deleting the integration and reinstalling it. No error is displayed anymore and both sensors (Vehicle Info and Tyres) are created. But the Configuration UI has wrong radio button selected. bar is selected in UI, while diagnostic file says Pa (which is default value).

      "user_preferences": {
        "__type": "<class 'custom_components.jlrincontrol.coordinator.UserPreferenceUnits'>",
        "repr": "UserPreferenceUnits(distance=<UnitOfLength.KILOMETERS: 'km'>, fuel=<UnitOfVolume.LITERS: 'L'>, temp=<UnitOfTemperature.CELSIUS: '\u00b0C'>, pressure=<UnitOfPressure.PA: 'Pa'>, energy_regenerated=<UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>, energy_consumed=<UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>)"
      }
image

@ismarslomic
Copy link
Collaborator Author

ismarslomic commented Feb 2, 2024

@ismarslomic
Copy link
Collaborator Author

Verified that the Default radio button is correctly selected in Pressure Unit Override configuration. Closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants