API error How to avoid this problem

From time to time I got the API error message and the status of the sensor I’m monitoring become “Unavailable”. Depending what tipe of flow, it happens that some automation don’t work fine in that case.
If I have a very simple flow that switch on and off a light at specific time like this

if I have an API error the flow run in a undesired statis where the light stay off.

Is there any way to avoid the problem?

Thank You

Regards

M.