Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
452 stars 89 forks source link

feat: Add Sensor for todays daily stats #954

Closed MichaelMKKelly closed 4 weeks ago

MichaelMKKelly commented 4 weeks ago

Adds a sensor for "Todays Daily Driving Stats" which allows for a fixed sensor to access daily stats instead of the moving target of the date labeled attribute in the main daily driving stats sensor.

This makes it easier to pull the current days stats and have it reset at midnight as it will switch to default 0 values. instead of using template workarounds such as those discussed in #870 or other helper implementations people may be using.

the entity gets added along with the normal Daily Driving Stats so it only exists if that does and draws data using the same method.

NB: 1st PR on a HA integration, please be kind.

cdnninja commented 4 weeks ago

Actually scratch that. I see an existing if is used.

Let's merge and see what happens! I can't test since I don't have a Kia anymore.

Triple-S commented 3 weeks ago

What is the reason for adding a new sensor that just copys already existing data? I really don't see the point of this change besides blowing up the database unnecessarily.

MichaelMKKelly commented 3 weeks ago

What is the reason for adding a new sensor that just copys already existing data? I really don't see the point of this change besides blowing up the database unnecessarily.

so there is a single target to get "todays data" rather then go looking for the correct attribute of a sensor which may or may not exist. if there is no data for "today" this returns 0. having a single target that resets at midnight simplifies obtaining and tracking daily data.

1 sensor with a few attributes is hardly "blowing up the database" . You can disable the sensor if you don't need/want it. although I suppose there is maybe an argument for disabling it by default and people switching it on if they want it. whichever way around it is there will likely be disagreement.