I’m trying to use a statistics sensor to determine the average times our cat goes to the litterbox so I can detect when something is wrong with him if he goes a lot more or a lot less than average on the potty.
I’ve read the stats sensor page but I’m still not sure the following is correct:
So what I would like is that I get stats ‘per day’, would the max_age be used for that as in my config? What about the sampling size? I’ve set precision to 1 as 0.5 accuracy seems enough for this use case.
E.g. if the average per day is 5, then I could trigger an automation to send a push notif if the current day count is 0 or 10 at 8pm or so
If it matters, my recorder is set up to keep 14 days worth of data.
I agree the docs for this sensor do not make it very clear how it actually works (although I suspect that it is one of those cases where if you do know how it works, the docs will appears clear. If you know what I mean!)
And I, only yesterday was wondering how to configure it suit my needs.
Please don’t use screenshots. Use pasted code properly formatted. It makes it easier for people to use your code in a reply.
Sampling size dependos on how often your sensor reports. You want sampling size to be greater than the number of reports by the sensor in a day. Otherwise the stats will roll over when the sample size has been reached.
E.g. if your sensor reports every 30 seconds and the number of seconds in a day is 86,400:
sample size = 86,400 / 30 = 2880. Make it an even 3000 to be sure. The data will roll over when your max age is reached.
This depends on your current sensor. How many times does it report over 24 hours? If it reports 100 times, then your max sample size is 100. You can choose from there.
This will report the number of hours your litter box has been occupied during the last 24.
Optionally, you can change “type” to “count” and get a count of the number of times in the last 24 hours. As I don’t use this sensor with a type of “count”, I’m not sure what happens if your sensor reports “on” again while it’s already “on”. In other words, the xiaomi motion sensors report “on” for 2 minutes when it senses motion. At the end of the 2 minute period, if it checks to see if there is still motion and reports another “on”, I’m not sure if this will count again. If the sensor doesn’t re-report the “on”, then you still have the issue where your kitty isn’t moving for a few seconds so it reports “off” and then “on” again right after that, this will most certainly count as 2 visits. So the “time” type sensor might be easier to evaluate.