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:
parent
5f44f5ac41
commit
35150803ef
1 changed files with 7 additions and 2 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue