How to detect and run python script when my sensor is not updated x seconds and

Hi! i’v an inverter that send data to my ha server, but my problem that when my inverter disconnect my raspberry pi also go off… I need to detect when my sensores is not updated 30 seconds and update all my sensors value to 0…
I’v already python script that can change the state of sensors but i dont know how to detexct when my sensors not send me data x seconds…
how can I do this?