Update WeatherAsHtml

- alle WeatherAsHtml-functionen auf $d, $items, $i gleichgestellt
- Abfrage in WeatherAsHtmlH, ob *fc(i)_low_c vorhanden, wenn nicht Verwendung von *fc(i)_temperature
- Erweiterung der Beispiels um Anzahl und daily/hourly-Angabe
This commit is contained in:
Lippie81 2019-03-05 20:24:24 +01:00 committed by GitHub
parent 3eaf8f6be5
commit a94030f9f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -764,10 +764,10 @@ sub WeatherAsHtmlV($;$$) {
return $ret; return $ret;
} }
sub WeatherAsHtml($;$) { sub WeatherAsHtml($;$$) {
my ( $d, $i ) = @_; my ( $d, $items, $i ) = @_;
WeatherAsHtmlV( $d, $i ); WeatherAsHtmlV( $d, $items, $i );
} }
sub WeatherAsHtmlH($;$$) { sub WeatherAsHtmlH($;$$) {
@ -832,8 +832,13 @@ sub WeatherAsHtmlH($;$$) {
ReadingsVal( $d, "humidity", "" ) ReadingsVal( $d, "humidity", "" )
); );
for ( my $i = 1 ; $i < $items ; $i++ ) { for ( my $i = 1 ; $i < $items ; $i++ ) {
$ret .= sprintf( '<td class="weatherMin">min %s°C</td>', if(defined($h->{READINGS}->{"${fc}${i}_low_c"}) and $h->{READINGS}->{"${fc}${i}_low_c"}){
ReadingsVal( $d, "${fc}${i}_low_c", " - " ) ); $ret .= sprintf( '<td class="weatherMin">min %s°C</td>',
ReadingsVal( $d, "${fc}${i}_low_c", " - " ) );
}else{
$ret .= sprintf( '<td class="weatherMin"> %s°C</td>',
ReadingsVal( $d, "${fc}${i}_temperature", " - " ) );
}
} }
$ret .= '</tr>'; $ret .= '</tr>';
@ -841,22 +846,24 @@ sub WeatherAsHtmlH($;$$) {
$ret .= sprintf( '<tr><td class="weatherMax">%s</td>', $ret .= sprintf( '<tr><td class="weatherMax">%s</td>',
ReadingsVal( $d, "wind_condition", "" ) ); ReadingsVal( $d, "wind_condition", "" ) );
for ( my $i = 1 ; $i < $items ; $i++ ) { for ( my $i = 1 ; $i < $items ; $i++ ) {
$ret .= sprintf( '<td class="weatherMax">max %s°C</td>', if(defined($h->{READINGS}->{"${fc}${i}_high_c"}) and $h->{READINGS}->{"${fc}${i}_high_c"}){
ReadingsVal( $d, "${fc}${i}_high_c", " - " ) ); $ret .= sprintf( '<td class="weatherMax">max %s°C</td>',
ReadingsVal( $d, "${fc}${i}_high_c", " - " ) );
}
} }
$ret .= "</tr></table>"; $ret .= "</tr></table>";
return $ret; return $ret;
} }
sub WeatherAsHtmlD($;$) { sub WeatherAsHtmlD($;$$) {
my ( $d, $i ) = @_; my ( $d, $items, $i ) = @_;
if ($FW_ss) { if ($FW_ss) {
WeatherAsHtmlV( $d, $i ); WeatherAsHtmlV( $d, $items, $i );
} }
else { else {
WeatherAsHtmlH( $d, $i ); WeatherAsHtmlH( $d, $items, $i );
} }
} }
@ -957,7 +964,7 @@ sub WeatherAsHtmlD($;$) {
to limit the numer of icons to display.<br><br> to limit the numer of icons to display.<br><br>
Example: Example:
<pre> <pre>
define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") } define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather",10,"h") }
</pre> </pre>
@ -1130,7 +1137,7 @@ sub WeatherAsHtmlD($;$) {
Wird der dritte Parameter verwendet muss auch der zweite Parameter f&uuml;r die Anzahl der darzustellenden Icons gesetzt werden.<br><br> Wird der dritte Parameter verwendet muss auch der zweite Parameter f&uuml;r die Anzahl der darzustellenden Icons gesetzt werden.<br><br>
Beispiel: Beispiel:
<pre> <pre>
define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather") } define MyWeatherWeblink weblink htmlCode { WeatherAsHtmlH("MyWeather",10,"h") }
</pre> </pre>
</ul> </ul>