#!/bin/bash
#DATE=$(date +"%Y-%m-%d_%H%M")
#echo "-------------------------------------------------------" >> /home/osmc/system_sensors/speedtest2mqtt.MERES


#sends speedtest-cli data as json to MQTT broker
/usr/bin/speedtest-cli --simple | perl -pe 's/^(.*): (.*) (.*?)(\/s)?\n/"$1_$3": $2, /m' | cut -d',' -f 1-3 | while read line
do
# Raw message to MQTT
  echo "{$line}"  | mosquitto_pub -h 192.168.1.180 -u mqtt_user -P kakoca -i RPI_XIAOMI -l -t "speedtest/rpi_xi"
done
