mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
HOMESTATEtk: add phenological season
git-svn-id: https://svn.fhem.de/fhem/trunk@19391 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
22fe86c0c9
commit
361287e4ee
@ -5,6 +5,8 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
#use Unit;
|
||||||
|
#use RESIDENTStk;
|
||||||
require RESIDENTStk;
|
require RESIDENTStk;
|
||||||
our ( %RESIDENTStk_types, %RESIDENTStk_subTypes );
|
our ( %RESIDENTStk_types, %RESIDENTStk_subTypes );
|
||||||
|
|
||||||
@ -50,6 +52,7 @@ my %readingsMap = (
|
|||||||
seasonAstro_long => 'calTodSAstro',
|
seasonAstro_long => 'calTodSAstro',
|
||||||
seasonMeteoChng => 'calTodSMeteoChng',
|
seasonMeteoChng => 'calTodSMeteoChng',
|
||||||
seasonMeteo_long => 'calTodSMeteo',
|
seasonMeteo_long => 'calTodSMeteo',
|
||||||
|
seasonPhenoChng => 'calTodSPhenoChng',
|
||||||
seasonPheno_long => 'calTodSPheno',
|
seasonPheno_long => 'calTodSPheno',
|
||||||
sunrise => 'calTodSunrise',
|
sunrise => 'calTodSunrise',
|
||||||
sunset => 'calTodSunset',
|
sunset => 'calTodSunset',
|
||||||
@ -86,7 +89,8 @@ my %readingsMap_tom = (
|
|||||||
seasonAstro_long => 'calTomSAstro',
|
seasonAstro_long => 'calTomSAstro',
|
||||||
seasonMeteoChng => 'calTomSMeteoChng',
|
seasonMeteoChng => 'calTomSMeteoChng',
|
||||||
seasonMeteo_long => 'calTomSMeteo',
|
seasonMeteo_long => 'calTomSMeteo',
|
||||||
seasonPheno_long => 'calTodSPheno',
|
seasonPhenoChng => 'calTomSPhenoChng',
|
||||||
|
seasonPheno_long => 'calTomSPheno',
|
||||||
sunrise => 'calTomSunrise',
|
sunrise => 'calTomSunrise',
|
||||||
sunset => 'calTomSunset',
|
sunset => 'calTomSunset',
|
||||||
wdaynISO => 'calTomWeekdayN',
|
wdaynISO => 'calTomWeekdayN',
|
||||||
@ -183,14 +187,14 @@ sub HOMESTATEtk_InitializeDev($) {
|
|||||||
|
|
||||||
foreach ( sort keys %{ $hash->{'.t'} } ) {
|
foreach ( sort keys %{ $hash->{'.t'} } ) {
|
||||||
next if ( ref( $hash->{'.t'}{$_} ) );
|
next if ( ref( $hash->{'.t'}{$_} ) );
|
||||||
my $r = $readingsMap{$_} ? $readingsMap{$_} : undef;
|
my $r = defined( $readingsMap{$_} ) ? $readingsMap{$_} : undef;
|
||||||
my $v = $hash->{'.t'}{$_};
|
my $v = $hash->{'.t'}{$_};
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
||||||
if ( defined($r) );
|
if ( defined($r) );
|
||||||
|
|
||||||
$r = $readingsMap_tom{$_} ? $readingsMap_tom{$_} : undef;
|
$r = defined( $readingsMap_tom{$_} ) ? $readingsMap_tom{$_} : undef;
|
||||||
$v = $hash->{'.t'}{1}{$_} ? $hash->{'.t'}{1}{$_} : undef;
|
$v = defined( $hash->{'.t'}{1}{$_} ) ? $hash->{'.t'}{1}{$_} : undef;
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
||||||
if ( defined($r) && defined($v) );
|
if ( defined($r) && defined($v) );
|
||||||
@ -199,16 +203,23 @@ sub HOMESTATEtk_InitializeDev($) {
|
|||||||
unless ( $lang =~ /^en/i || !$hash->{'.t'}{$lang} ) {
|
unless ( $lang =~ /^en/i || !$hash->{'.t'}{$lang} ) {
|
||||||
foreach ( sort keys %{ $hash->{'.t'}{$lang} } ) {
|
foreach ( sort keys %{ $hash->{'.t'}{$lang} } ) {
|
||||||
next if ( ref( $hash->{'.t'}{$lang}{$_} ) );
|
next if ( ref( $hash->{'.t'}{$lang}{$_} ) );
|
||||||
my $r = $readingsMap{$_} ? $readingsMap{$_} . "_$langUc" : undef;
|
my $r =
|
||||||
|
defined( $readingsMap{$_} )
|
||||||
|
? $readingsMap{$_} . "_$langUc"
|
||||||
|
: undef;
|
||||||
my $v = $hash->{'.t'}{$lang}{$_};
|
my $v = $hash->{'.t'}{$lang}{$_};
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
||||||
if ( defined($r) );
|
if ( defined($r) );
|
||||||
|
|
||||||
$r =
|
$r =
|
||||||
$readingsMap_tom{$_} ? $readingsMap_tom{$_} . "_$langUc" : undef;
|
defined( $readingsMap_tom{$_} )
|
||||||
|
? $readingsMap_tom{$_} . "_$langUc"
|
||||||
|
: undef;
|
||||||
$v =
|
$v =
|
||||||
$hash->{'.t'}{1}{$lang}{$_} ? $hash->{'.t'}{1}{$lang}{$_} : undef;
|
defined( $hash->{'.t'}{1}{$lang}{$_} )
|
||||||
|
? $hash->{'.t'}{1}{$lang}{$_}
|
||||||
|
: undef;
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
readingsBulkUpdateIfChanged( $hash, $r, $v )
|
||||||
if ( defined($r) && defined($v) );
|
if ( defined($r) && defined($v) );
|
||||||
@ -410,7 +421,8 @@ sub HOMESTATEtk_Set($$$) {
|
|||||||
|
|
||||||
# usage: mode
|
# usage: mode
|
||||||
my $i =
|
my $i =
|
||||||
$autoMode && ReadingsVal( $name, "daytime", "night" ) ne "night"
|
defined($autoMode)
|
||||||
|
&& ReadingsVal( $name, "daytime", "night" ) ne "night"
|
||||||
? HOMESTATEtk_GetIndexFromArray( ReadingsVal( $name, "daytime", 0 ),
|
? HOMESTATEtk_GetIndexFromArray( ReadingsVal( $name, "daytime", 0 ),
|
||||||
$UConv::daytimes{en} )
|
$UConv::daytimes{en} )
|
||||||
: 0;
|
: 0;
|
||||||
@ -967,7 +979,7 @@ sub HOMESTATEtk_GetIndexFromArray($$) {
|
|||||||
my ( $string, $array ) = @_;
|
my ( $string, $array ) = @_;
|
||||||
return undef unless ( ref($array) eq "ARRAY" );
|
return undef unless ( ref($array) eq "ARRAY" );
|
||||||
my ($index) = grep { $array->[$_] =~ /^$string$/i } ( 0 .. @$array - 1 );
|
my ($index) = grep { $array->[$_] =~ /^$string$/i } ( 0 .. @$array - 1 );
|
||||||
return defined $index ? $index : undef;
|
return defined($index) ? $index : undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HOMESTATEtk_findHomestateSlaves($;$) {
|
sub HOMESTATEtk_findHomestateSlaves($;$) {
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# $Id$
|
# $Id$
|
||||||
package main;
|
package main;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
#use FHEM::Meta;
|
||||||
sub UConv_Initialize() { }
|
sub UConv_Initialize() { }
|
||||||
|
|
||||||
package UConv;
|
package UConv;
|
||||||
@ -8,6 +13,10 @@ use Scalar::Util qw(looks_like_number);
|
|||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
sub GetSeason (;$$$);
|
||||||
|
sub GetSeasonPheno ($$;$);
|
||||||
|
sub _ReplaceStringByHashKey($$;$);
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Translations
|
# Translations
|
||||||
|
|
||||||
@ -132,6 +141,17 @@ our %daytimes = (
|
|||||||
"Morgen", "Vormittag", "Mittag", "Nachmittag",
|
"Morgen", "Vormittag", "Mittag", "Nachmittag",
|
||||||
"Vorabend", "Abend", "Nacht",
|
"Vorabend", "Abend", "Nacht",
|
||||||
],
|
],
|
||||||
|
nl => [
|
||||||
|
"Ochtend", "Vormiddag", "Middag", "Nachmiddag",
|
||||||
|
"Avond", "Midavond", "Nacht",
|
||||||
|
],
|
||||||
|
fr => [
|
||||||
|
"Matin", "Martinée", "Midi", "Après-midi", "Veille", "Soir", "Nuit",
|
||||||
|
],
|
||||||
|
pl => [
|
||||||
|
"Ranek", "Rano", "Południe", "Popołudnie",
|
||||||
|
"Wigilia", "Wieczór", "Noc",
|
||||||
|
],
|
||||||
icons => [
|
icons => [
|
||||||
"weather_sunrise", "scene_day",
|
"weather_sunrise", "scene_day",
|
||||||
"weather_sun", "weather_summer",
|
"weather_sun", "weather_summer",
|
||||||
@ -245,20 +265,23 @@ our %sdt2daytimes = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
our %seasons = (
|
our %seasons = (
|
||||||
en => [ "Spring", "Summer", "Autumn", "Winter", ],
|
en => [ "Spring", "Summer", "Autumn", "Winter", ],
|
||||||
de => [ "Frühling", "Sommer", "Herbst", "Winter", ],
|
de => [ "Frühling", "Sommer", "Herbst", "Winter", ],
|
||||||
pheno => [ 2, 4, 7, 9 ],
|
nl => [ "Voorjaar", "Zomer", "Herfst", "Winter", ],
|
||||||
|
fr => [ "Printemps", "Été", "Automne", "Hiver", ],
|
||||||
|
pl => [ "Wiosna", "Lato", "Jesień", "Zima", ],
|
||||||
|
pheno => [ 2, 4, 7, 9 ],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %seasonsPheno = (
|
our %seasonsPheno = (
|
||||||
en => [
|
en => [
|
||||||
"Early Spring",
|
"Early Spring",
|
||||||
"First Spring",
|
"First Spring",
|
||||||
"Spring",
|
"Full Spring",
|
||||||
"Early Summer",
|
"Early Summer",
|
||||||
"Summer",
|
"Midsummer",
|
||||||
"Late Summer",
|
"Late Summer",
|
||||||
"Early Autumn",
|
"Early Fall",
|
||||||
"Autumn",
|
"Autumn",
|
||||||
"Late Autumn",
|
"Late Autumn",
|
||||||
"Winter",
|
"Winter",
|
||||||
@ -268,21 +291,66 @@ our %seasonsPheno = (
|
|||||||
"Hochsommer", "Spätsommer", "Frühherbst", "Vollherbst",
|
"Hochsommer", "Spätsommer", "Frühherbst", "Vollherbst",
|
||||||
"Spätherbst", "Winter",
|
"Spätherbst", "Winter",
|
||||||
],
|
],
|
||||||
|
nl => [
|
||||||
|
"Vroeg Voorjaar",
|
||||||
|
"Eerste Voorjaar",
|
||||||
|
"Voorjaar",
|
||||||
|
"Vroeg Zomer",
|
||||||
|
"Zomer",
|
||||||
|
"Laat Zomer",
|
||||||
|
"Vroeg Herfst",
|
||||||
|
"Herfst",
|
||||||
|
"Laat Herfst",
|
||||||
|
"Winter",
|
||||||
|
],
|
||||||
|
fr => [
|
||||||
|
"Avant du printemps",
|
||||||
|
"Début du printemps",
|
||||||
|
"Printemps",
|
||||||
|
"Avant de l'été",
|
||||||
|
"Milieu de l'été",
|
||||||
|
"Fin de l'été",
|
||||||
|
"Avant de l'automne",
|
||||||
|
"Automne",
|
||||||
|
"Fin de l'automne",
|
||||||
|
"Hiver",
|
||||||
|
],
|
||||||
|
pl => [
|
||||||
|
"Przedwiośnie",
|
||||||
|
"Pierwsza Wiosna",
|
||||||
|
"Wiosna",
|
||||||
|
"Wczesne Lato",
|
||||||
|
"Połowa Lata",
|
||||||
|
"Późnym Latem",
|
||||||
|
"Wczesną Jesienią",
|
||||||
|
"Jesień",
|
||||||
|
"Późną Jesienią",
|
||||||
|
"Zima",
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %dst = (
|
our %dst = (
|
||||||
en => [ "standard", "daylight" ],
|
en => [ "standard", "daylight" ],
|
||||||
de => [ "Normalzeit", "Sommerzeit" ],
|
de => [ "Normalzeit", "Sommerzeit" ],
|
||||||
|
nl => [ "Standaardtijd", "Zomertijd" ],
|
||||||
|
fr => [ "Heure normale", "L'heure d'été" ],
|
||||||
|
pl => [ "Standardowy czas", "Czas Letni" ],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %daystages = (
|
our %daystages = (
|
||||||
en => [ "weekday", "weekend", "holiday", "vacation", ],
|
en => [ "weekday", "weekend", "holiday", "vacation", ],
|
||||||
de => [ "Wochentag", "Wochenende", "Feiertag", "Urlaubstag", ],
|
de => [ "Wochentag", "Wochenende", "Feiertag", "Urlaubstag", ],
|
||||||
|
nl => [ "Weekdag", "Weekend", "Vieringsdag", "Vakantiedag", ],
|
||||||
|
fr => [ "Jour de la semaine", "Weekend", "Vacances", "Villégiature", ],
|
||||||
|
pl => [ "dzień powszedni", "Weekend", "święto", "Wakacjach", ],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %reldays = (
|
our %reldays = (
|
||||||
en => [ "yesterday", "today", "tomorrow" ],
|
en => [ "yesterday", "today", "tomorrow" ],
|
||||||
de => [ "Gestern", "Heute", "Morgen" ],
|
de => [ "gestern", "heute", "morgen" ],
|
||||||
|
nl => [ "gisteren", "vandaag", "morgen" ],
|
||||||
|
fr => [ "hier", "aujourd'hui", "demain" ],
|
||||||
|
pl => [ "wczoraj", "dzisiaj", "jutro" ],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %monthss = (
|
our %monthss = (
|
||||||
@ -294,6 +362,18 @@ our %monthss = (
|
|||||||
"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug",
|
"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug",
|
||||||
"Sep", "Okt", "Nov", "Dez", "Jan"
|
"Sep", "Okt", "Nov", "Dez", "Jan"
|
||||||
],
|
],
|
||||||
|
nl => [
|
||||||
|
"Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug",
|
||||||
|
"Sep", "Okt", "Nov", "Dec", "Jan"
|
||||||
|
],
|
||||||
|
fr => [
|
||||||
|
"Jan", "Fév", "Mar", "Avr", "Mai", "Jun", "Jul", "Aût",
|
||||||
|
"Sep", "Oct", "Nov", "Dec", "Jan"
|
||||||
|
],
|
||||||
|
pl => [
|
||||||
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
|
||||||
|
"Sep", "Oct", "Nov", "Dec", "Jan"
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %months = (
|
our %months = (
|
||||||
@ -309,11 +389,32 @@ our %months = (
|
|||||||
"September", "Oktober", "November", "Dezember",
|
"September", "Oktober", "November", "Dezember",
|
||||||
"Januar"
|
"Januar"
|
||||||
],
|
],
|
||||||
|
nl => [
|
||||||
|
"Januari", "Februari", "Maart", "April",
|
||||||
|
"Mei", "Juni", "Juli", "Augustus",
|
||||||
|
"September", "Oktober", "November", "December",
|
||||||
|
"Januari"
|
||||||
|
],
|
||||||
|
fr => [
|
||||||
|
"Janvier", "Février", "Mars", "Avril",
|
||||||
|
"Mai", "Juin", "Juillet", "Août",
|
||||||
|
"Septembre", "Octobre", "Novembre", "Décembre",
|
||||||
|
"Janvier"
|
||||||
|
],
|
||||||
|
pl => [
|
||||||
|
"Styczeń", "Luty", "Marzec", "Kwiecień",
|
||||||
|
"Maj", "Czerwiec", "July", "Lipiec",
|
||||||
|
"Wrzesień", "Październik", "Listopad", "Grudzień",
|
||||||
|
"Styczeń"
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %dayss = (
|
our %dayss = (
|
||||||
en => [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ],
|
en => [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ],
|
||||||
de => [ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ],
|
de => [ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ],
|
||||||
|
nl => [ "Zon", "Maa", "Din", "Woe", "Don", "Vri", "Zat", "Zon" ],
|
||||||
|
fr => [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim" ],
|
||||||
|
pl => [ "Nie", "Pon", "Wto", "śro", "Czw", "Pią", "Sob", "Nie" ],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %days = (
|
our %days = (
|
||||||
@ -325,16 +426,34 @@ our %days = (
|
|||||||
"Sonntag", "Montag", "Dienstag", "Mittwoch",
|
"Sonntag", "Montag", "Dienstag", "Mittwoch",
|
||||||
"Donnerstag", "Freitag", "Samstag", "Sonntag"
|
"Donnerstag", "Freitag", "Samstag", "Sonntag"
|
||||||
],
|
],
|
||||||
|
nl => [
|
||||||
|
"Zondag", "Maandag", "Dinsdag", "Woensdag",
|
||||||
|
"Donderdag", "Vrijdag", "Zaterdag", "Zondag"
|
||||||
|
],
|
||||||
|
fr => [
|
||||||
|
"Dimanche", "Lundi", "Mardi", "Mercredi",
|
||||||
|
"Jeudi", "Vendredi", "Samedi", "Dimanche"
|
||||||
|
],
|
||||||
|
pl => [
|
||||||
|
"Niedziela", "Poniedziałek", "Wtorek", "środa",
|
||||||
|
"Czwartek", "Piątek", "Sobota", "Niedziela"
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
our %dateformats = (
|
our %dateformats = (
|
||||||
en => '%wday_long%, %mon_long% %mday%',
|
en => '%wday_long%, %mon_long% %mday%',
|
||||||
de => '%wday_long%, %mday%. %mon_long%',
|
de => '%wday_long%, %mday%. %mon_long%',
|
||||||
|
nl => '%wday_long%, %mday%. %mon_long%',
|
||||||
|
fr => '%wday_long%, %mday%. %mon_long%',
|
||||||
|
pl => '%wday_long%, %mday%. %mon_long%',
|
||||||
);
|
);
|
||||||
|
|
||||||
our %dateformatss = (
|
our %dateformatss = (
|
||||||
en => '%mon_long% %mday%',
|
en => '%mon_long% %mday%',
|
||||||
de => '%mday%. %mon_long%',
|
de => '%mday%. %mon_long%',
|
||||||
|
nl => '%mday%. %mon_long%',
|
||||||
|
fr => '%mday%. %mon_long%',
|
||||||
|
pl => '%mday%. %mon_long%',
|
||||||
);
|
);
|
||||||
|
|
||||||
# https://www.luftfeuchtigkeit-raumklima.de/tabelle.php
|
# https://www.luftfeuchtigkeit-raumklima.de/tabelle.php
|
||||||
@ -467,13 +586,19 @@ our %clima_rgb = (
|
|||||||
|
|
||||||
our %clima_names = (
|
our %clima_names = (
|
||||||
c => {
|
c => {
|
||||||
en => [ "freeze", "cold", "low", "ideal", "high", "hot" ],
|
en => [ "freeze", "cold", "low", "ideal", "high", "hot" ],
|
||||||
de => [ "frostig", "kalt", "niedrig", "optimal", "hoch", "heiß" ],
|
de => [ "frostig", "kalt", "niedrig", "optimal", "hoch", "heiß" ],
|
||||||
|
nl => [ "kil", "koude", "laag", "optimale", "hoog", "heet" ],
|
||||||
|
fr => [ "froid", "froid", "faible", "optimal", "haut", "chaud" ],
|
||||||
|
pl =>
|
||||||
|
[ "chłodny", "zimno", "niski", "optymalny", "wysoki", "gorący" ],
|
||||||
},
|
},
|
||||||
h => {
|
h => {
|
||||||
en => [ "dry", "low", "ideal", "high", "wet" ],
|
en => [ "dry", "low", "ideal", "high", "wet" ],
|
||||||
de => [ "trocken", "niedrig", "optimal", "hoch", "nass" ],
|
de => [ "trocken", "niedrig", "optimal", "hoch", "nass" ],
|
||||||
|
nl => [ "droog", "laag", "optimale", "hoog", "nat" ],
|
||||||
|
fr => [ "sec", "faible", "optimal", "haut", "humide" ],
|
||||||
|
pl => [ "suchy", "niski", "optymalny", "wysoki", "mokro" ],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1345,8 +1470,8 @@ sub GetDaytime(;$$$$) {
|
|||||||
|
|
||||||
# include season data
|
# include season data
|
||||||
$ret = GetSeason( $ret, $lang );
|
$ret = GetSeason( $ret, $lang );
|
||||||
|
$ret = GetSeasonPheno( $ret, $lang );
|
||||||
|
|
||||||
#$ret = GetSeasonPheno( $ret, $lang );
|
|
||||||
#$ret = GetSeasonSocial( $ret, $lang ); #TODO https://de.wikipedia.org/wiki/F%C3%BCnfte_Jahreszeit
|
#$ret = GetSeasonSocial( $ret, $lang ); #TODO https://de.wikipedia.org/wiki/F%C3%BCnfte_Jahreszeit
|
||||||
|
|
||||||
# change midnight event when season changes
|
# change midnight event when season changes
|
||||||
@ -1360,6 +1485,11 @@ sub GetDaytime(;$$$$) {
|
|||||||
$ret->{events}{ $ret->{midnight_t} }{DESC} .=
|
$ret->{events}{ $ret->{midnight_t} }{DESC} .=
|
||||||
", Begin astronomical $ret->{seasonAstro_long} season"
|
", Begin astronomical $ret->{seasonAstro_long} season"
|
||||||
if ( $ret->{seasonAstroChng} && $ret->{seasonAstroChng} == 1 );
|
if ( $ret->{seasonAstroChng} && $ret->{seasonAstroChng} == 1 );
|
||||||
|
$ret->{events}{ $ret->{midnight_t} }{VALUE} = 2
|
||||||
|
if ( $ret->{seasonPhenoChng} && $ret->{seasonPhenoChng} == 1 );
|
||||||
|
$ret->{events}{ $ret->{midnight_t} }{DESC} .=
|
||||||
|
", Begin phenological season $ret->{seasonPheno_long}"
|
||||||
|
if ( $ret->{seasonPhenoChng} && $ret->{seasonPhenoChng} == 1 );
|
||||||
|
|
||||||
# calculate daytime from daytimeStage, season and DST
|
# calculate daytime from daytimeStage, season and DST
|
||||||
my $ds = $ret->{daytimeStage};
|
my $ds = $ret->{daytimeStage};
|
||||||
@ -1491,8 +1621,6 @@ sub GetDaytime(;$$$$) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub GetSeason (;$$$);
|
|
||||||
|
|
||||||
sub GetSeason (;$$$) {
|
sub GetSeason (;$$$) {
|
||||||
my ( $time, $lang, $meteo ) = @_;
|
my ( $time, $lang, $meteo ) = @_;
|
||||||
$lang = (
|
$lang = (
|
||||||
@ -1544,12 +1672,12 @@ sub GetSeason (;$$$) {
|
|||||||
$index++ if ( $ret->{yday} >= ( 356 + $ret->{isly} ) );
|
$index++ if ( $ret->{yday} >= ( 356 + $ret->{isly} ) );
|
||||||
$ret->{seasonAstro} = $index;
|
$ret->{seasonAstro} = $index;
|
||||||
|
|
||||||
unless (wantarray) {
|
return ( $ret->{seasonMeteo}, $ret->{seasonAstro} ) if (wantarray);
|
||||||
( $ret->{'-1'}{seasonMeteo}, $ret->{'-1'}{seasonAstro} ) =
|
|
||||||
GetSeason( $ret->{'-1'}{time_t}, $lang );
|
( $ret->{'-1'}{seasonMeteo}, $ret->{'-1'}{seasonAstro} ) =
|
||||||
( $ret->{1}{seasonMeteo}, $ret->{1}{seasonAstro} ) =
|
GetSeason( $ret->{'-1'}{time_t}, $lang );
|
||||||
GetSeason( $ret->{1}{time_t}, $lang );
|
( $ret->{1}{seasonMeteo}, $ret->{1}{seasonAstro} ) =
|
||||||
}
|
GetSeason( $ret->{1}{time_t}, $lang );
|
||||||
|
|
||||||
# text strings
|
# text strings
|
||||||
my @langs = ('EN');
|
my @langs = ('EN');
|
||||||
@ -1558,52 +1686,53 @@ sub GetSeason (;$$$) {
|
|||||||
my $l = lc($_);
|
my $l = lc($_);
|
||||||
$l =~ s/^([a-z]+).*/$1/g;
|
$l =~ s/^([a-z]+).*/$1/g;
|
||||||
next unless ( $seasons{$l} );
|
next unless ( $seasons{$l} );
|
||||||
my $h = $l eq "en" ? $ret : \%{ $ret->{$_} };
|
|
||||||
|
|
||||||
$h->{seasonMeteo_long} = $seasons{$l}[ $ret->{seasonMeteo} ];
|
if ($l eq 'en') {
|
||||||
$h->{seasonAstro_long} = $seasons{$l}[ $ret->{seasonAstro} ];
|
$ret->{'-1'}{seasonMeteo_long} = $seasons{$l}[ $ret->{'-1'}{seasonMeteo} ];
|
||||||
|
$ret->{seasonMeteo_long} = $seasons{$l}[ $ret->{seasonMeteo} ];
|
||||||
|
$ret->{1}{seasonMeteo_long} = $seasons{$l}[ $ret->{1}{seasonMeteo} ];
|
||||||
|
|
||||||
|
$ret->{'-1'}{seasonAstro_long} = $seasons{$l}[ $ret->{'-1'}{seasonAstro} ];
|
||||||
|
$ret->{seasonAstro_long} = $seasons{$l}[ $ret->{seasonAstro} ];
|
||||||
|
$ret->{1}{seasonAstro_long} = $seasons{$l}[ $ret->{1}{seasonAstro} ];
|
||||||
|
} else {
|
||||||
|
$ret->{'-1'}{$l}{seasonMeteo_long} = $seasons{$l}[ $ret->{'-1'}{seasonMeteo} ];
|
||||||
|
$ret->{$l}{seasonMeteo_long} = $seasons{$l}[ $ret->{seasonMeteo} ];
|
||||||
|
$ret->{1}{$l}{seasonMeteo_long} = $seasons{$l}[ $ret->{1}{seasonMeteo} ];
|
||||||
|
|
||||||
|
$ret->{'-1'}{$l}{seasonAstro_long} = $seasons{$l}[ $ret->{'-1'}{seasonAstro} ];
|
||||||
|
$ret->{$l}{seasonAstro_long} = $seasons{$l}[ $ret->{seasonAstro} ];
|
||||||
|
$ret->{1}{$l}{seasonAstro_long} = $seasons{$l}[ $ret->{1}{seasonAstro} ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ret->{'-1'}{seasonMeteoChng} = 0;
|
||||||
|
$ret->{seasonMeteoChng} = 0;
|
||||||
|
$ret->{1}{seasonMeteoChng} = 0;
|
||||||
|
|
||||||
if ( $ret->{seasonMeteo} ne $ret->{1}{seasonMeteo} ) {
|
if ( $ret->{seasonMeteo} ne $ret->{1}{seasonMeteo} ) {
|
||||||
$ret->{seasonMeteoChng} = 2;
|
$ret->{seasonMeteoChng} = 2;
|
||||||
|
$ret->{1}{seasonMeteoChng} = 1;
|
||||||
|
}
|
||||||
|
elsif ( $ret->{seasonMeteo} ne $ret->{'-1'}{seasonMeteo} ) {
|
||||||
|
$ret->{'-1'}{seasonMeteoChng} = 2;
|
||||||
|
$ret->{seasonMeteoChng} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $ret->{'-1'}
|
$ret->{'-1'}{seasonAstroChng} = 0;
|
||||||
&& defined( $ret->{'-1'}{seasonMeteo} )
|
$ret->{seasonAstroChng} = 0;
|
||||||
&& defined( $ret->{'-1'}{seasonAstro} )
|
$ret->{1}{seasonAstroChng} = 0;
|
||||||
&& $ret->{1}
|
|
||||||
&& defined( $ret->{1}{seasonMeteo} )
|
|
||||||
&& defined( $ret->{1}{seasonAstro} ) )
|
|
||||||
{
|
|
||||||
$ret->{'-1'}{seasonMeteoChng} = 0;
|
|
||||||
$ret->{seasonMeteoChng} = 0;
|
|
||||||
$ret->{1}{seasonMeteoChng} = 0;
|
|
||||||
|
|
||||||
if ( $ret->{seasonMeteo} ne $ret->{1}{seasonMeteo} ) {
|
if ( $ret->{seasonAstro} ne $ret->{1}{seasonAstro} ) {
|
||||||
$ret->{seasonMeteoChng} = 2;
|
$ret->{seasonAstroChng} = 2;
|
||||||
$ret->{1}{seasonMeteoChng} = 1;
|
$ret->{1}{seasonAstroChng} = 1;
|
||||||
}
|
}
|
||||||
elsif ( $ret->{seasonMeteo} ne $ret->{'-1'}{seasonMeteo} ) {
|
elsif ( $ret->{seasonAstro} ne $ret->{'-1'}{seasonAstro} ) {
|
||||||
$ret->{'-1'}{seasonMeteoChng} = 2;
|
$ret->{'-1'}{seasonAstroChng} = 2;
|
||||||
$ret->{seasonMeteoChng} = 1;
|
$ret->{seasonAstroChng} = 1;
|
||||||
}
|
|
||||||
|
|
||||||
$ret->{'-1'}{seasonAstroChng} = 0;
|
|
||||||
$ret->{seasonAstroChng} = 0;
|
|
||||||
$ret->{1}{seasonAstroChng} = 0;
|
|
||||||
|
|
||||||
if ( $ret->{seasonAstro} ne $ret->{1}{seasonAstro} ) {
|
|
||||||
$ret->{seasonAstroChng} = 2;
|
|
||||||
$ret->{1}{seasonAstroChng} = 1;
|
|
||||||
}
|
|
||||||
elsif ( $ret->{seasonAstro} ne $ret->{'-1'}{seasonAstro} ) {
|
|
||||||
$ret->{'-1'}{seasonAstroChng} = 2;
|
|
||||||
$ret->{seasonAstroChng} = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret if ($wanthash);
|
return $ret if ($wanthash);
|
||||||
return ( $ret->{seasonMeteo}, $ret->{seasonAstro} ) if (wantarray);
|
|
||||||
return $ret->{$lang}{seasonMeteo_long}
|
return $ret->{$lang}{seasonMeteo_long}
|
||||||
? $ret->{$lang}{seasonMeteo_long}
|
? $ret->{$lang}{seasonMeteo_long}
|
||||||
: $ret->{seasonMeteo_long}
|
: $ret->{seasonMeteo_long}
|
||||||
@ -1615,66 +1744,45 @@ sub GetSeason (;$$$) {
|
|||||||
|
|
||||||
# Estimate phenologic season from astro and meteo season
|
# Estimate phenologic season from astro and meteo season
|
||||||
# https://de.wikipedia.org/wiki/Ph%C3%A4nologie#Ph.C3.A4nologischer_Kalender
|
# https://de.wikipedia.org/wiki/Ph%C3%A4nologie#Ph.C3.A4nologischer_Kalender
|
||||||
sub GetSeasonPheno (;$$) {
|
sub GetSeasonPheno ($$;$) {
|
||||||
|
my ( $time, $lang, $ret2 ) = @_;
|
||||||
$lang = (
|
$lang = (
|
||||||
$main::attr{global}{language}
|
$main::attr{global}{language}
|
||||||
? $main::attr{global}{language}
|
? $main::attr{global}{language}
|
||||||
: "EN"
|
: "EN"
|
||||||
) unless ($lang);
|
) unless ($lang);
|
||||||
|
|
||||||
if ( !$time ) {
|
my $ret;
|
||||||
$time = time;
|
|
||||||
}
|
|
||||||
elsif ( $time =~ /^(?:0|1|2|3|4|5|6|7|8|9|10|11)$/ ) {
|
|
||||||
return $seasonsPheno{ lc($lang) }
|
|
||||||
? $seasonsPheno{ lc($lang) }[$time]
|
|
||||||
: $seasonsPheno{en}[$time];
|
|
||||||
}
|
|
||||||
elsif ( $time =~ /[A-Za-z]/ ) {
|
|
||||||
my $index =
|
|
||||||
$seasonsPheno{ lc($lang) }
|
|
||||||
? _GetIndexFromArray( $time, $seasonsPheno{ lc($lang) } )
|
|
||||||
: undef;
|
|
||||||
return $index;
|
|
||||||
}
|
|
||||||
elsif ( $time !~ /^\d{10}(?:\.\d+)?$/ ) {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
my (
|
if ( ref($time) eq "HASH" ) {
|
||||||
$sec, $min, $hour,
|
$ret = $time;
|
||||||
$mday, $mdayrem, $month,
|
}
|
||||||
$monthISO, $year, $week,
|
else {
|
||||||
$weekISO, $wday, $wdayISO,
|
$ret = _time($time);
|
||||||
$yday, $ydayrem, $isdst,
|
$ret->{seasonAstro} = $ret2->{seasonAstro};
|
||||||
$isLeapYear, $iswe, $isHolidayYesterday,
|
$ret->{seasonMeteo} = $ret2->{seasonMeteo};
|
||||||
$isHolidayToday, $isHolidayTomorrow
|
}
|
||||||
) = GetDaySchedule($time);
|
|
||||||
|
|
||||||
my ( $seasonAstro, $seasonAstroIndex, $seasonAstroChng ) = GetSeason($time);
|
|
||||||
my ( $seasonMeteo, $seasonMeteoIndex, $seasonMeteoChng ) =
|
|
||||||
GetSeason( $time, "en", 1 );
|
|
||||||
|
|
||||||
# stick to astro season first
|
# stick to astro season first
|
||||||
my $index = $seasons{pheno}[$seasonAstro];
|
my $index = $seasons{pheno}[ $ret->{seasonAstro} ];
|
||||||
|
|
||||||
# meteos say it's spring time
|
# meteos say it's spring time
|
||||||
if ( $seasonMeteo == 0 ) {
|
if ( $ret->{seasonMeteo} == 0 ) {
|
||||||
$index = 0;
|
$index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# meteos say it's summer time
|
# meteos say it's summer time
|
||||||
elsif ( $seasonMeteo == 1 ) {
|
elsif ( $ret->{seasonMeteo} == 1 ) {
|
||||||
$index = 3;
|
$index = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
# meteos say it's autumn time
|
# meteos say it's autumn time
|
||||||
elsif ( $seasonMeteo == 2 ) {
|
elsif ( $ret->{seasonMeteo} == 2 ) {
|
||||||
$index = 6;
|
$index = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
# meteos say it's winter time
|
# meteos say it's winter time
|
||||||
elsif ( $seasonMeteo == 3 ) {
|
elsif ( $ret->{seasonMeteo} == 3 ) {
|
||||||
$index = 9;
|
$index = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1691,7 +1799,8 @@ sub GetSeasonPheno (;$$) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
# TODO: let begin of early spring be set by user
|
# TODO: let begin of early spring be set by user
|
||||||
my $earlySpringBegin = main::time_str2num("$year-02-28 00:00:00");
|
my $earlySpringBegin =
|
||||||
|
main::time_str2num( $ret->{year} . '-02-28 00:00:00' );
|
||||||
my $days = ( $time - $earlySpringBegin ) / ( 60 * 60 * 24 );
|
my $days = ( $time - $earlySpringBegin ) / ( 60 * 60 * 24 );
|
||||||
|
|
||||||
# comes with 40km per day
|
# comes with 40km per day
|
||||||
@ -1710,14 +1819,14 @@ sub GetSeasonPheno (;$$) {
|
|||||||
|
|
||||||
# assume spring progress from calendar
|
# assume spring progress from calendar
|
||||||
elsif ( ( $index == 0 || $index == 1 ) ) {
|
elsif ( ( $index == 0 || $index == 1 ) ) {
|
||||||
$index = 1 if ( $monthISO == 4 );
|
$index = 1 if ( $ret->{monISO} == 4 );
|
||||||
$index = 2 if ( $monthISO == 5 );
|
$index = 2 if ( $ret->{monISO} == 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
# assume summer progress from calendar
|
# assume summer progress from calendar
|
||||||
elsif ( $index == 3 ) {
|
elsif ( $index == 3 ) {
|
||||||
$index = 4 if ( $monthISO == 7 );
|
$index = 4 if ( $ret->{monISO} == 7 );
|
||||||
$index = 5 if ( $monthISO == 8 );
|
$index = 5 if ( $ret->{monISO} == 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
# if we know our position and autumn is ahead
|
# if we know our position and autumn is ahead
|
||||||
@ -1733,7 +1842,8 @@ sub GetSeasonPheno (;$$) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
# TODO: let begin of early autumn be set by user
|
# TODO: let begin of early autumn be set by user
|
||||||
my $earlySpringBegin = main::time_str2num("$year-09-01 00:00:00");
|
my $earlySpringBegin =
|
||||||
|
main::time_str2num( $ret->{year} . '-09-01 00:00:00' );
|
||||||
my $days = ( $time - $earlySpringBegin ) / ( 60 * 60 * 24 );
|
my $days = ( $time - $earlySpringBegin ) / ( 60 * 60 * 24 );
|
||||||
|
|
||||||
# comes with 40km per day
|
# comes with 40km per day
|
||||||
@ -1752,18 +1862,51 @@ sub GetSeasonPheno (;$$) {
|
|||||||
|
|
||||||
# assume autumn progress from calendar
|
# assume autumn progress from calendar
|
||||||
elsif ( ( $index == 6 || $index == 7 ) ) {
|
elsif ( ( $index == 6 || $index == 7 ) ) {
|
||||||
$index = 7 if ( $monthISO == 10 );
|
$index = 7 if ( $ret->{monISO} == 10 );
|
||||||
$index = 8 if ( $monthISO == 11 );
|
$index = 8 if ( $ret->{monISO} == 11 );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $seasonPheno =
|
$ret->{seasonPheno} = $index;
|
||||||
defined($index)
|
return ( $ret->{seasonPheno} ) if (wantarray);
|
||||||
&& $index{ lc($lang) }
|
|
||||||
? $seasonsPheno{ lc($lang) }[$index]
|
|
||||||
: $seasonsPheno{en}[$index];
|
|
||||||
|
|
||||||
return ( $seasonPheno, $index ) if (wantarray);
|
( $ret->{'-1'}{seasonPheno} ) =
|
||||||
return ($seasonPheno);
|
GetSeasonPheno( $ret->{'-1'}{time_t}, $lang, $ret );
|
||||||
|
( $ret->{1}{seasonPheno} ) =
|
||||||
|
GetSeasonPheno( $ret->{1}{time_t}, $lang, $ret );
|
||||||
|
|
||||||
|
# text strings
|
||||||
|
my @langs = ('EN');
|
||||||
|
push @langs, $lang unless ( $lang =~ /^EN/i );
|
||||||
|
foreach (@langs) {
|
||||||
|
my $l = lc($_);
|
||||||
|
$l =~ s/^([a-z]+).*/$1/g;
|
||||||
|
next unless ( $seasonsPheno{$l} );
|
||||||
|
|
||||||
|
if ($l eq 'en') {
|
||||||
|
$ret->{'-1'}{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{'-1'}{seasonPheno} ];
|
||||||
|
$ret->{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{seasonPheno} ];
|
||||||
|
$ret->{1}{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{1}{seasonPheno} ];
|
||||||
|
} else {
|
||||||
|
$ret->{'-1'}{$l}{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{'-1'}{seasonPheno} ];
|
||||||
|
$ret->{$l}{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{seasonPheno} ];
|
||||||
|
$ret->{1}{$l}{seasonPheno_long} = $seasonsPheno{$l}[ $ret->{1}{seasonPheno} ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret->{'-1'}{seasonPhenoChng} = 0;
|
||||||
|
$ret->{seasonPhenoChng} = 0;
|
||||||
|
$ret->{1}{seasonPhenoChng} = 0;
|
||||||
|
|
||||||
|
if ( $ret->{seasonPheno} ne $ret->{1}{seasonPheno} ) {
|
||||||
|
$ret->{seasonPhenoChng} = 2;
|
||||||
|
$ret->{1}{seasonPhenoChng} = 1;
|
||||||
|
}
|
||||||
|
elsif ( $ret->{seasonPheno} ne $ret->{'-1'}{seasonPheno} ) {
|
||||||
|
$ret->{'-1'}{seasonPhenoChng} = 2;
|
||||||
|
$ret->{seasonPhenoChng} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################
|
####################
|
||||||
@ -1895,6 +2038,10 @@ sub _time(;$$$$) {
|
|||||||
&& main::IsDevice( $main::attr{global}{holiday2we}, "holiday" )
|
&& main::IsDevice( $main::attr{global}{holiday2we}, "holiday" )
|
||||||
? $main::attr{global}{holiday2we}
|
? $main::attr{global}{holiday2we}
|
||||||
: undef;
|
: undef;
|
||||||
|
|
||||||
|
my $tod;
|
||||||
|
my $ytd;
|
||||||
|
my $tom;
|
||||||
if ($holidayDev) {
|
if ($holidayDev) {
|
||||||
my $date = sprintf( "%02d-%02d", $ret{monISO}, $ret{mday} );
|
my $date = sprintf( "%02d-%02d", $ret{monISO}, $ret{mday} );
|
||||||
$tod = main::holiday_refresh( $holidayDev, $date );
|
$tod = main::holiday_refresh( $holidayDev, $date );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user