DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 32 forks source link

Fuel level sensor not available #273

Open desosav opened 4 months ago

desosav commented 4 months ago

It stopped working a few days ago.

> 2024-06-28 08:45:12.509 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity None for domain sensor with platform toyota
> Traceback (most recent call last):
>   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
>     await coro
>   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 831, in _async_add_entity
>     unit_of_measurement=entity.unit_of_measurement,
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 512, in unit_of_measurement
>     if self._is_valid_suggested_unit(suggested_unit_of_measurement):
>        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 383, in _is_valid_suggested_unit
>     raise ValueError(
> ValueError: Entity <class 'custom_components.toyota.sensor.ToyotaSensor'> suggest an incorrect unit of measurement: %.
Stemmi90 commented 4 months ago

Same kind of issue when updated to 2024.7.0 so restored back to 2024.6.4

Anangaranga commented 4 months ago

Same here...🫤

desosav commented 4 months ago

this is a workaround for anyone interested in updating HA core to the latest available release, while keeping the fuel level sensor enabled. I have updated line 230 in /homeassistant/custom_components/toyota/sensor.py file (replace PERCENTAGE with None) Now the fuel level is working but obviously no unit of measurement is assigned to the sensor. I am not a programmer, so this is just a workaround until this is resolved by the ha_toyota integration devs.

vehicle._vehicle_info.extended_capabilities.fuel_level_available, FUEL_LEVEL_ENTITY_DESCRIPTION, ToyotaSensor, None,

nisu66 commented 4 months ago

same error from update 2024.7

joost11111 commented 4 months ago

Same error. No more Fuel level percentage. In the My Toyota App it is still available.

mario-pranjic commented 3 months ago

Same here. I upgraded directly from 2024.6.x (latest) to 2024.7.3 and fuel level sensor is off. MyToyota app shows that information properly.

mario-pranjic commented 3 months ago

this is a workaround for anyone interested in updating HA core to the latest available release, while keeping the fuel level sensor enabled. I have updated line 230 in /homeassistant/custom_components/toyota/sensor.py file (replace PERCENTAGE with None) Now the fuel level is working but obviously no unit of measurement is assigned to the sensor. I am not a programmer, so this is just a workaround until this is resolved by the ha_toyota integration devs.

vehicle._vehicle_info.extended_capabilities.fuel_level_available, FUEL_LEVEL_ENTITY_DESCRIPTION, ToyotaSensor, None,

I can confim this workaround helps. Restart of HA is required to apply changes.

joost11111 commented 3 months ago

this is a workaround for anyone interested in updating HA core to the latest available release, while keeping the fuel level sensor enabled. I have updated line 230 in /homeassistant/custom_components/toyota/sensor.py file (replace PERCENTAGE with None) Now the fuel level is working but obviously no unit of measurement is assigned to the sensor. I am not a programmer, so this is just a workaround until this is resolved by the ha_toyota integration devs. vehicle._vehicle_info.extended_capabilities.fuel_level_available, FUEL_LEVEL_ENTITY_DESCRIPTION, ToyotaSensor, None,

I can confim this workaround helps. Restart of HA is required to apply changes.

I did the workaround and it works but without the percentage and just only a value. Thanks for now and hope there will be an update to resolve this. Capture

mario-pranjic commented 3 months ago

Any chance this getting resolved without manual workaround in sensor.py file?

CM000n commented 3 months ago

Any chance this getting resolved without manual workaround in sensor.py file?

Feel free to open a Pull request for it.

It looks like Home Assistant has changed the restrictions for the homeassistant.const entries in one of its last versions, so that the PERCENTAGE entries can no longer be used freely.

Another option would be to change the device_class to a valid SensorDeviceClass for PERCENTAGE measuring units. For example, SensorDeviceClass.BATTERY. But as a result, the fuel level in Homeassistant would be displayed as a battery.

A better device_class would actually be SensorDeviceClass.VOLUME_STORAGE. However, only measurement units such as mL, L, are permitted for these.

nisu66 commented 3 months ago

this is a workaround for anyone interested in updating HA core to the latest available release, while keeping the fuel level sensor enabled. I have updated line 230 in /homeassistant/custom_components/toyota/sensor.py file (replace PERCENTAGE with None) Now the fuel level is working but obviously no unit of measurement is assigned to the sensor. I am not a programmer, so this is just a workaround until this is resolved by the ha_toyota integration devs. vehicle._vehicle_info.extended_capabilities.fuel_level_available, FUEL_LEVEL_ENTITY_DESCRIPTION, ToyotaSensor, None,

I can confim this workaround helps. Restart of HA is required to apply changes.

I did the workaround and it works but without the percentage and just only a value. Thanks for now and hope there will be an update to resolve this. Capture

to get around the % problem, I used a solution, not beautiful but functional

nisu66 commented 3 months ago

to get around the % problem, I used a solution, not beautiful but functional

sensor:

tommeijering commented 3 months ago

Other solution to add % sign:

See https://community.home-assistant.io/t/adding-units-of-measurement-in-2021-12/384972/10

Edit configuration.yaml below line homeassistant: add line customize:

homeassistant:

customize:

nameoffyoursensor:

unit_of_measurement: "%"

**nameoffyoursensor** something like sensor.xxx_fuel_level

Don't forget : signs

Check and reload configuration.yaml

ajain-93 commented 2 months ago

I got it working by commenting out https://github.com/DurgNomis-drol/ha_toyota/blob/master/custom_components/toyota/sensor.py#L321, i.e. removing the suggested_unit_of_measurement attributes.

@CM000n I've created a pull request for this. But I have to admit: I have looked around at the documentation, but am not really able to understand the difference between the native_unit_of_measurement and suggested_unit_of_measurement attributes.

ajain-93 commented 2 months ago

Should be fixed now in 2.0.5 by #292.