forked from fredlcore/BSB-LAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_settings.pl
executable file
·36 lines (31 loc) · 971 Bytes
/
backup_settings.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl
# This script retrieves all settings from the heater (optionally limted to a
# range limited by the first two command line arguments) and stores them in a
# CSV-style file.
# All you need to do is adjust the URL of BSB-LAN in the line below (including
# any potential credentials/passcode). Do NOT end the URL with a slash!
my $URL = "http://192.168.1.50/4444";
my $from = $ARGV[0];
my $to = $ARGV[1];
if ($from le " " ) {
$from = 0;
}
if ($to le " " ) {
$to = 9999;
}
print "Creating backup for parameters $from to $to, this may take several minutes...\n";
my $date = `date "+%Y%m%d"`;
chomp ($date);
open (OUT, ">backup_settings-$from-$to-$date.csv");
open (WGET, "wget -q -O - $URL/$from-$to|");
while (my $line=<WGET>) {
if ($line =~ /^\s*(\d+)\s+.*: (.*)/) {
my $param_no = $1;
my $param_val = $2;
if ($param_val =~ /error/) {
next;
}
print "$param_no;$param_val\n";
print OUT "$param_no;$param_val\n";
}
}