Skip to content

Conversation

@qudiqudi
Copy link
Contributor

@qudiqudi qudiqudi commented Dec 7, 2025

The time_to_full_charge sensor was being published with device_class 'duration' but without a unit_of_measurement, causing Home Assistant to log an error.

This adds 'h' (hours) as the unit_of_measurement to comply with Home Assistant's requirements for duration sensors. The Tesla API returns time_to_full_charge in hours as a decimal value.

Fixes Home Assistant error:
Entity is using native unit of measurement 'None' which is not a valid unit for the device class ('duration')

The time_to_full_charge sensor was being published with device_class
'duration' but without a unit_of_measurement, causing Home Assistant
to log an error.

This adds 'h' (hours) as the unit_of_measurement to comply with Home
Assistant's requirements for duration sensors. The Tesla API returns
time_to_full_charge in hours as a decimal value.

Fixes Home Assistant error:
Entity is using native unit of measurement 'None' which is not a
valid unit for the device class ('duration')
@qudiqudi
Copy link
Contributor Author

qudiqudi commented Dec 7, 2025

Problem

The time_to_full_charge sensor was being published with device_class: "duration" but without a unit_of_measurement, causing Home Assistant to log the following error:

Entity sensor.xxx_time_to_full_charge is using native unit of measurement 'None'
which is not a valid unit for the device class ('duration');
expected one of ['h', 'μs', 's', 'min', 'd', 'ms']

Solution

Added unit_of_measurement: "h" to the MQTT auto-discovery configuration for the time_to_full_charge sensor.

Rationale

  • Tesla API returns time_to_full_charge in hours (as a decimal value)
  • TeslaLogger passes this value through without conversion
  • Home Assistant requires a valid unit for sensors with device_class: "duration"

Testing

  • Verified the fix matches the pattern of other duration sensors in the codebase
  • Confirmed the Tesla API documentation specifies hours as the unit

Files Changed

  • TeslaLogger/MQTTAutoDiscovery.cs - Added unit configuration on line 107

@bassmaster187
Copy link
Owner

@Adminius could you please test it?

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

Successfully merging this pull request may close these issues.

2 participants