Bring back the state data item in status group

Derive connectivity state information from the "outage" field of the get_status response, which I hadn't noticed before because it only populates when the dish is not in a connected state. This restores the state data item in the status mode group, which had been rendered useless due to a grpc service change.

In addition to the previous possible state names, this adds a few more that pertain to outages while otherwise connected, which I think were just previously reported as "CONNECTED", as well as some special cases of offline.
This commit is contained in:
sparky8512 2021-10-19 15:34:45 -07:00
parent 79839c0b19
commit 3dddd95ff3

View file

@ -33,8 +33,8 @@ This group holds information about the current state of the user terminal.
: **software_version** : A string identifying the software currently installed : **software_version** : A string identifying the software currently installed
on the user terminal. on the user terminal.
: **state** : As string describing the current connectivity state of the user : **state** : As string describing the current connectivity state of the user
terminal. One of: "UNKNOWN", "CONNECTED", "SEARCHING", "BOOTING". terminal. One of: "UNKNOWN", "CONNECTED", "BOOTING", "SEARCHING", "STOWED",
**OBSOLETE**: The user terminal no longer provides this data. "THERMAL_SHUTDOWN", "NO_SATS", "OBSTRUCTED", "NO_DOWNLINK", "NO_PINGS".
: **uptime** : The amount of time, in seconds, since the user terminal last : **uptime** : The amount of time, in seconds, since the user terminal last
rebooted. rebooted.
: **snr** : Most recent sample value. See bulk history data for detail. : **snr** : Most recent sample value. See bulk history data for detail.
@ -596,6 +596,15 @@ def status_data(context=None):
except grpc.RpcError as e: except grpc.RpcError as e:
raise GrpcError(e) raise GrpcError(e)
if status.HasField("outage"):
if status.outage.cause == dish_pb2.DishOutage.Cause.NO_SCHEDULE:
# Special case translate this to equivalent old name
state = "SEARCHING"
else:
state = dish_pb2.DishOutage.Cause.Name(status.outage.cause)
else:
state = "CONNECTED"
# More alerts may be added in future, so in addition to listing them # More alerts may be added in future, so in addition to listing them
# individually, provide a bit field based on field numbers of the # individually, provide a bit field based on field numbers of the
# DishAlerts message. # DishAlerts message.
@ -618,7 +627,7 @@ def status_data(context=None):
"id": status.device_info.id, "id": status.device_info.id,
"hardware_version": status.device_info.hardware_version, "hardware_version": status.device_info.hardware_version,
"software_version": status.device_info.software_version, "software_version": status.device_info.software_version,
"state": "UNKNOWN", # obsoleted in grpc service "state": state,
"uptime": status.device_state.uptime_s, "uptime": status.device_state.uptime_s,
"snr": None, # obsoleted in grpc service "snr": None, # obsoleted in grpc service
"seconds_to_first_nonempty_slot": status.seconds_to_first_nonempty_slot, "seconds_to_first_nonempty_slot": status.seconds_to_first_nonempty_slot,