Comments (5)
Hey there @ThomDietrich, mind taking a look at this issue as it has been labeled with an integration (statistics
) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of statistics
can trigger bot actions by commenting:
@home-assistant close
Closes the issue.@home-assistant rename Awesome new title
Renames the issue.@home-assistant reopen
Reopen the issue.@home-assistant unassign statistics
Removes the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-information
Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-information
Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
statistics documentation
statistics source
(message by IssueLinks)
from core.
Hello @bakerkj,
thanks for the feedback!
The statistics component calculates change_second
like this:
The calculation doesn't care about the values and the nature of the source sensor.
Did I understand you correctly: You would like a new characteristic which take sum_differences_nonnegative
and divides it by the seconds between the oldest and newest sample?
from core.
Hi @ThomDietrich,
I am trying to use change_second to compute the rate of increase of a counter that is always increasing, except when the device is reset (which is when the counter starts again from zero).
I think instead of the existing code
def _stat_change_second(self) -> StateType:
if len(self.states) > 1:
age_range_seconds = (self.ages[-1] - self.ages[0]).total_seconds()
if age_range_seconds > 0:
return (self.states[-1] - self.states[0]) / age_range_seconds
return None
I think I want something like this
def _stat_change_second_something(self) -> StateType:
if len(self.states) > 1:
age_range_seconds = (self.ages[-1] - self.ages[0]).total_seconds()
change = self.states[-1] - self.states[0]
if age_range_seconds > 0 and change >= 0:
return change / age_range_seconds
return None
So for example
time in seconds | counter | statistic
0 | 0 | None
10 | 10 | 1
20 | 30 | 2
30 | 40 | 1
40 | 0 | None <- counter reset
50 | 20 | 2
60 | 30 | 1
I think in this way, the statistic will not be computed in the case where the counter resets (the change is negative)?
Does that make sense?
Thanks,
Ken
from core.
I think it does make sense. Did you check this integration? I wonder if it already does what you want (not that I am saying this is strictly out of scope for the statistics integration)
https://www.home-assistant.io/integrations/derivative/
from core.
I think it does make sense. Did you check this integration? I wonder if it already does what you want (not that I am saying this is strictly out of scope for the statistics integration)
If I understand correctly, the derivative sensor has the same challenge with counters that reset to zero:
For sensors that reset to zero after a power interruption and need a “non-negative derivative”, such as bandwidth counters in routers, or rain gauges, consider using the Utility Meter integration instead. Otherwise, each reset will register a significant change in the derivative sensor.
I don't think the Utility Meter integration does what I am looking to do.
from core.
Related Issues (20)
- opower pg&e will not authorize HOT 3
- Problems with tuya cam stream, not working... HOT 4
- Dev tools -> Services: calling a service with wrong data does not return an error
- VeSync Integration causing throttling HOT 12
- NWK_INVALID_REQUEST: 194 HOT 4
- [Unifi] MAC address is reported incorrectly in device tracker. HOT 4
- Roborock - intermittent timeout errors loading floor plan image while cleaning HOT 1
- Universal Media Player Does Not Send Volume Up/Down From Control Center Remote When Added To HomeKit HOT 1
- Tuya climate shows wrong temperature HOT 7
- Z-Wave JS: Flickering in QR code scanner and huge error message when QR code does not get recognized HOT 4
- Levoit LTF-F422S-WUS not recognised (Levoit Classic 42-Inch Smart Tower Fan) HOT 7
- Mobile app double device HOT 11
- "Authentication expired" messages HOT 13
- Client error '429 Too Many Requests' for URL HOT 27
- Entities `last_alarm_timestamp` and `seconds_since_last_alarm` are no longer available. HOT 1
- RFXTRX does not detect Oregon sensor any more HOT 3
- Withings sleep two users HOT 14
- Volumio integration doesn't supply media_content_id HOT 1
- RCHTSENSOR data doesn't refresh HOT 2
- WLED (14.3): "Segment Per Output" not importing correctly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.