New validity check for prolonged obstruction data

Reintroduce validity check for prolonged obstruction duration and interval, but based on checking for 0.0 and NaN values instead of relying on the valid flag in the gRPC message. Empirical evidence suggests that the dish reports (0, NaN) for those 2 values when it has no obstruction data with which to work, such as when there actually are no obstructions or when the dish has recently rebooted.

This should fix #42.
This commit is contained in:
sparky8512 2022-03-26 15:22:02 -07:00
parent 5f44f5ac41
commit 35150803ef

View file

@ -618,8 +618,13 @@ def status_data(context=None):
if field.number < 65: if field.number < 65:
alert_bits |= (1 if value else 0) << (field.number - 1) alert_bits |= (1 if value else 0) << (field.number - 1)
obstruction_duration = status.obstruction_stats.avg_prolonged_obstruction_duration_s if (status.obstruction_stats.avg_prolonged_obstruction_duration_s > 0.0 and not
obstruction_interval = status.obstruction_stats.avg_prolonged_obstruction_interval_s math.isnan(status.obstruction_stats.avg_prolonged_obstruction_interval_s)):
obstruction_duration = status.obstruction_stats.avg_prolonged_obstruction_duration_s
obstruction_interval = status.obstruction_stats.avg_prolonged_obstruction_interval_s
else:
obstruction_duration = None
obstruction_interval = None
return { return {
"id": status.device_info.id, "id": status.device_info.id,