I have never seen a switch with those features built in, typically there is some type of control or monitors device that will do it. You can probably get creative with a raspberry pi or something similar if you have the time and know how.
Something like Domotz https://www.domotz.com
will do what you need out of the box as long as your specific switch is supported. I have been using it for quite a while now and it works great.