From f25e58aa2b8f0e813d1521bc5568e8951d82230f Mon Sep 17 00:00:00 2001 From: sparky8512 <76499194+sparky8512@users.noreply.github.com> Date: Wed, 2 Mar 2022 15:02:29 -0800 Subject: [PATCH] Filter out None values when not in JSON mode I noticed this while testing the change that added the --json option, though it is not related to that change. Sequence types get mushed into a string when not in JSON mode, and that was turning None object values into the string "None", which is not desirable. So, similar to how the text output script handles it, those now get emitted as an empty string instead. JSON mode is probably better to use for this type of data, anyway, but it was bugging me to have it report as "None". --- dish_grpc_mqtt.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dish_grpc_mqtt.py b/dish_grpc_mqtt.py index c4cb838..53cefa7 100644 --- a/dish_grpc_mqtt.py +++ b/dish_grpc_mqtt.py @@ -154,9 +154,8 @@ def loop_body(opts, gstate): key), val, 0, False)) def cb_add_sequence(key, val, category, _): - msgs.append( - ("starlink/dish_{0}/{1}/{2}".format(category, gstate.dish_id, - key), ",".join(str(x) for x in val), 0, False)) + msgs.append(("starlink/dish_{0}/{1}/{2}".format(category, gstate.dish_id, key), + ",".join("" if x is None else str(x) for x in val), 0, False)) rc = dish_common.get_data(opts, gstate, cb_add_item, cb_add_sequence)[0]