@petro , in this case @Edwin_D is correct. There is something changing, and that is time, which is a fundamental aspect of a gradient. The unit_of_measurement of a gradient or derivative is always UoM/TimeUnit, such as km/hr, %/sec, etc.
By definition, if the sensor does not change value over a period of time the gradient is 0.
So it isn’t a feature request. It’s a bug report.
@Edwin_D thank you for posting the feature request. I have not looked at the details of your submission, but I guess the easiest way to implement this would be to add a time delta at which the value is reassessed. It really should be performing some sort of smoothing, otherwise the gradient will jump all over the place if the sensor is changing sporadically while time is progressing in set intervals.
But somewhere in the HA community someone knows how to do this correctly because of the way the Sensor graph is displayed without/with detail, which is still a smoothed line compared to the History Graph. The screen shot is the display of the same sensor in these 3 methods.
I never said it was or wasn’t correct. Again, I’m not here to discuss what’s right or wrong. I’m describing how it works. That’s it.
The graphs have a spline fit on them, they do not show actual values between the datapoints. It’s a fancy graphic that makes the data points connect without sharp corners.
Time is a sensor with input to the Gradient calculation. The user can decide on the units and time bucket size, for example “00:01:00” would re-evaluate the gradient every minute. The gradient value is calculated every time value change, when the value of the sensor is checked.
We can’t calculate a gradient until we have 2 values for the value sensor.
You don’t have to make a template. Atleast, I didn’t.
Go to Settings, and then Devices & Services settings, and then the “helpers” tab and add the Derivative. Fill in the timewindow you want to measure and ID of the humidity sensor and you’re good to go.
Reboot and see the behaviour of the output of the derivative sensor in the History, to base your automation decisions on.
The automation triggers very quickly, which is great, however, as soon as the shower is done, the dehumidifier causes the derivative to dive very quickly. As a result the dehumidifier turns off way quicker than I would like.
Track the humidity and turn off the switch when the humidity reaches a desired level. Or just use a timer after the derivative drops. I put a 20 minute delay after the drop before turning off my switch.