init III
This commit is contained in:
52
Perl Luftdaten/13728_13729.html
Normal file
52
Perl Luftdaten/13728_13729.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a name="oben"></a>
|
||||
<a href="luftdaten.html">zurück</a><br><br>
|
||||
<a href="#Temperature">Temperature</a><br>
|
||||
<a href="#PM10">PM10</a><br>
|
||||
<a href="#PM25">PM25</a><br>
|
||||
<a href="#Humidity">Humidity</a><br>
|
||||
<a href="#hPa">hPa</a><br><br>
|
||||
<a href="13728_13729/archive.html" target="archive">archive</a><br>
|
||||
<iframe marginwidth="0" frameborder="0" height="40px" src="13728_13729/here"></iframe>
|
||||
|
||||
<h1>13728_13729</h1>
|
||||
<h2><a name="Temperature"></a>Temperature</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="13728_13729/graph-Temperature-1h.png">
|
||||
<img src="13728_13729/graph-Temperature-1d.png">
|
||||
<img src="13728_13729/graph-Temperature-1w.png">
|
||||
<img src="13728_13729/graph-Temperature-1m.png">
|
||||
<img src="13728_13729/graph-Temperature-1y.png">
|
||||
<h2><a name="PM10"></a>PM10</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="13728_13729/graph-PM10-1h.png">
|
||||
<img src="13728_13729/graph-PM10-1d.png">
|
||||
<img src="13728_13729/graph-PM10-1w.png">
|
||||
<img src="13728_13729/graph-PM10-1m.png">
|
||||
<img src="13728_13729/graph-PM10-1y.png">
|
||||
<h2><a name="PM25"></a>PM25</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="13728_13729/graph-PM25-1h.png">
|
||||
<img src="13728_13729/graph-PM25-1d.png">
|
||||
<img src="13728_13729/graph-PM25-1w.png">
|
||||
<img src="13728_13729/graph-PM25-1m.png">
|
||||
<img src="13728_13729/graph-PM25-1y.png">
|
||||
<h2><a name="Humidity"></a>Humidity</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="13728_13729/graph-Humidity-1h.png">
|
||||
<img src="13728_13729/graph-Humidity-1d.png">
|
||||
<img src="13728_13729/graph-Humidity-1w.png">
|
||||
<img src="13728_13729/graph-Humidity-1m.png">
|
||||
<img src="13728_13729/graph-Humidity-1y.png">
|
||||
<h2><a name="hPa"></a>Air Pressure</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="13728_13729/graph-hPa-1h.png">
|
||||
<img src="13728_13729/graph-hPa-1d.png">
|
||||
<img src="13728_13729/graph-hPa-1w.png">
|
||||
<img src="13728_13729/graph-hPa-1m.png">
|
||||
<img src="13728_13729/graph-hPa-1y.png">
|
||||
</body>
|
||||
</html>
|
||||
19
Perl Luftdaten/13728_13729/archive.html
Normal file
19
Perl Luftdaten/13728_13729/archive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Temperature</h2>
|
||||
<a href='graph-Temperature-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Temperature-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM10</h2>
|
||||
<a href='graph-PM10-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM10-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM25</h2>
|
||||
<a href='graph-PM25-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM25-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>Humidity</h2>
|
||||
<a href='graph-Humidity-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Humidity-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>hPa</h2>
|
||||
<a href='graph-hPa-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-hPa-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
</body>
|
||||
</html>
|
||||
1
Perl Luftdaten/13728_13729/here
Normal file
1
Perl Luftdaten/13728_13729/here
Normal file
@@ -0,0 +1 @@
|
||||
<a href='https://wego.here.com/directions/mix/50.124,8.766/?map=50.124,8.766,16,normal' target='_map'>wego.here</a>
|
||||
30
Perl Luftdaten/13728_13729/mkarchive.sh
Normal file
30
Perl Luftdaten/13728_13729/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/13728_13729/
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
61
Perl Luftdaten/13728_13729/read_multiple.pl
Normal file
61
Perl Luftdaten/13728_13729/read_multiple.pl
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/13728_13729/db_13728_13729.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=13728;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/13728_13729/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
|
||||
$sensor=13729;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
154
Perl Luftdaten/13728_13729/write_graph.sh
Normal file
154
Perl Luftdaten/13728_13729/write_graph.sh
Normal file
@@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
# "DEF:VNAME1=db_13728_13729.rrd:$VALUE:AVERAGE:step=$1" \
|
||||
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN) red[$1s Average]" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_13728_13729.rrd:$VALUE:AVERAGE" \
|
||||
"DEF:VNAME1=db_13728_13729.rrd:$VALUE:AVERAGE:step=$1" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME1#FF0000' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/13728_13729/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 300
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 300
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 300
|
||||
|
||||
export VALUE=PM25
|
||||
graph 300
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 300
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 1800
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 1800
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 1800
|
||||
|
||||
export VALUE=PM25
|
||||
graph 1800
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 1800
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 3600
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM25
|
||||
graph 3600
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 3600
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 3600
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM25
|
||||
graph 3600
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 3600
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 86400
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 86400
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 86400
|
||||
|
||||
export VALUE=PM25
|
||||
graph 86400
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 86400
|
||||
52
Perl Luftdaten/26940_26941.html
Normal file
52
Perl Luftdaten/26940_26941.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a name="oben"></a>
|
||||
<a href="luftdaten.html">zurück</a><br><br>
|
||||
<a href="#Temperature">Temperature</a><br>
|
||||
<a href="#PM10">PM10</a><br>
|
||||
<a href="#PM25">PM25</a><br>
|
||||
<a href="#Humidity">Humidity</a><br>
|
||||
<a href="#hPa">hPa</a><br><br>
|
||||
<a href="26940_26941/archive.html" target="archive">archive</a><br>
|
||||
<iframe marginwidth="0" frameborder="0" height="40px" src="26940_26941/here"></iframe>
|
||||
|
||||
<h1>26940_26941</h1>
|
||||
<h2><a name="Temperature"></a>Temperature</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="26940_26941/graph-Temperature-1h.png">
|
||||
<img src="26940_26941/graph-Temperature-1d.png">
|
||||
<img src="26940_26941/graph-Temperature-1w.png">
|
||||
<img src="26940_26941/graph-Temperature-1m.png">
|
||||
<img src="26940_26941/graph-Temperature-1y.png">
|
||||
<h2><a name="PM10"></a>PM10</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="26940_26941/graph-PM10-1h.png">
|
||||
<img src="26940_26941/graph-PM10-1d.png">
|
||||
<img src="26940_26941/graph-PM10-1w.png">
|
||||
<img src="26940_26941/graph-PM10-1m.png">
|
||||
<img src="26940_26941/graph-PM10-1y.png">
|
||||
<h2><a name="PM25"></a>PM25</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="26940_26941/graph-PM25-1h.png">
|
||||
<img src="26940_26941/graph-PM25-1d.png">
|
||||
<img src="26940_26941/graph-PM25-1w.png">
|
||||
<img src="26940_26941/graph-PM25-1m.png">
|
||||
<img src="26940_26941/graph-PM25-1y.png">
|
||||
<h2><a name="Humidity"></a>Humidity</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="26940_26941/graph-Humidity-1h.png">
|
||||
<img src="26940_26941/graph-Humidity-1d.png">
|
||||
<img src="26940_26941/graph-Humidity-1w.png">
|
||||
<img src="26940_26941/graph-Humidity-1m.png">
|
||||
<img src="26940_26941/graph-Humidity-1y.png">
|
||||
<h2><a name="hPa"></a>Air Pressure</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="26940_26941/graph-hPa-1h.png">
|
||||
<img src="26940_26941/graph-hPa-1d.png">
|
||||
<img src="26940_26941/graph-hPa-1w.png">
|
||||
<img src="26940_26941/graph-hPa-1m.png">
|
||||
<img src="26940_26941/graph-hPa-1y.png">
|
||||
</body>
|
||||
</html>
|
||||
19
Perl Luftdaten/26940_26941/archive.html
Normal file
19
Perl Luftdaten/26940_26941/archive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Temperature</h2>
|
||||
<a href='graph-Temperature-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Temperature-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM10</h2>
|
||||
<a href='graph-PM10-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM10-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM25</h2>
|
||||
<a href='graph-PM25-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM25-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>Humidity</h2>
|
||||
<a href='graph-Humidity-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Humidity-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>hPa</h2>
|
||||
<a href='graph-hPa-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-hPa-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
</body>
|
||||
</html>
|
||||
1
Perl Luftdaten/26940_26941/here
Normal file
1
Perl Luftdaten/26940_26941/here
Normal file
@@ -0,0 +1 @@
|
||||
<a href='https://wego.here.com/directions/mix/50.126,8.696/?map=50.126,8.696,16,normal' target='_map'>wego.here</a>
|
||||
30
Perl Luftdaten/26940_26941/mkarchive.sh
Normal file
30
Perl Luftdaten/26940_26941/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/26940_26941
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
60
Perl Luftdaten/26940_26941/read_multiple.pl
Normal file
60
Perl Luftdaten/26940_26941/read_multiple.pl
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/26940_26941/db_26940_26941.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=26940;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/26940_26941/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
$sensor=26941;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
150
Perl Luftdaten/26940_26941/write_graph.sh
Normal file
150
Perl Luftdaten/26940_26941/write_graph.sh
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN)" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_26940_26941.rrd:$VALUE:MAX" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/26940_26941/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
52
Perl Luftdaten/31386_31387.html
Normal file
52
Perl Luftdaten/31386_31387.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a name="oben"></a>
|
||||
<a href="luftdaten.html">zurück</a><br><br>
|
||||
<a href="#Temperature">Temperature</a><br>
|
||||
<a href="#PM10">PM10</a><br>
|
||||
<a href="#PM25">PM25</a><br>
|
||||
<a href="#Humidity">Humidity</a><br>
|
||||
<a href="#hPa">hPa</a><br><br>
|
||||
<a href="31386_31387/archive.html" target="archive">archive</a><br>
|
||||
<iframe marginwidth="0" frameborder="0" height="40px" src="31386_31387/here"></iframe>
|
||||
|
||||
<h1>31386_31387</h1>
|
||||
<h2><a name="Temperature"></a>Temperature</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="31386_31387/graph-Temperature-1h.png">
|
||||
<img src="31386_31387/graph-Temperature-1d.png">
|
||||
<img src="31386_31387/graph-Temperature-1w.png">
|
||||
<img src="31386_31387/graph-Temperature-1m.png">
|
||||
<img src="31386_31387/graph-Temperature-1y.png">
|
||||
<h2><a name="PM10"></a>PM10</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="31386_31387/graph-PM10-1h.png">
|
||||
<img src="31386_31387/graph-PM10-1d.png">
|
||||
<img src="31386_31387/graph-PM10-1w.png">
|
||||
<img src="31386_31387/graph-PM10-1m.png">
|
||||
<img src="31386_31387/graph-PM10-1y.png">
|
||||
<h2><a name="PM25"></a>PM25</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="31386_31387/graph-PM25-1h.png">
|
||||
<img src="31386_31387/graph-PM25-1d.png">
|
||||
<img src="31386_31387/graph-PM25-1w.png">
|
||||
<img src="31386_31387/graph-PM25-1m.png">
|
||||
<img src="31386_31387/graph-PM25-1y.png">
|
||||
<h2><a name="Humidity"></a>Humidity</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="31386_31387/graph-Humidity-1h.png">
|
||||
<img src="31386_31387/graph-Humidity-1d.png">
|
||||
<img src="31386_31387/graph-Humidity-1w.png">
|
||||
<img src="31386_31387/graph-Humidity-1m.png">
|
||||
<img src="31386_31387/graph-Humidity-1y.png">
|
||||
<h2><a name="hPa"></a>Air Pressure</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="31386_31387/graph-hPa-1h.png">
|
||||
<img src="31386_31387/graph-hPa-1d.png">
|
||||
<img src="31386_31387/graph-hPa-1w.png">
|
||||
<img src="31386_31387/graph-hPa-1m.png">
|
||||
<img src="31386_31387/graph-hPa-1y.png">
|
||||
</body>
|
||||
</html>
|
||||
19
Perl Luftdaten/31386_31387/archive.html
Normal file
19
Perl Luftdaten/31386_31387/archive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Temperature</h2>
|
||||
<a href='graph-Temperature-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Temperature-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM10</h2>
|
||||
<a href='graph-PM10-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM10-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM25</h2>
|
||||
<a href='graph-PM25-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM25-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>Humidity</h2>
|
||||
<a href='graph-Humidity-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Humidity-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>hPa</h2>
|
||||
<a href='graph-hPa-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-hPa-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
</body>
|
||||
</html>
|
||||
1
Perl Luftdaten/31386_31387/here
Normal file
1
Perl Luftdaten/31386_31387/here
Normal file
@@ -0,0 +1 @@
|
||||
<a href='https://wego.here.com/directions/mix/50.124,8.688/?map=50.124,8.688,16,normal' target='_map'>wego.here</a>
|
||||
30
Perl Luftdaten/31386_31387/mkarchive.sh
Normal file
30
Perl Luftdaten/31386_31387/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/31386_31387
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
62
Perl Luftdaten/31386_31387/read_multiple.pl
Normal file
62
Perl Luftdaten/31386_31387/read_multiple.pl
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/31386_31387/db_31386_31387.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=31386;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/31386_31387/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
|
||||
$sensor=31387;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
150
Perl Luftdaten/31386_31387/write_graph.sh
Normal file
150
Perl Luftdaten/31386_31387/write_graph.sh
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN)" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_31386_31387.rrd:$VALUE:MAX" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/31386_31387/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
52
Perl Luftdaten/761_762.html
Normal file
52
Perl Luftdaten/761_762.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a name="oben"></a>
|
||||
<a href="luftdaten.html">zurück</a><br><br>
|
||||
<a href="#Temperature">Temperature</a><br>
|
||||
<a href="#PM10">PM10</a><br>
|
||||
<a href="#PM25">PM25</a><br>
|
||||
<a href="#Humidity">Humidity</a><br>
|
||||
<a href="#hPa">hPa</a><br><br>
|
||||
<a href="761_762/archive.html" target="archive">archive</a><br>
|
||||
<iframe marginwidth="0" frameborder="0" height="40px" src="761_762/here"></iframe>
|
||||
|
||||
<h1>761_762</h1>
|
||||
<h2><a name="Temperature"></a>Temperature</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="761_762/graph-Temperature-1h.png">
|
||||
<img src="761_762/graph-Temperature-1d.png">
|
||||
<img src="761_762/graph-Temperature-1w.png">
|
||||
<img src="761_762/graph-Temperature-1m.png">
|
||||
<img src="761_762/graph-Temperature-1y.png">
|
||||
<h2><a name="PM10"></a>PM10</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="761_762/graph-PM10-1h.png">
|
||||
<img src="761_762/graph-PM10-1d.png">
|
||||
<img src="761_762/graph-PM10-1w.png">
|
||||
<img src="761_762/graph-PM10-1m.png">
|
||||
<img src="761_762/graph-PM10-1y.png">
|
||||
<h2><a name="PM25"></a>PM25</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="761_762/graph-PM25-1h.png">
|
||||
<img src="761_762/graph-PM25-1d.png">
|
||||
<img src="761_762/graph-PM25-1w.png">
|
||||
<img src="761_762/graph-PM25-1m.png">
|
||||
<img src="761_762/graph-PM25-1y.png">
|
||||
<h2><a name="Humidity"></a>Humidity</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="761_762/graph-Humidity-1h.png">
|
||||
<img src="761_762/graph-Humidity-1d.png">
|
||||
<img src="761_762/graph-Humidity-1w.png">
|
||||
<img src="761_762/graph-Humidity-1m.png">
|
||||
<img src="761_762/graph-Humidity-1y.png">
|
||||
<h2><a name="hPa"></a>Air Pressure</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="761_762/graph-hPa-1h.png">
|
||||
<img src="761_762/graph-hPa-1d.png">
|
||||
<img src="761_762/graph-hPa-1w.png">
|
||||
<img src="761_762/graph-hPa-1m.png">
|
||||
<img src="761_762/graph-hPa-1y.png">
|
||||
</body>
|
||||
</html>
|
||||
19
Perl Luftdaten/761_762/archive.html
Normal file
19
Perl Luftdaten/761_762/archive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Temperature</h2>
|
||||
<a href='graph-Temperature-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Temperature-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM10</h2>
|
||||
<a href='graph-PM10-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM10-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM25</h2>
|
||||
<a href='graph-PM25-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM25-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>Humidity</h2>
|
||||
<a href='graph-Humidity-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Humidity-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>hPa</h2>
|
||||
<a href='graph-hPa-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-hPa-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
</body>
|
||||
</html>
|
||||
1
Perl Luftdaten/761_762/here
Normal file
1
Perl Luftdaten/761_762/here
Normal file
@@ -0,0 +1 @@
|
||||
<a href='https://wego.here.com/directions/mix/50.128,8.728/?map=50.128,8.728,16,normal' target='_map'>wego.here</a>
|
||||
30
Perl Luftdaten/761_762/mkarchive.sh
Normal file
30
Perl Luftdaten/761_762/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/761_762/
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
61
Perl Luftdaten/761_762/read_multiple.pl
Normal file
61
Perl Luftdaten/761_762/read_multiple.pl
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/761_762/db_761_762.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=761;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/761_762/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
|
||||
$sensor=762;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
154
Perl Luftdaten/761_762/write_graph.sh
Normal file
154
Perl Luftdaten/761_762/write_graph.sh
Normal file
@@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
# "DEF:VNAME1=db_761_762.rrd:$VALUE:AVERAGE:step=$1" \
|
||||
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN) red[$1s Average]" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_761_762.rrd:$VALUE:AVERAGE" \
|
||||
"DEF:VNAME1=db_761_762.rrd:$VALUE:AVERAGE:step=$1" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME1#FF0000' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/761_762/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 300
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 300
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 300
|
||||
|
||||
export VALUE=PM25
|
||||
graph 300
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 300
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 1800
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 1800
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 1800
|
||||
|
||||
export VALUE=PM25
|
||||
graph 1800
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 1800
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 3600
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM25
|
||||
graph 3600
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 3600
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 3600
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 3600
|
||||
|
||||
export VALUE=PM25
|
||||
graph 3600
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 3600
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph 86400
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph 86400
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph 86400
|
||||
|
||||
export VALUE=PM25
|
||||
graph 86400
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph 86400
|
||||
46
Perl Luftdaten/README
Normal file
46
Perl Luftdaten/README
Normal file
@@ -0,0 +1,46 @@
|
||||
https://rrdwizard.appspot.com/index.php
|
||||
|
||||
rrdtool create filename.rrd \
|
||||
--step '300' \
|
||||
'DS:PM25:GAUGE:300:0:2000' \
|
||||
'DS:PM10:GAUGE:300:0:2000' \
|
||||
'DS:Temperature:GAUGE:300:-30:60' \
|
||||
'DS:Humidity:GAUGE:300:0:100' \
|
||||
'DS:hPa:GAUGE:300:300:1100' \
|
||||
'RRA:MIN:0.5:1:105408' \
|
||||
'RRA:MAX:0.5:1:105408' \
|
||||
'RRA:AVERAGE:0.5:1:105408' \
|
||||
'RRA:LAST:0.5:1:105408' \
|
||||
'RRA:MIN:0.5:12:87600' \
|
||||
'RRA:MAX:0.5:12:87600' \
|
||||
'RRA:AVERAGE:0.5:12:87600' \
|
||||
'RRA:LAST:0.5:12:87600'
|
||||
|
||||
|
||||
|
||||
VALUE:PM10,PM25,Temperature,Humidity
|
||||
UNIT:µg,µg,°C,%
|
||||
SPAN:1h 1d 1w ...
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
export SPAN=1d
|
||||
|
||||
rrdtool graph "graph_$VALUE.png" \
|
||||
--title "$VALUE" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_761_762.rrd:$VALUE:MAX" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
|
||||
|
||||
52
Perl Luftdaten/XXXX.html
Normal file
52
Perl Luftdaten/XXXX.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<a name="oben"></a>
|
||||
<a href="luftdaten.html">zurück</a><br><br>
|
||||
<a href="#Temperature">Temperature</a><br>
|
||||
<a href="#PM10">PM10</a><br>
|
||||
<a href="#PM25">PM25</a><br>
|
||||
<a href="#Humidity">Humidity</a><br>
|
||||
<a href="#hPa">hPa</a><br><br>
|
||||
<a href="XXXX/archive.html" target="archive">archive</a><br>
|
||||
<iframe marginwidth="0" frameborder="0" height="40px" src="XXXX/here"></iframe>
|
||||
|
||||
<h1>XXXX</h1>
|
||||
<h2><a name="Temperature"></a>Temperature</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="XXXX/graph-Temperature-1h.png">
|
||||
<img src="XXXX/graph-Temperature-1d.png">
|
||||
<img src="XXXX/graph-Temperature-1w.png">
|
||||
<img src="XXXX/graph-Temperature-1m.png">
|
||||
<img src="XXXX/graph-Temperature-1y.png">
|
||||
<h2><a name="PM10"></a>PM10</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="XXXX/graph-PM10-1h.png">
|
||||
<img src="XXXX/graph-PM10-1d.png">
|
||||
<img src="XXXX/graph-PM10-1w.png">
|
||||
<img src="XXXX/graph-PM10-1m.png">
|
||||
<img src="XXXX/graph-PM10-1y.png">
|
||||
<h2><a name="PM25"></a>PM25</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="XXXX/graph-PM25-1h.png">
|
||||
<img src="XXXX/graph-PM25-1d.png">
|
||||
<img src="XXXX/graph-PM25-1w.png">
|
||||
<img src="XXXX/graph-PM25-1m.png">
|
||||
<img src="XXXX/graph-PM25-1y.png">
|
||||
<h2><a name="Humidity"></a>Humidity</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="XXXX/graph-Humidity-1h.png">
|
||||
<img src="XXXX/graph-Humidity-1d.png">
|
||||
<img src="XXXX/graph-Humidity-1w.png">
|
||||
<img src="XXXX/graph-Humidity-1m.png">
|
||||
<img src="XXXX/graph-Humidity-1y.png">
|
||||
<h2><a name="hPa"></a>Air Pressure</h2>
|
||||
<a href="#oben">nach oben</a><br>
|
||||
<img src="XXXX/graph-hPa-1h.png">
|
||||
<img src="XXXX/graph-hPa-1d.png">
|
||||
<img src="XXXX/graph-hPa-1w.png">
|
||||
<img src="XXXX/graph-hPa-1m.png">
|
||||
<img src="XXXX/graph-hPa-1y.png">
|
||||
</body>
|
||||
</html>
|
||||
42
Perl Luftdaten/create_new.sh
Normal file
42
Perl Luftdaten/create_new.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" == "" ]
|
||||
then
|
||||
echo Sensornummer angeben
|
||||
exit
|
||||
fi
|
||||
|
||||
cd /scripts/luftdaten/
|
||||
|
||||
! Name ermitteln
|
||||
|
||||
export SENSOR1=$1
|
||||
export SENSOR2=`expr $SENSOR1 + 1`
|
||||
export SNAME=${SENSOR1}_${SENSOR2}
|
||||
echo $SNAME
|
||||
|
||||
! Verzeichnis erstellen und füllen
|
||||
mkdir $SNAME
|
||||
cp filename.rrd $SNAME/db_$SNAME.rrd
|
||||
cp mkarchive.sh $SNAME/
|
||||
cp read_multiple.pl $SNAME/
|
||||
cp write_graph.sh $SNAME/
|
||||
cp XXXX.html $SNAME.html
|
||||
|
||||
! Vorlagen anpassen
|
||||
! XXXX -> $SNAME
|
||||
sed -i -e "s/XXXX/$SNAME/g" $SNAME/*
|
||||
sed -i -e "s/XXXX/$SNAME/g" $SNAME.html
|
||||
sed -i -e "s/XXXX\/<a href=\"$SNAME.html\">$SNAME<\/a><br>\nXXXX" index.html
|
||||
|
||||
! Links für Web erstellen
|
||||
cd /var/www/html
|
||||
ln -s /scripts/luftdaten/$SNAME/
|
||||
ln -s /scripts/luftdaten/$SNAME.html
|
||||
|
||||
! cronjobs
|
||||
echo cronjobs erstellen
|
||||
echo "*/5 * * * * /scripts/luftdaten/$SNAME/read_multiple.pl > /dev/null 2>&1"
|
||||
echo "*/5 * * * * /scripts/luftdaten/$SNAME/write_graph.sh > /dev/null 2>&1"
|
||||
echo "10 0 * * * /scripts/luftdaten/$SNAME/mkarchive.sh > /dev/null 2>&1"
|
||||
|
||||
BIN
Perl Luftdaten/filename.rrd
Normal file
BIN
Perl Luftdaten/filename.rrd
Normal file
Binary file not shown.
15
Perl Luftdaten/index.html
Normal file
15
Perl Luftdaten/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
https://api.luftdaten.info/v1/sensor/[sensor]/<br>
|
||||
https://wego.here.com/directions/mix/[LATITUDE],[LONGITUDE]/?map=[LATITUDE],[LONGITUDE],16,normal<br>
|
||||
<br>
|
||||
|
||||
<a href="761_762.html">761_762 Johanna-Tesch-Platz 9</a><br>
|
||||
<a href="13728_13729.html">13728_13729 Konstanzer Str.</a><br>
|
||||
<a href="26940_26941.html">26940_26941 Günthersburgallee 49</a><br>
|
||||
<a href="31386_31387.html">31386_31387 Zeißelstr</a><br>
|
||||
XXXX
|
||||
</body>
|
||||
</html>
|
||||
30
Perl Luftdaten/mkarchive.sh
Normal file
30
Perl Luftdaten/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/XXXX
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
BIN
Perl Luftdaten/mozilla_1.pdf
Normal file
BIN
Perl Luftdaten/mozilla_1.pdf
Normal file
Binary file not shown.
BIN
Perl Luftdaten/mozilla_2.pdf
Normal file
BIN
Perl Luftdaten/mozilla_2.pdf
Normal file
Binary file not shown.
61
Perl Luftdaten/read_multiple.pl
Normal file
61
Perl Luftdaten/read_multiple.pl
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/XXXX/db_XXXX.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=761;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/XXXX/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
|
||||
$sensor=762;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
76
Perl Luftdaten/read_sensor.pl
Normal file
76
Perl Luftdaten/read_sensor.pl
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
#use RRD::Simple ();
|
||||
|
||||
my $sensor=$ARGV[0];
|
||||
|
||||
my $trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
#https://github.com/opendata-stuttgart/meta/wiki/APIs
|
||||
#https://data.sensor.community/airrohr/v1/sensor/762/ temp hum
|
||||
#https://data.sensor.community/airrohr/v1/sensor/761/ pm10 pm25
|
||||
#50.128,8.728
|
||||
#https://wego.here.com/directions/mix/50.128,8.728/?map=50.128,8.728,16,normal
|
||||
|
||||
# open is for files. unless you have a file called
|
||||
# 'https://graph.facebook.com/?ids=http://www.filestube.com' in your
|
||||
# local filesystem, this won't work.
|
||||
#{
|
||||
# local $/; #enable slurp
|
||||
# open my $fh, "<", $trendsurl;
|
||||
# $json = <$fh>;
|
||||
#}
|
||||
|
||||
# Create an interface object
|
||||
#my $rrd = RRD::Simple->new( file => "myfile.rrd" );
|
||||
|
||||
# Create a new RRD file with 3 data sources called
|
||||
# bytesIn, bytesOut and faultsPerSec.
|
||||
#$rrd->create(
|
||||
# P1 => "GAUGE",
|
||||
# P2 => "GAUGE",
|
||||
# time => "STRING"
|
||||
# );
|
||||
|
||||
# 'get' is exported by LWP::Simple; install LWP from CPAN unless you have it.
|
||||
# You need it or something similar (HTTP::Tiny, maybe?) to get web pages.
|
||||
my $json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
|
||||
# This next line isn't Perl. don't know what you're going for.
|
||||
#my $decoded_json = @{decode_json{shares}};
|
||||
|
||||
# Decode the entire JSON
|
||||
my $decoded_json = decode_json( $json );
|
||||
|
||||
# you'll get this (it'll print out); comment this when done.
|
||||
#print Dumper $decoded_json;
|
||||
|
||||
foreach (@{$decoded_json}) {
|
||||
#print $_->{'timestamp'} . "\n";
|
||||
foreach (@{$_->{'sensordatavalues'}}) {
|
||||
#print "$_->{'value_type'}: ";
|
||||
#print $_->{'value'} . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $k=${$decoded_json}[0];
|
||||
#print $k->{'timestamp'} . "\n";
|
||||
foreach (@{$k->{'sensordatavalues'}}) {
|
||||
#print $_->{'value_type'} . ": ";
|
||||
#print $_->{'value'} . "\n";
|
||||
}
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
print "$k->{'sensordatavalues'}[0]->{'value_type'} ";
|
||||
print "$k->{'sensordatavalues'}[0]->{'value'}\n";
|
||||
print "$k->{'sensordatavalues'}[1]->{'value_type'} ";
|
||||
print "$k->{'sensordatavalues'}[1]->{'value'}\n";
|
||||
print "\n";
|
||||
51
Perl Luftdaten/read_sensor2db.pl
Normal file
51
Perl Luftdaten/read_sensor2db.pl
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $DEBUG=1;
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
my $HPA;
|
||||
|
||||
my @sensors = qw /761 762 13728 13729 26940 26941 31386 31387/;
|
||||
|
||||
foreach my $sensor (@sensors) {
|
||||
for (my $i=1; $i<=3; $i++) {
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
my $k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
foreach (@{$k->{'sensordatavalues'}}) {
|
||||
my $type_alias=$_->{'value_type'};
|
||||
my $sensor_value=$_->{'value'};
|
||||
print "$sensor $type_alias $sensor_value\n" if ($DEBUG);
|
||||
}
|
||||
|
||||
#printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
#printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
#$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
#$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
#$LAT = $k->{'location'}->{'latitude'};
|
||||
#$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
sleep (30);
|
||||
}
|
||||
}
|
||||
150
Perl Luftdaten/write_graph.sh
Normal file
150
Perl Luftdaten/write_graph.sh
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN)" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_XXXX.rrd:$VALUE:MAX" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/XXXX/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
Reference in New Issue
Block a user