Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/data/data/com.termux/files/usr/bin/sh -f
- TAB=$(printf '\t')
- # The output format specified by the -F option of 'mosquitto_sub'
- # needs to match how it is subsequently 'read'.
- mosquitto_sub -t 'openScaleSync/measurements/#' -F '%t\t%p\t@s\t%I' \
- -i "Scale Val Sub Client $$" \
- | while true; do
- new_payload=$( IFS="$TAB" read -r topic payload time_processed time_processed_readable;
- (>&2 echo $topic, $payload, $time_processed $time_processed_readable);
- echo "$payload" \
- | jq ". + { \
- \"time\": ( .date / 1000 ), \
- \"time_readable\": \
- ( ( .date / 1000 ) \
- | strflocaltime(\"%Y-%m-%dT%H:%M:%S+0900\") \
- ), \
- \"orig_topic\": \"${topic}\", \
- \"time_processed\": ${time_processed}, \
- \"time_processed_readable\": \"${time_processed_readable}\" \
- } \
- | del(.date)" \
- )
- mosquitto_pub -r -t 'xxxx/scale/weight' -m "$new_payload" \
- -i "Scale Val Pub Client $$" ;
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement