Der folgende patch korrigiert nicht nur die hartkodierte url, sondern schafft auch ein zusätzliches Attribut 'apiurl', mit dem bei künftigen Änderungen die interne url vom Anwender überschrieben werden kann. Damit kann die Wartezeit bis zu einer weiteren Moduländerung überbrückt werden.
Index: /opt/fhem/FHEM/59_GSI.pm
===================================================================
--- /opt/fhem/FHEM/59_GSI.pm (revision 27003)
+++ /opt/fhem/FHEM/59_GSI.pm (working copy)
@@ -39,7 +39,7 @@
$hash->{'UndefFn'} = 'GSI_Undef';
$hash->{'NotifyFn'} = 'GSI_Notify';
$hash->{'FW_detailFn'} = 'GSI_FW_detailFn';
- $hash->{'AttrList'} = "continuous:1,0 $readingFnAttributes ";
+ $hash->{'AttrList'} = "continuous:1,0 apiurl $readingFnAttributes ";
$hash->{'NOTIFYDEV'} = 'TYPE=Global';
return undef;
};
@@ -236,10 +236,13 @@
sub GSI_ApiRequest {
my ($hash) = @_;
- my $plz = $hash->{'ZIP'};
+ my $name = $hash->{'NAME'};
+ my $zip = $hash->{'ZIP'};
+ my $url = AttrVal($name,'apiurl',"https://api.corrently.io/v2.0/gsi/prediction?zip=").$zip;
+ Log3($hash,4,"GSI $name: $url");
my $param = {
'hash' => $hash,
- 'url' => "https://api.corrently.io/core/gsi?plz=$plz",
+ 'url' => $url,
'timeout' => 30,
'callback' => \&GSI_ApiResponse
};
@@ -722,6 +725,10 @@
<li>60..100: green</li>
</ul>
</li>
+ <a name="apiurl"></a>
+ <li>apiurl<br>
+ The internal API url can be overwritten by this attribute.
+ </li>
<a name="continuous"></a>
<li>continuous<br>
if set to 0 readings will be updated on hourly base. Otherwise readings will be continuously updated with interpolated values.