mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-08 01:14:19 +00:00
76_SolarForecast: VictronVRM - API request start time adopted
git-svn-id: https://svn.fhem.de/fhem/trunk@28912 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4cb2426a71
commit
775b584745
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it
|
# Do not insert empty lines here, update check depends on it
|
||||||
|
- change: 76_SolarForecast: VictronVRM - API request start time adopted
|
||||||
- change: 73_GardenaSmartBridge: fix: api call,rate limit
|
- change: 73_GardenaSmartBridge: fix: api call,rate limit
|
||||||
- change: 49_SSCAM: NOTE! set enable/disable renamed to enableCam/disableCam
|
- change: 49_SSCAM: NOTE! set enable/disable renamed to enableCam/disableCam
|
||||||
switch commandref to ID tags
|
switch commandref to ID tags
|
||||||
|
@ -157,6 +157,7 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"1.21.2" => "26.05.2024 __VictronVRM_ApiRequestForecast: change request time from current time to '<current hour>:00:00'",
|
||||||
"1.21.1" => "23.05.2024 new sub isDeviceValid, replace Smartmatch Forum:#137776 ",
|
"1.21.1" => "23.05.2024 new sub isDeviceValid, replace Smartmatch Forum:#137776 ",
|
||||||
"1.21.0" => "14.05.2024 currentMeterDev: meter can be a Day meter, contotal and feedtotal can be reset at day begin ",
|
"1.21.0" => "14.05.2024 currentMeterDev: meter can be a Day meter, contotal and feedtotal can be reset at day begin ",
|
||||||
"1.20.0" => "12.05.2024 graphicBeamXContent: gridfeedin available, beamGraphic: Mouse-Over shows beamcontent text ".
|
"1.20.0" => "12.05.2024 graphicBeamXContent: gridfeedin available, beamGraphic: Mouse-Over shows beamcontent text ".
|
||||||
@ -2699,14 +2700,16 @@ sub Get {
|
|||||||
my (undef, $disabled, $inactive) = controller ($name);
|
my (undef, $disabled, $inactive) = controller ($name);
|
||||||
return if($disabled || $inactive);
|
return if($disabled || $inactive);
|
||||||
|
|
||||||
|
my $t = int time;
|
||||||
my $params = {
|
my $params = {
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
name => $name,
|
name => $name,
|
||||||
type => $type,
|
type => $type,
|
||||||
opt => $opt,
|
opt => $opt,
|
||||||
arg => $arg,
|
arg => $arg,
|
||||||
t => int time,
|
t => $t,
|
||||||
date => (strftime "%Y-%m-%d", localtime(time)),
|
chour => (strftime "%H", localtime($t)), # aktuelle Stunde in 24h format (00-23)
|
||||||
|
date => (strftime "%Y-%m-%d", localtime($t)),
|
||||||
debug => getDebug ($hash),
|
debug => getDebug ($hash),
|
||||||
lang => getLang ($hash)
|
lang => getLang ($hash)
|
||||||
};
|
};
|
||||||
@ -3661,14 +3664,17 @@ sub __getDWDSolarData {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
####################################################################################################
|
||||||
# Abruf Victron VRM API Forecast
|
# Abruf Victron VRM API Forecast
|
||||||
################################################################
|
#
|
||||||
|
# https://community.victronenergy.com/questions/216543/new-vrm-feature-solar-forecast.html
|
||||||
|
# API Beschreibung: https://vrm-api-docs.victronenergy.com/#/operations/installations/idSite/stats
|
||||||
|
####################################################################################################
|
||||||
sub __getVictronSolarData {
|
sub __getVictronSolarData {
|
||||||
my $paref = shift;
|
my $paref = shift;
|
||||||
my $hash = $paref->{hash};
|
my $hash = $paref->{hash};
|
||||||
my $force = $paref->{force} // 0;
|
my $force = $paref->{force} // 0;
|
||||||
my $t = $paref->{t} // time;
|
my $t = $paref->{t};
|
||||||
my $lang = $paref->{lang};
|
my $lang = $paref->{lang};
|
||||||
|
|
||||||
my $lrt = SolCastAPIVal ($hash, '?All', '?All', 'lastretrieval_timestamp', 0);
|
my $lrt = SolCastAPIVal ($hash, '?All', '?All', 'lastretrieval_timestamp', 0);
|
||||||
@ -3736,6 +3742,8 @@ sub __VictronVRM_ApiRequestLogin {
|
|||||||
debug => $debug,
|
debug => $debug,
|
||||||
caller => \&$caller,
|
caller => \&$caller,
|
||||||
lang => $paref->{lang},
|
lang => $paref->{lang},
|
||||||
|
chour => $paref->{chour}, # aktuelle Stunde in 24h format (00-23)
|
||||||
|
date => $paref->{date},
|
||||||
idsite => $idsite,
|
idsite => $idsite,
|
||||||
header => { "Content-Type" => "application/json" },
|
header => { "Content-Type" => "application/json" },
|
||||||
data => qq({ "username": "$user", "password": "$pwd" }),
|
data => qq({ "username": "$user", "password": "$pwd" }),
|
||||||
@ -3837,11 +3845,11 @@ sub __VictronVRM_ApiResponseLogin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################################
|
######################################################################################################
|
||||||
# Victron VRM API Forecast Data
|
# Victron VRM API Forecast Data
|
||||||
# https://vrm-api-docs.victronenergy.com/#/
|
# https://vrm-api-docs.victronenergy.com/#/
|
||||||
# https://vrmapi.victronenergy.com/v2/installations/<instalation id>/stats?type=forecast&interval=hours&start=<start date and time>&end=<end date and time>
|
# # API Beschreibung: https://vrm-api-docs.victronenergy.com/#/operations/installations/idSite/stats
|
||||||
################################################################################################
|
######################################################################################################
|
||||||
sub __VictronVRM_ApiRequestForecast {
|
sub __VictronVRM_ApiRequestForecast {
|
||||||
my $paref = shift;
|
my $paref = shift;
|
||||||
|
|
||||||
@ -3851,9 +3859,11 @@ sub __VictronVRM_ApiRequestForecast {
|
|||||||
my $debug = $paref->{debug};
|
my $debug = $paref->{debug};
|
||||||
my $lang = $paref->{lang};
|
my $lang = $paref->{lang};
|
||||||
my $idsite = $paref->{idsite};
|
my $idsite = $paref->{idsite};
|
||||||
|
my $chour = $paref->{chour}; # aktuelle Stunde in 24h format (00-23)
|
||||||
|
my $date = $paref->{date};
|
||||||
|
|
||||||
my $tstart = time;
|
my $tstart = timestringToTimestamp ("$date $chour:00:00");
|
||||||
my $tend = time + 259200; # 172800 = 2 Tage
|
my $tend = $tstart + 259200; # 172800 = 2 Tage
|
||||||
|
|
||||||
my $url = "https://vrmapi.victronenergy.com/v2/installations/$idsite/stats?type=forecast&interval=hours&start=$tstart&end=$tend";
|
my $url = "https://vrmapi.victronenergy.com/v2/installations/$idsite/stats?type=forecast&interval=hours&start=$tstart&end=$tend";
|
||||||
|
|
||||||
@ -3953,6 +3963,8 @@ sub __VictronVRM_ApiResponseForecast {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#debugLog ($paref, "apiProcess", "Victron VRM API - raw data received:\n". Dumper $jdata);
|
||||||
|
|
||||||
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{todayDoneAPIrequests} += 1;
|
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{todayDoneAPIrequests} += 1;
|
||||||
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{todayDoneAPIcalls} += 1;
|
$data{$type}{$name}{solcastapi}{'?All'}{'?All'}{todayDoneAPIcalls} += 1;
|
||||||
|
|
||||||
@ -3991,6 +4003,8 @@ sub __VictronVRM_ApiResponseForecast {
|
|||||||
my $val = $jdata->{'records'}{'vrm_consumption_fc'}[$k][1];
|
my $val = $jdata->{'records'}{'vrm_consumption_fc'}[$k][1];
|
||||||
$starttmstr = (timestampToTimestring ($starttmstr, $lang))[3];
|
$starttmstr = (timestampToTimestring ($starttmstr, $lang))[3];
|
||||||
|
|
||||||
|
debugLog ($paref, "apiProcess", "Victron VRM API - CO estimate: ".$starttmstr.' => '.$val.' Wh');
|
||||||
|
|
||||||
if ($val) {
|
if ($val) {
|
||||||
$val = sprintf "%.2f", $val;
|
$val = sprintf "%.2f", $val;
|
||||||
my $string = ReadingsVal ($name, 'inverterStrings', '?');
|
my $string = ReadingsVal ($name, 'inverterStrings', '?');
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user