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

Make the odometer suitable as a long-term statistic #213

Open
mthmulders opened this issue Sep 23, 2023 · 5 comments
Open

Make the odometer suitable as a long-term statistic #213

mthmulders opened this issue Sep 23, 2023 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mthmulders
Copy link

Is your feature request related to a problem? Please describe.
I'd love to see a chart of the mileage of my Skoda car. I thought I would need a Statistics Graph Card for that, but it doesn't show the odometer as a source.

Describe the solution you'd like
The Expected data source not listed page suggests that the state_class of the entity may not be correct.

Describe alternatives you've considered
n/a.

Additional context
I'm quite a starter when it comes to using Home Assistant - so if my understanding of how HA or this Skoda integration works is insufficient, I'm definitely open for alternative approaches.

@dvx76
Copy link
Member

dvx76 commented Sep 24, 2023

Seems reasonable. We're currently setting state_class for 'battery_level', 'adblue_level', 'fuel_level', 'charging_time_left', 'charging_power', 'charge_rate', 'electric_range', 'combustion_range', 'combined_range', 'outside_temperature'. (see

)

Settings state_class = total for the appropriate sensors (like odometer) seems valid. Setting state class does result in long-term statistics being stored for it.

Note that if all you want is a graph with recent values I'd recommend looking into mini graph card and apex charts card, which aren't tied into the native HA statistics stuff.

E.g. minigraph with the odometer sensor (so without state_class):

image

type: custom:mini-graph-card
hours_to_show: 168
entities:
  - sensor.tmxxxxxxxx_odometer

@WebSpider WebSpider self-assigned this Sep 25, 2023
@WebSpider WebSpider added enhancement New feature or request good first issue Good for newcomers labels Sep 25, 2023
@WebSpider WebSpider removed their assignment Sep 25, 2023
@MaZa78
Copy link

MaZa78 commented Dec 13, 2023

I made my own "helper" in configuration.yml file like this

  • name: "ENYAQ KILOMETRES"
    state: >-
    {{ states('sensor.skoda_enyaq_odometer') }}
    unit_of_measurement: km
    device_class: distance
    state_class: total_increasing

I think this odometer needs state_class: total_increasing attribute. This works fine for me.

In Tesla integration the odometer contains this total_increasing

@CaptSB
Copy link

CaptSB commented Jan 8, 2024

I would like to be able to plot a statistics bar chart of the daily mileage based on the odometer reading but I can't plot the "change" in a statistics chart, it only gives the total Odometer. I suspect this is what the original poster was also referring to. If there is a way of doing this with the current code in HA then I am happy to learn how to do it.

@dvx76
Copy link
Member

dvx76 commented Jan 20, 2024

@CaptSB , as mentioned previously, take a look at the ApexCharts card.

type: custom:apexcharts-card
graph_span: 7d
series:
  - entity: sensor.tmxxxxxxxxx_odometer
    type: column
    group_by:
      func: diff
      duration: 1day

image

@MaZa78 @mthmulders , setting state_class: total_increasing for the odo sensor sounds like the right thing to do. I'll take a look when I have time but feel free to submit a PR.

@CaptSB
Copy link

CaptSB commented Jan 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants