#!/bin/bash id=1 TMP=/tmp/metrics.$$ ( color() { guid=$(uuidgen) echo " { \"enableIntermediateState\": true, \"enablePub\": true, \"enteredIntermediateStateAt\": 0, \"format\": 0, \"icon\": \"ic_radio_button_checked\", \"id\": \"$guid\", \"intermediateStateTimeout\": 0, \"jsBlinkExpression\": \"\", \"jsOnDisplay\": \"\", \"jsOnReceive\": \"\", \"jsOnTap\": \"\", \"jsonPath\": \"\", \"longId\": $id, \"name\": \"$1\", \"qos\": 0, \"retained\": false, \"topic\": \"$2\", \"topicPub\": \"\", \"type\": 6, \"updateLastPayloadOnPub\": true } " id=$[ $id + 1] } list() { guid=$(uuidgen) echo " { \"enableIntermediateState\": true, \"enablePub\": true, \"enteredIntermediateStateAt\": 0, \"id\": \"$guid\", \"intermediateStateTimeout\": 0, \"items\": [ " echo "$3" echo " ], \"jsBlinkExpression\": \"\", \"jsOnDisplay\": \"\", \"jsOnReceive\": \"\", \"jsOnTap\": \"\", \"jsonPath\": \"\", \"longId\": $id, \"mainTextSize\": \"LARGE\", \"name\": \"$1\", \"qos\": 0, \"retained\": false, \"textColor\": -1, \"topic\": \"$2\", \"topicPub\": \"\", \"type\": 4, \"updateLastPayloadOnPub\": true } " id=$[ $id + 1] } toggle() { guid=$(uuidgen) echo " { \"enableIntermediateState\": true, \"enablePub\": $4, \"enteredIntermediateStateAt\": 0, \"iconOff\": \"ic_check_box_unchecked\", \"iconOn\": \"ic_check_box_checked\", \"id\": \"$guid\", \"intermediateStateTimeout\": 0, \"jsBlinkExpression\": \"\", \"jsOnDisplay\": \"\", \"jsOnReceive\": \"\", \"jsOnTap\": \"\", \"jsonPath\": \"\", \"longId\": $id, \"name\": \"$1\", \"offColor\": -1, \"onColor\": -1, \"payloadOff\": \"$5\", \"payloadOn\": \"$6\", \"qos\": 0, \"retained\": false, \"topic\": \"$3\", \"topicPub\": \"$2\", \"type\": 2, \"updateLastPayloadOnPub\": true } " id=$[ $id + 1] } numeric() { guid=$(uuidgen) echo " { \"decimalPrecision\": 1, \"displayPayloadValue\": true, \"enableIntermediateState\": false, \"enablePub\": $4, \"id\": \"$guid\", \"intermediateStateTimeout\": 0, \"jsBlinkExpression\": \"\", \"jsOnDisplay\": \"\", \"jsOnReceive\": \"\", \"jsOnTap\": \"\", \"jsonPath\": \"\", \"longId\": $id, \"maxValue\": $6, \"minValue\": $5, \"name\": \"$1\", \"postfix\": \"\", \"prefix\": \"\", \"progressColor\": -1, \"qos\": 0, \"retained\": false, \"topic\": \"$3\", \"topicPub\": \"$2\", \"type\": 3, \"updateLastPayloadOnPub\": true } " id=$[ $id + 1] } lightswitch() { toggle $1 cmnd/$2/$3 stat/$2/$3 true OFF ON } lightswitch_l() { lightswitch $1 $1 POWER } radiator() { toggle "${1}_coil" cmnd/$1/POWER stat/$1/POWER false OFF ON echo "," toggle "${1}_open" cmnd/$1/OPEN stat/$1/OPEN false 0 1 echo "," numeric "${1}_temp" cmnd/$1/TEMPERATURE stat/$1/TEMPERATURE false 5.0 35.0 echo "," numeric "${1}_low" cmnd/$1/var1 stat/$1/var1 true 5.0 35.0 echo "," numeric "${1}_high" cmnd/$1/var2 stat/$1/var2 true 5.0 35.0 } echo "[" for r in hall_radiator laundry_radiator kitchen_radiator dd_radiator1 dd_radiator2 dd_radiator3 music_room_radiator music_room_e_radiator plc0_radiator7; do radiator $r echo "," done for r in bathroom_radiator bedroom_radiator kstudy_radiator boxroom_radiator spare_bedroom_radiator ; do radiator $r echo "," done radiator 2fl_main_radiator echo "," radiator 2fl_stair_radiator echo "]" ) > ${TMP} mosquitto_pub -h 10.32.137.1 -t metrics/exchange -f ${TMP}