Skip to content

Commit

Permalink
Inital release
Browse files Browse the repository at this point in the history
  • Loading branch information
basti122303 committed May 9, 2023
0 parents commit 5edd3e4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
41 changes: 41 additions & 0 deletions deye_data2vz
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/perl
# A simple pure perl reimplementation of
# https://wiki.volkszaehler.org/hardware/channels/solar_inverters/deye
# I need to query multiple inverters.

use strict;
use warnings;
use LWP::UserAgent;

our %config;
do "/etc/vz/config" or die $@;

my @err;
my $ua = LWP::UserAgent->new;

foreach my $inverter (@{$config{inverter}}){
my $response = $ua->get("http://$inverter->[0]/status.html");
$response->authorization_basic($inverter->[2], $inverter->[3]);
if ($response->is_success) {
my $content = $response->content;
for (split /^/, $content) {
chomp();
my $line = $_;
if ($line =~ /(?<=webdata_now_p = ")\d+/) {
$line =~ s/[^0-9]//g;
$response = $ua->get("http://$config{DB_Host}/middleware/data/$inverter->[1].json?operation=add&value=$line");
if (!$response->is_success) {
push @err,$response->status_line;
}
last;
}
}
}
else {
push @err,$response->status_line;
}
}
foreach (@err) {
print "$_\n";
}
exit @err ? 1 : 0;
7 changes: 7 additions & 0 deletions etc/vz/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%config=(
DB_Host=>'vzhost.example.com',
inverter=>[
['inverter.example.com','<YOUR UUID>','admin','yourpass'],
['inverter2.example.com','<YOUR UUID2>','admin','yourpass'],
],
);

0 comments on commit 5edd3e4

Please sign in to comment.