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

Remove "in KM" from "Next inspection" and "Oil service" sensors #496

Open
cholek3 opened this issue Dec 29, 2024 · 5 comments
Open

Remove "in KM" from "Next inspection" and "Oil service" sensors #496

cholek3 opened this issue Dec 29, 2024 · 5 comments

Comments

@cholek3
Copy link

cholek3 commented Dec 29, 2024

Hi,

First of all, thank you for your work on this add-on.

Do API requests also provide imperial measurements for sensors? I have my Kamiq set for UK market, so all measurements are in miles, but add-on provides sensor.skoda_kamiq_range, sensor.skoda_kamiq_next_inspection_in_km, sensor.skoda_kamiq_oil_service_in_km and sensor.skoda_kamiq_mileage are in kilometres. If so, could we have those sensors providing measurements in miles, please?

I am having difficulties converting kilometres into miles, as I am getting different factors:
My current measurements from addon and what it shows in car:
range: 249m (car) / 402km (addon) = 1.614457831325301
mileage: 117m (car)/117.2m (trip mileage) /188km (addon) = 1.606837606837607/1.604095563139932
127.6m / 205.4km = 1.609717868338558

@cholek3
Copy link
Author

cholek3 commented Dec 29, 2024

Well, I guess I will answer myself to this feature request. Just downloaded diagnostics file, and I see API only reports those values in kilometres, so I had to create template sensor:

- platform: template
  sensors:
    skoda_kamiq_range_in_miles:
      friendly_name: "Skoda Kamiq Range in miles"
      unit_of_measurement: 'm'
      device_class: distance
      icon_template: mdi:gas-station
      value_template: "{{ ((states('sensor.skoda_kamiq_range') | float(0) / 1.609717868338558 | float(0) )) | round(0) }}"

    skoda_kamiq_next_inspection_in_miles:
      friendly_name: "Skoda Kamiq service in miles"
      unit_of_measurement: 'm'
      device_class: distance
      icon_template: mdi:car-wrench
      value_template: "{{ ((states('sensor.skoda_kamiq_next_inspection_in_km') | float(0) / 1.609717868338558 | float(0) )) | round(0) }}"

    skoda_kamiq_mileage_in_miles:
      friendly_name: "Skoda Kamiq mileage in miles"
      unit_of_measurement: 'm'
      device_class: distance
      icon_template: mdi:counter
      value_template: "{{ ((states('sensor.skoda_kamiq_mileage') | float(0) / 1.609717868338558 | float(0) )) | round(0) }}"

    skoda_kamiq_oil_service_in_miles:
      friendly_name: "Skoda Kamiq oil service in miles"
      unit_of_measurement: 'm'
      device_class: distance
      icon_template: mdi:oil
      value_template: "{{ ((states('sensor.skoda_kamiq_oil_service_in_km') | float(0) / 1.609717868338558 | float(0) )) | round(0) }}"

Can somebody correct me if I am wrong.

@dvx76
Copy link
Member

dvx76 commented Dec 30, 2024

The API definitely only returns metric units from what I've seen but I thought HA would be able to convert to your configured unit system (Settings -> General -> Unit System) automatically as long as the entities have correct unit_of_measurement and device_class set. Do you have that set to US customary? If not, what happens if you change it?

image

@cholek3
Copy link
Author

cholek3 commented Dec 30, 2024

Thanks @dvx76, I don't think this solution would not work for me as it would change a lot more entities unit of measurements.
BUUUUT... I totally forgot we can change the unit of measurements for individual entities. Please see below.

Screenshot 2024-12-30 092907

The only problem (well, not really a problem, but visual abnormality) is 2 of the above sensors (sensor.XXX_next_inspection_in_km and sensor.XXX_oil_service_in_km) which provide kilometres (KM) in their names, which looks a little bit weird by default, when you have Miles set as a unit (like I said, not really a problem, as you can change the name of the entity easily).

Screenshot 2024-12-30 094728

I guess that could be changed from:
"Next Inspection in KM" to "Next Inspection" (sensor.XXX_next_inspection_in_km to sensor.XXX_next_inspection_distance)
Since Next Inspection sensor (and name) already exists (sensor.XXX_next_inspection) in Days as a unit of measurements, this one would also have to be changed (for example sensor.XXX_next_inspection to sensor.XXX_next_inspection_time)

Similar with Oil service

"Oil service in KM" to "Oil service" (sensor.XXX_oil_service_in_km to sensor.XXX_oil_service_distance)
Since Oil service sensor (and name) already exists (sensor.XXX_oil_service) in Days as a unit of measurements, this one would also have to be changed (for example sensor.XXX_oil_service to sensor.XXX_oil_service_time)

@cholek3 cholek3 changed the title Add imperial measurements for sensors Remove "in KM" from "Next inspection" and "Oil service" sensors Dec 30, 2024
@dvx76
Copy link
Member

dvx76 commented Dec 31, 2024

@WebSpider it makes sense to me that the entity names do not include the unit since it could end up being converted to a different unit + the unit_of_measurement already provides this info. I guess possibly the entity names were just based on the field names of the API responses.

Drawback is that this will only take effect after re-installing the integration (or probably we need to look into migration flows...)

@WebSpider
Copy link
Contributor

WebSpider commented Dec 31, 2024

I agree 100% on this. Have been scouting code for migrations in device registry and entity registry yesterday, but sleep won 😆

Also see #502 that introduces config schema's so we can do this in a seamless manner

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

3 participants