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

Fuel level sensor not available #273

Closed
desosav opened this issue Jun 28, 2024 · 16 comments
Closed

Fuel level sensor not available #273

desosav opened this issue Jun 28, 2024 · 16 comments
Labels

Comments

@desosav
Copy link

desosav commented Jun 28, 2024

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
Copy link

Stemmi90 commented Jul 4, 2024

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

@Anangaranga
Copy link

Same here...🫤

@desosav
Copy link
Author

desosav commented Jul 4, 2024

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
Copy link

nisu66 commented Jul 7, 2024

same error from update 2024.7

@joost11111
Copy link

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

@mario-pranjic
Copy link

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
Copy link

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
Copy link

joost11111 commented Jul 27, 2024

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
Copy link

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

@CM000n
Copy link
Collaborator

CM000n commented Aug 15, 2024

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
Copy link

nisu66 commented Aug 15, 2024

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
Copy link

nisu66 commented Aug 15, 2024

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

sensor:

  • platform: template
    sensors:
    percentuale_valore:
    friendly_name: "Percentuale Valore"
    unit_of_measurement: '%'
    value_template: >
    {{ (states('sensor.nameyuorsensor)|float)|round(2) }}

@tommeijering
Copy link

tommeijering commented Aug 15, 2024

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
Copy link
Contributor

ajain-93 commented Aug 21, 2024

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 added a commit to ajain-93/ha_toyota that referenced this issue Aug 21, 2024
CM000n added a commit that referenced this issue Aug 23, 2024
* Remove `suggested_unit_of_measurement` attributes

Solves #273 and makes it work in 2024.7

* Revert "Remove `suggested_unit_of_measurement` attributes"

This reverts commit e7003f4.

* add explicit suggested_unit_of_measurement

* set explicit `native_unit` and `suggested_unit`

* bump version to 2.0.5

---------

Co-authored-by: Simon Hörrle <7945681+CM000n@users.noreply.github.com>
@ajain-93
Copy link
Contributor

Should be fixed now in 2.0.5 by #292.

@CM000n
Copy link
Collaborator

CM000n commented Mar 3, 2025

Closed due to discontinuation of the project. See: #346

@CM000n CM000n closed this as completed Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants