From 3dddd95ff30e13fd45b8f8fde44925786a261ddb Mon Sep 17 00:00:00 2001 From: sparky8512 <76499194+sparky8512@users.noreply.github.com> Date: Tue, 19 Oct 2021 15:34:45 -0700 Subject: [PATCH] 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. --- starlink_grpc.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/starlink_grpc.py b/starlink_grpc.py index 92c8259..67881ff 100644 --- a/starlink_grpc.py +++ b/starlink_grpc.py @@ -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 on the user terminal. : **state** : As string describing the current connectivity state of the user - terminal. One of: "UNKNOWN", "CONNECTED", "SEARCHING", "BOOTING". - **OBSOLETE**: The user terminal no longer provides this data. + terminal. One of: "UNKNOWN", "CONNECTED", "BOOTING", "SEARCHING", "STOWED", + "THERMAL_SHUTDOWN", "NO_SATS", "OBSTRUCTED", "NO_DOWNLINK", "NO_PINGS". : **uptime** : The amount of time, in seconds, since the user terminal last rebooted. : **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: 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 # individually, provide a bit field based on field numbers of the # DishAlerts message. @@ -618,7 +627,7 @@ def status_data(context=None): "id": status.device_info.id, "hardware_version": status.device_info.hardware_version, "software_version": status.device_info.software_version, - "state": "UNKNOWN", # obsoleted in grpc service + "state": state, "uptime": status.device_state.uptime_s, "snr": None, # obsoleted in grpc service "seconds_to_first_nonempty_slot": status.seconds_to_first_nonempty_slot,