Description
The problem
Hello. Source sensor sent value of 176 8 hrs ago, then value of 176 4 hrs ago and then value of 197 now. In lovelace, it shows updates 8 hrs ago and now. Derivative sensor as well calculates difference from value 8 hrs ago and now, therefore 2.675/h. Correct difference should be calculated from value which is 4 hrs old and now, therefore 5.25. It looks like when values are same, derivative sensor looks at last change, therefore first of the same values, but it takes tame elapsed between last two values. Here is mqtt log:
Received 2:28:53 AM
QoS: 0
Payload: 176 (Record1)
Received 6:26:41 AM
QoS: 0
Payload: 176 (Record2)
Received 10:24:51 AM
QoS: 0
Payload: 197 (Record3)
It appears that value of derivative sensor is calculated as:
(payload.record3 - payload.record1or2) / (timeof.record3 - timeof.record1)
while it should be:
(payload.record3 - payload.record2) / (timeof.record3 - timeof.record2)
What is version of Home Assistant Core has the issue?
core-2021.3.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
derivative sensor
Link to integration documentation on our website
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
nothing found