Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parameter_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/flow_params
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading