Statistic sensor in a specific time range

Hi all,

I’m using viaggiatreno sensor to monitor my commuting time. The sensor says the the late of a specific train in minutes.

Later I created an statistic sensor to see the average late time for day and month.

It works but when the train is not departed or has arrived the sensor reports “not departed yer” or “arrived” as status and I found sereral error in logs:

2019-06-12 10:51:44 ERROR (MainThread) [homeassistant.components.statistics.sensor] sensor.ritardo_giornaliero_medio_frecciarossa_delle_19_00_mean: parsing error, expected number and received Arrived stdout

There’s a way to avoid this? Maybe let the sensor do it job only in a specific time range?

Thank you in advance