diff --git a/src/parameter_update.sh b/src/parameter_update.sh index 2c4fbc8..d67084e 100755 --- a/src/parameter_update.sh +++ b/src/parameter_update.sh @@ -46,7 +46,7 @@ case "$COMMAND" in exit 1 fi - PARAMETER_PAYLOAD=$(echo "$MESSAGE" | jq ".operation.${TYPE}") + PARAMETER_PAYLOAD=$(echo "$MESSAGE" | jq ".operation.\"${TYPE}\"") echo :::begin-tedge::: printf '{"type":"%s","parameters":%s}\n' "$TYPE" "$PARAMETER_PAYLOAD" diff --git a/src/plugins/flow_params b/src/plugins/flow_params index e322dce..1930680 100755 --- a/src/plugins/flow_params +++ b/src/plugins/flow_params @@ -21,11 +21,14 @@ update_parameters() { # convert json to key/value and write it to the params.toml file echo "Writing to the flows params.toml file. path=$FLOW_DIR/params.toml" >&2 - echo "$MESSAGE" | jq -r 'to_entries|map("\(.key) = \(.value|tojson)")|.[]' | sudo tedge-write "$FLOW_DIR/params.toml" + CONTENTS=$(echo "$MESSAGE" | jq -r 'to_entries|map("\(.key) = \(.value|tojson)")|.[]') + if [ -n "$CONTENTS" ] && [ "$CONTENTS" != "null" ]; then + echo "$MESSAGE" | jq -r 'to_entries|map("\(.key) = \(.value|tojson)")|.[]' | sudo tedge-write "$FLOW_DIR/params.toml" - # Note: manually update the digital twin property though normally this is done by the Device Parameter microservice - # as sending the 408 message is actually harder than just updating the digital twin value - tedge mqtt pub -r "te/device/main///twin/$MESSAGE_TYPE" "${MESSAGE}" + # Note: manually update the digital twin property though normally this is done by the Device Parameter microservice + # as sending the 408 message is actually harder than just updating the digital twin value + tedge mqtt pub -r "te/device/main///twin/$MESSAGE_TYPE" "${MESSAGE}" + fi } get() {