Derivative sensor


#1

I am missing a sensor that would take input from another sensor and display the derivative of that sensor.
I.e. for a sensor displaying distance (e.g. a car odometer sensor), it would display speed. For a sensor displaying amount of data transferred (for e.g. a modem), it would display data transfer rate. For a sensor displaying temperature, it would display temperature change. Etc.

Would that be usefule to anybody else? Is this already possible or does it already exists?


#2

Take a look at https://home-assistant.io/components/sensor.template/ or https://home-assistant.io/components/sensor.history_stats/


#3

I can’t see how template or history help with this, except for very slow sensors.

The use case I have (and @molobrakos, I think), is much faster. For example, I have an SNMP sensor that reads the number of bytes transmitted on an interface, but I want the bandwidth (bytes per second), measured as a sliding window over the last, say, 2 minutes.

Happy to implement anything, just need tips as to where to start.


#4

Release .87 now includes an Integration sensor. Could the derivative sensor be based on that component implementation? Using finite difference instead of trapezoidal rule for instance.