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

feat: Add Sensor for todays daily stats #954

Merged
merged 3 commits into from
Oct 27, 2024

Conversation

MichaelMKKelly
Copy link
Contributor

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.

MichaelMKKelly and others added 3 commits October 26, 2024 10:39
add 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.
remove irrelevant test implementation
Copy link
Collaborator

@cdnninja cdnninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this sensor will be added and set to 0 for cars that don't have driving stats. Could you add a if statement to check for stats before appending?

@cdnninja
Copy link
Collaborator

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.

@cdnninja cdnninja merged commit 686baa9 into Hyundai-Kia-Connect:master Oct 27, 2024
4 checks passed
Triple-S added a commit to Triple-S/kia_uvo that referenced this pull request Oct 31, 2024
@Triple-S
Copy link
Contributor

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

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.

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.

3 participants