Uitbreiding automatische weer tweets

domoticahouse

In het vorige artikel over automatische weer tweets heb ik uitleg gegeven hoe je gegevens van je weersensoren naar Twitter kunt sturen. Je kunt naarst gegevens van je eigen sensoren ook gegevens van Buienradar en Burze.dzis.net downloaden. Volg voor de installatie onderstaande handleiding.
20180515 tweet
Installeer libpython3.4 en python3-dev om plugins te laten werken, het kan ook zijn dat je dit eerder al gedaan hebt. Dan geeft het systeem het aan als je het probeert.

sudo apt install libpython3.4
sudo apt install python3-dev

Ga vervolgens naar je domoticz/plugins directory doormiddel van de eerste opdracht en clone daarna van Git.

cd domoticz/plugins
git clone https://github.com/ffes/domoticz-buienradar.git
git clone --recursive https://github.com/lrybak/domoticz-storm-report

Herstart Domoticz:
sudo service domoticz.sh restart

Registreer je op https://burze.dzis.net/ en vraag via het contact formulier om een API key

Ga nu naar het Hardware scherm in Domoticz en voeg Buienradar.nl (Weather lookup) en domoticz-storm-report toe. Bij de laatste heb je de API key nodig die je al hebt aangevraagd.

Onder Apparaten zie je vervolgens de opgehaalde informatie.
20180515 buienradar

Om de gegevens van Buienradar en onweer op te nemen in de tweet heb ik het script aangepast.

#!/bin/bash				

timestamp=`/bin/date +%H`

temp=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=3897"`
echo $temp > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
temp=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/"//g'`
 
hygro=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=3897"`
echo $hygro > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
hygro=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17, $18}' | awk '{print $3}' | sed 's/"//g'`

rain=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=876"`
echo $rain > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
rain=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $33, $34}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`

pressure=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=3625"`
echo $pressure > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
pressure=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`
 
wind=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=3896"`
echo $wind > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
dir=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $20, $21}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`
speed=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $22, $23}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'` 
gust=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $39, $40}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`

forecast=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=9"`
echo $forecast > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
forecast=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17}' | awk -F ', "' '{print $1}' | sed 's/"//g'`

rainforecasts=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=8"`
echo $rainforecasts > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
rainforecasts=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`

if [ $rainforecasts == 0 ]; then
echo $regen > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
regen="komend uur droog"
else
echo $regen > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
regen="komend uur kans op "$rainforecasts" mm neerslag"
fi

uv=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=5"`
echo $uv > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
uv=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | cut -c 1-4 | sed 's/"//g' | sed 's/,//g'`

zicht=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=4"`
echo $zicht > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
zicht=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/"//g'`

onweer1=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=18"`
echo $onweer1 > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer1=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17}' | awk '{print $2}' | sed 's/"//g'`

onweer2=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=17"`
echo $onweer2 > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer2=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17}' | awk -F ', "' '{print $1}' | sed 's/"//g'`

onweer3=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=16"`
echo $onweer3 > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer3=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17}' | awk -F ', "' '{print $1}' | sed 's/"//g'`

onweer4=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=19"`
echo $onweer4 > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer4=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $17}' | awk -F ', "' '{print $1}' | sed 's/"//g'`

uv2=`curl "http://127.0.0.1:8080/json.htm?type=devices&rid=8"`
echo $uv2 > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
uv2=`cat /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt | awk -F: '{print $16, $17}' | awk '{print $3}' | sed 's/"//g'`

if [ $onweer3 == 0 ]; then
echo $onweer > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer="Geen onweer de laatste $onweer4"
else
echo $onweer > /home/pi/domoticz/scripts/logging/weather_updates/weather-data.txt
onweer="Onweer op $onweer2 $onweer1 laatste $onweer4"
fi

if [ $speed == $gust ]; then
gusts=""
else
gusts=", "$gust"km/u"
fi

echo -ne "Weer in #Veendam "$timestamp":00 | Temp: "$temp"°C, Wind: "$dir" "$speed"km/u"$gusts", Luchtv: "$hygro"%, Luchtd: "$pressure"hPa, UV: "$uv"Watt/m2, "$uv2"UVI, Zicht: "$zicht"km, "$onweer" | Neerslag vandaag: "$rain"mm | "$forecast" en "$regen""> /home/pi/domoticz/scripts/logging/weather_updates/weather-tweet.txt

Bronnen: https://github.com/ffes/domoticz-buienradar, https://github.com/lrybak/domoticz-storm-report en https://github.com/Siewert308SW/MyDomoticz-Scripts/blob/master/domoticz/scripts/bash/check_domo_weather.sh

Bijgewerkt op 20 februari 2023

Heeft dit artikel je geholpen?

Bedankt voor je feedback!

2 antwoorden naar “Uitbreiding automatische weer tweets”

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

*