2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

11_OWC_CCC.pm: Versionsupdate, keine wesentlichen Änderungen

11_OWC_FRM.pm: Komplette Überarbeitung für neue Firmata-Version
11_OWC_SER.pm: Versionsupdate, keine wesentlichen Änderungen
11_OWC_TCP.pm: Versionsupdate, keine wesentlichen Änderungen
95_YAAHM.pm: Verbesserung im Handling von Kalendern, längere Beschreibungen möglich

git-svn-id: https://svn.fhem.de/fhem/trunk@23231 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
phenning 2020-11-25 16:25:09 +00:00
parent 090bd53907
commit aba1e9f533
5 changed files with 99 additions and 81 deletions

View File

@ -54,7 +54,7 @@ sub new($) {
return bless { return bless {
hash => $hash, hash => $hash,
#-- module version #-- module version
version => "7.11" version => "7.21"
}, $class; }, $class;
} }

View File

@ -5,6 +5,7 @@
# FHEM module providing hardware dependent functions for the FRM interface of OWX # FHEM module providing hardware dependent functions for the FRM interface of OWX
# #
# Prof. Dr. Peter A. Henning # Prof. Dr. Peter A. Henning
# Contributions by Jens B
# #
# $Id$ # $Id$
# #
@ -43,9 +44,6 @@ package OWX_FRM;
use strict; use strict;
use warnings; use warnings;
use Device::Firmata::Constants qw/ :all /;
use GPUtils qw(:all);
######################################################################################## ########################################################################################
# #
# Constructor # Constructor
@ -58,7 +56,7 @@ sub new($) {
return bless { return bless {
hash => $hash, hash => $hash,
#-- module version #-- module version
version => "7.11" version => "7.21"
}, $class; }, $class;
} }
@ -76,11 +74,18 @@ sub Define($) {
my ($self,$def) = @_; my ($self,$def) = @_;
my $hash = $self->{hash}; my $hash = $self->{hash};
if (!defined($main::modules{FRM})) { if (!defined($main::modules{FRM})) {
my $ret = "OWX_FRM::Define module FRM not yet loaded, please define an FRM device first."; my $ret = "module FRM not yet loaded, please define an FRM device first";
main::Log3 $hash->{NAME},1,$ret; main::Log3 $hash->{NAME},1,"OWX_FRM::Define error: $ret";
return $ret; $hash->{STATE} = "error: $ret";
} return $ret;
}
if (main::FRM_Get_Device_Firmata_Status() != main::FRM_DEVICE_FIRMATA_STATUS_INSTALLED) {
my $ret = "Perl module Device::Firmata not properly installed";
main::Log3 $hash->{NAME},1,"OWX_FRM::Define error: $ret";
$hash->{STATE} = "error: $ret";
}
my @a = split( "[ \t][ \t]*", $def ); my @a = split( "[ \t][ \t]*", $def );
my $u = "wrong syntax: define <name> OWX <firmata-device>:<firmata-pin>"; my $u = "wrong syntax: define <name> OWX <firmata-device>:<firmata-pin>";
@ -202,6 +207,10 @@ sub Reopen () {
sub Init() { sub Init() {
my ($self) = @_; my ($self) = @_;
if (main::FRM_Get_Device_Firmata_Status() != main::FRM_DEVICE_FIRMATA_STATUS_INSTALLED) {
return 'Error: Perl module Device::Firmata not properly installed';
}
if (defined($self->{OWX})) { if (defined($self->{OWX})) {
# class method called with parent hash instead of class hash as 1st parameter, fix # class method called with parent hash instead of class hash as 1st parameter, fix
$self = $self->{OWX}; $self = $self->{OWX};
@ -222,7 +231,7 @@ sub Init() {
#-- 10_FRM.pm is broken #-- 10_FRM.pm is broken
#-- possible workaround #-- possible workaround
$main::attr{$name}{IODev} = $hash->{IODev}->{NAME}; $main::attr{$name}{IODev} = $hash->{IODev}->{NAME};
my $ret = main::FRM_Init_Pin_Client($hash,\@args,PIN_ONEWIRE); my $ret = main::FRM_Init_Pin_Client($hash,\@args,Device::Firmata::Constants->PIN_ONEWIRE);
if (defined $ret){ if (defined $ret){
$msg = "Error ".$ret; $msg = "Error ".$ret;
@ -242,7 +251,7 @@ sub Init() {
$firmata->onewire_config($pin,1); $firmata->onewire_config($pin,1);
} }
}; };
return GP_Catch($@) if ($@); return main::FRM_Catch($@) if ($@);
$hash->{STATE}="Initialized"; $hash->{STATE}="Initialized";
main::InternalTimer(main::gettimeofday()+10, "OWX_Discover", $hash,0); main::InternalTimer(main::gettimeofday()+10, "OWX_Discover", $hash,0);
@ -608,7 +617,7 @@ sub Write(@) {
$firmata->onewire_command_series( $pin, $ow_command ); $firmata->onewire_command_series( $pin, $ow_command );
}; };
if ($@) { if ($@) {
main::Log3 $name,1,"OWX_FRM::Write device $name exception " . GP_Catch($@); main::Log3 $name,1,"OWX_FRM::Write device $name exception " . main::FRM_Catch($@);
return 0 return 0
} }
} }
@ -693,6 +702,15 @@ sub firmata_to_device
1; 1;
=pod
=head1 CHANGES
04.10.2020 jensb
o check for Device::Firmata install error in Define and Init
o GP_Catch() replaced with FRM_Catch() to provide filtered error messages for Perl errors
=cut
=pod =pod
=item device =item device

View File

@ -59,7 +59,7 @@ sub new($) {
#-- OWX device #-- OWX device
hash => $hash, hash => $hash,
#-- module version #-- module version
version => "7.11", version => "7.21",
#-- baud rate serial interface #-- baud rate serial interface
baud => 9600, baud => 9600,
#-- 16 byte search string #-- 16 byte search string

View File

@ -60,7 +60,7 @@ sub new($) {
#-- OWX device #-- OWX device
hash => $hash, hash => $hash,
#-- module version #-- module version
version => "7.11", version => "7.21",
#-- 16 byte search string #-- 16 byte search string
search => [0,0,0,0 ,0,0,0,0, 0,0,0,0, 0,0,0,0], search => [0,0,0,0 ,0,0,0,0, 0,0,0,0, 0,0,0,0],
ROM_ID => [0,0,0,0 ,0,0,0,0], ROM_ID => [0,0,0,0 ,0,0,0,0],
@ -485,6 +485,7 @@ sub Query ($$) {
$buffer = main::DevIo_DoSimpleRead($hash); $buffer = main::DevIo_DoSimpleRead($hash);
alarm 0; alarm 0;
}; };
#--- 2019
if ($@) { if ($@) {
if( $numexp<=1 ){ if( $numexp<=1 ){
main::Log3 $name, 4, "OWX_TCP::Query timed out in first attempt - maybe one byte missing"; main::Log3 $name, 4, "OWX_TCP::Query timed out in first attempt - maybe one byte missing";

View File

@ -52,7 +52,7 @@ my $yaahmname;
my $yaahmlinkname = "Profile"; # link text my $yaahmlinkname = "Profile"; # link text
my $yaahmhiddenroom = "ProfileRoom"; # hidden room my $yaahmhiddenroom = "ProfileRoom"; # hidden room
my $yaahmpublicroom = "Unsorted"; # public room my $yaahmpublicroom = "Unsorted"; # public room
my $yaahmversion = "3.13"; my $yaahmversion = "3.14";
my $firstcall = 1; my $firstcall = 1;
my %yaahm_transtable_EN = ( my %yaahm_transtable_EN = (
@ -2197,9 +2197,9 @@ sub YAAHM_sayWeeklyTime($$$) {
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my ($tod,$tom,$ton,$hl,$ml,$tl,$ht,$mt,$tt,$tsay,$chg,$msg,$hw,$mw,$pt,$rea,$done,$norep); my ($tod,$tom,$ton,$hl,$ml,$tl,$ht,$mt,$tt,$tsay,$chg,$msg,$hw,$mw,$pt,$rea,$done,$norep);
$tod ="";
#--determine which timer (duplicate check when coming from set) #--determine which timer (duplicate check when coming from set)
if( $timer >= int( @{$hash->{DATA}{"WT"}}) ){ if( $timer >= int( @{$hash->{DATA}{"WT"}}) ){
$msg = "Error, timer number $timer does not exist, number musst be smaller than ".int( @{$hash->{DATA}{"WT"}}); $msg = "Error, timer number $timer does not exist, number musst be smaller than ".int( @{$hash->{DATA}{"WT"}});
Log3 $name,1,"[YAAHM_sayWeeklyTime] ".$msg; Log3 $name,1,"[YAAHM_sayWeeklyTime] ".$msg;
@ -2351,14 +2351,11 @@ sub YAAHM_checkMonthly($$$) {
@tmor = split('\.',$stom); @tmor = split('\.',$stom);
@two = split('\.',$stwom); @two = split('\.',$stwom);
$fline=Calendar_Get($defs{$specialDev},,"get","events","format:full filter:mode=~'alarm|start|upcoming'"); $fline=Calendar_Get($defs{$specialDev},,"get","events","format:custom=\"\$M \$T1 \$T2 \$S\" filter:mode=~'alarm|start|upcoming'");
#-- more complicated to check here, #-- more complicated to check here,
# format is '<id> upcoming [<datetoannounce> <timetoannouce>] <datestart> <timestart>-<dateend> <timeend> [<description>] # format is 'upcoming <datestart> <timestart> <dateend> <timeend> [<description>]
# format is 'start/upcoming <datestart> <timestart> <dateend> <timeend> [<description>]
#-- more complicated to check here, # start/upcoming 03.10.2018 00:00- Sperrmüll
# format is '<id> start/upcoming <datestart> <timestart>-<dateend> <timeend> [<description>]
# d30479...5e6 start/upcoming 03.10.2018 00:00- Tag der Deutschen Einheit
my ($cstart,$cdesc);
if($fline){ if($fline){
#chomp($fline); #chomp($fline);
@ -2366,29 +2363,27 @@ sub YAAHM_checkMonthly($$$) {
foreach $fline (@lines){ foreach $fline (@lines){
chomp($fline); chomp($fline);
@chunks = split(' ',$fline); @chunks = split(' ',$fline);
if( int(@chunks)>=7 ){ @sday = split('\.',$chunks[1]);
$cstart = 4; if( !defined($chunks[5]) ){
$cdesc = 7; $tod = "???";
}else{ }else{
$cstart = 2; splice @chunks, 0, 5;
$cdesc = 5, $tod = join(' ',@chunks);
} }
@sday = split('\.',$chunks[$cstart]);
$tod = ($chunks[$cdesc]) ? $chunks[$cdesc] : "???";
#-- today #-- today
my $rets = ($sday[2]-$tday[2])*365+($sday[1]-$tday[1])*31+($sday[0]-$tday[0]); my $rets = ($sday[2]-$tday[2])*365+($sday[1]-$tday[1])*31+($sday[0]-$tday[0]);
if( $rets==0 ){ if( $rets==0 ){
$todaydesc .= $tod.","; $todaydesc .= $tod.", ";
Log3 $name, 5,"[YAAHM] found today=special date \"$tod\" in calendar $specialDev"; Log3 $name, 5,"[YAAHM] found today=special date \"$tod\" in calendar $specialDev";
} }
$rets = ($sday[2]-$tmor[2])*365+($sday[1]-$tmor[1])*31+($sday[0]-$tmor[0]); $rets = ($sday[2]-$tmor[2])*365+($sday[1]-$tmor[1])*31+($sday[0]-$tmor[0]);
if( $rets==0 ){ if( $rets==0 ){
$tomdesc .= $tod.","; $tomdesc .= $tod.", ";
Log3 $name, 5,"[YAAHM] found tomorrow=special date \"$tod\" in calendar $specialDev"; Log3 $name, 5,"[YAAHM] found tomorrow=special date \"$tod\" in calendar $specialDev";
} }
$rets = ($sday[2]-$two[2])*365+($sday[1]-$two[1])*31+($sday[0]-$two[0]); $rets = ($sday[2]-$two[2])*365+($sday[1]-$two[1])*31+($sday[0]-$two[0]);
if( $rets==0 ){ if( $rets==0 ){
$twomdesc .= $tod.","; $twomdesc .= $tod.", ";
Log3 $name, 5,"[YAAHM] found twodays=special date \"$tod\" in calendar $specialDev"; Log3 $name, 5,"[YAAHM] found twodays=special date \"$tod\" in calendar $specialDev";
} }
} }
@ -2405,9 +2400,9 @@ sub YAAHM_checkMonthly($$$) {
$twodaylong .= $twomdesc $twodaylong .= $twomdesc
if($twomdesc); if($twomdesc);
} }
$todaylong =~ s/,$//; $todaylong =~ s/, $//;
$tomlong =~ s/,$//; $tomlong =~ s/, $//;
$twodaylong =~ s/,$//; $twodaylong =~ s/, $//;
$hash->{DATA}{"DD"}[0]{"special"} = $todaylong; $hash->{DATA}{"DD"}[0]{"special"} = $todaylong;
$hash->{DATA}{"DD"}[1]{"special"} = $tomlong; $hash->{DATA}{"DD"}[1]{"special"} = $tomlong;
#-- put into readings #-- put into readings
@ -2605,35 +2600,37 @@ sub YAAHM_GetDayStatus($) {
my ($ret,$line,$fline,$date); my ($ret,$line,$fline,$date);
my (@lines,@chunks,@tday,@eday,@sday,@tmor,@ttwo); my (@lines,@chunks,@tday,@eday,@sday,@tmor,@ttwo);
my ($todaydesc,$todaytype,$tomdesc,$tomtype,$twodesc,$twotype); my ($adesc,$todaydesc,$todaytype,$tomdesc,$atype,$tomtype,$twodesc,$twotype);
my $stoday = strftime('%d.%m.%Y', localtime(time)); my $stoday = strftime('%d.%m.%Y', localtime(time));
my $stom = strftime('%d.%m.%Y', localtime(time+86400)); my $stom = strftime('%d.%m.%Y', localtime(time+86400));
my $stwo = strftime('%d.%m.%Y', localtime(time+2*86400)); my $stwo = strftime('%d.%m.%Y', localtime(time+2*86400));
#-- workday has lowest priority #-- workday has lowest priority
$todaytype = "workday"; $atype = "workday";
$todaytype = $atype;
$hash->{DATA}{"DD"}[0]{"date"} = $stoday; $hash->{DATA}{"DD"}[0]{"date"} = $stoday;
$hash->{DATA}{"DD"}[0]{"weekday"} = (strftime('%w', localtime(time))+6)%7; $hash->{DATA}{"DD"}[0]{"weekday"} = (strftime('%w', localtime(time))+6)%7;
$hash->{DATA}{"DD"}[0]{"daytype"} = "workday"; $hash->{DATA}{"DD"}[0]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"workday"}[0]; $hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"workday"}[0];
$hash->{DATA}{"DD"}[0]{"vacflag"} = 0; $hash->{DATA}{"DD"}[0]{"vacflag"} = 0;
$tomtype = "workday"; $tomtype = "workday";
$hash->{DATA}{"DD"}[1]{"date"} = $stom; $hash->{DATA}{"DD"}[1]{"date"} = $stom;
$hash->{DATA}{"DD"}[1]{"weekday"} = (strftime('%w', localtime(time+86400))+6)%7; $hash->{DATA}{"DD"}[1]{"weekday"} = (strftime('%w', localtime(time+86400))+6)%7;
$hash->{DATA}{"DD"}[1]{"daytype"} = "workday"; $hash->{DATA}{"DD"}[1]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"workday"}[0]; $hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"workday"}[0];
$hash->{DATA}{"DD"}[1]{"vacflag"} = 0; $hash->{DATA}{"DD"}[1]{"vacflag"} = 0;
$twotype = "workday"; $twotype = "workday";
$hash->{DATA}{"DD"}[2]{"date"} = $stwo; $hash->{DATA}{"DD"}[2]{"date"} = $stwo;
$hash->{DATA}{"DD"}[2]{"weekday"} = (strftime('%w', localtime(time+2*86400))+6)%7; $hash->{DATA}{"DD"}[2]{"weekday"} = (strftime('%w', localtime(time+2*86400))+6)%7;
$hash->{DATA}{"DD"}[2]{"daytype"} = "workday"; $hash->{DATA}{"DD"}[2]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"workday"}[0]; $hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"workday"}[0];
$hash->{DATA}{"DD"}[2]{"vacflag"} = 0; $hash->{DATA}{"DD"}[2]{"vacflag"} = 0;
#-- vacation has higher priority #-- vacation has higher priority
$atype = "vacation";
my $vacdayDevs = AttrVal( $name, "vacationDevices", "" ); my $vacdayDevs = AttrVal( $name, "vacationDevices", "" );
foreach my $vacdayDev ( split( /,/, $vacdayDevs ) ) { foreach my $vacdayDev ( split( /,/, $vacdayDevs ) ) {
#-- device of type holiday #-- device of type holiday
@ -2644,19 +2641,19 @@ sub YAAHM_GetDayStatus($) {
my $tod = holiday_refresh( $vacdayDev, $stoday ); my $tod = holiday_refresh( $vacdayDev, $stoday );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$todaydesc = $tod; $todaydesc = $tod;
$todaytype = "vacation"; $todaytype = $atype;
Log3 $name, 5,"[YAAHM] found today=vacation \"$todaydesc\" in holiday $vacdayDev"; Log3 $name, 5,"[YAAHM] found today=vacation \"$todaydesc\" in holiday $vacdayDev";
} }
$tod = holiday_refresh( $vacdayDev, $stom ); $tod = holiday_refresh( $vacdayDev, $stom );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$tomdesc = $tod; $tomdesc = $tod;
$tomtype = "vacation"; $tomtype = $atype;
Log3 $name, 5,"[YAAHM] found tomorrow=vacation \"$tomdesc\" in holiday $vacdayDev"; Log3 $name, 5,"[YAAHM] found tomorrow=vacation \"$tomdesc\" in holiday $vacdayDev";
} }
$tod = holiday_refresh( $vacdayDev, $stwo ); $tod = holiday_refresh( $vacdayDev, $stwo );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$twodesc = $tod; $twodesc = $tod;
$twotype = "vacation"; $twotype = $atype;
Log3 $name, 5,"[YAAHM] found twodays=vacation \"$twodesc\" in holiday $vacdayDev"; Log3 $name, 5,"[YAAHM] found twodays=vacation \"$twodesc\" in holiday $vacdayDev";
} }
#-- device of type calendar #-- device of type calendar
@ -2668,39 +2665,39 @@ sub YAAHM_GetDayStatus($) {
@tmor = split('\.',$stom); @tmor = split('\.',$stom);
@ttwo = split('\.',$stwo); @ttwo = split('\.',$stwo);
#-- more complicated to check here #-- more complicated to check here
$fline=Calendar_Get($defs{$vacdayDev},"get","events","format:full filter:mode=~'alarm|start|upcoming'"); $fline=Calendar_Get($defs{$vacdayDev},"get","events","format:custom=\"\$M \$T1 \$T2 \$S\" filter:mode=~'alarm|start|upcoming'");
#-- more complicated to check here, #-- more complicated to check here,
# format is '<id> start/end <datestart> <timestart>-<dateend> <timeend> [<description>] # format is 'start/end <datestart> <timestart> <dateend> <timeend> [<description>]
# 58b54d...4b end 22.05.2018 00:00-03.06.2018 00:00 Pfingstferien # end 22.05.2018 00:00 03.06.2018 00:00 Pfingstferien
if($fline){ if($fline){
#chomp($fline); #chomp($fline);
@lines = split('\n',$fline); @lines = split('\n',$fline);
foreach $fline (@lines){ foreach $fline (@lines){
chomp($fline); chomp($fline);
@chunks = split(' ',$fline); @chunks = split(' ',$fline);
@sday = split('\.',$chunks[2]); @sday = split('\.',$chunks[1]);
@eday = split('\.',substr($chunks[3],6,10)); @eday = split('\.',$chunks[3]);
$adesc = join(' ',splice(@chunks, 0, 5));
#-- today #-- today
my $rets = ($sday[2]-$tday[2])*365+($sday[1]-$tday[1])*31+($sday[0]-$tday[0]); my $rets = ($sday[2]-$tday[2])*365+($sday[1]-$tday[1])*31+($sday[0]-$tday[0]);
my $rete = ($eday[2]-$tday[2])*365+($eday[1]-$tday[1])*31+($eday[0]-$tday[0]); my $rete = ($eday[2]-$tday[2])*365+($eday[1]-$tday[1])*31+($eday[0]-$tday[0]);
if( ($rete>=0) && ($rets<=0) ){ if( ($rete>=0) && ($rets<=0) ){
$todaydesc = $chunks[5]; $todaydesc = $adesc;
$todaytype = "vacation"; $todaytype = $atype;
Log3 $name, 1,"[YAAHM] found today=vacation \"$todaydesc\" in calendar $vacdayDev"; Log3 $name, 1,"[YAAHM] found today=vacation \"$todaydesc\" in calendar $vacdayDev";
} }
$rets = ($sday[2]-$tmor[2])*365+($sday[1]-$tmor[1])*31+($sday[0]-$tmor[0]); $rets = ($sday[2]-$tmor[2])*365+($sday[1]-$tmor[1])*31+($sday[0]-$tmor[0]);
$rete = ($eday[2]-$tmor[2])*365+($eday[1]-$tmor[1])*31+($eday[0]-$tmor[0]); $rete = ($eday[2]-$tmor[2])*365+($eday[1]-$tmor[1])*31+($eday[0]-$tmor[0]);
if( ($rete>=0) && ($rets<=0) ){ if( ($rete>=0) && ($rets<=0) ){
$tomdesc = $chunks[5]; $tomdesc = $adesc;
$tomtype = "vacation"; $tomtype = $atype;
Log3 $name, 1,"[YAAHM] found tomorrow=vacation \"$tomdesc\" in calendar $vacdayDev"; Log3 $name, 1,"[YAAHM] found tomorrow=vacation \"$tomdesc\" in calendar $vacdayDev";
} }
$rets = ($sday[2]-$ttwo[2])*365+($sday[1]-$ttwo[1])*31+($sday[0]-$ttwo[0]); $rets = ($sday[2]-$ttwo[2])*365+($sday[1]-$ttwo[1])*31+($sday[0]-$ttwo[0]);
$rete = ($eday[2]-$ttwo[2])*365+($eday[1]-$ttwo[1])*31+($eday[0]-$ttwo[0]); $rete = ($eday[2]-$ttwo[2])*365+($eday[1]-$ttwo[1])*31+($eday[0]-$ttwo[0]);
if( ($rete>=0) && ($rets<=0) ){ if( ($rete>=0) && ($rets<=0) ){
$twodesc = $chunks[5]; $twodesc = $adesc;
$twotype = "vacation"; $twotype = $atype;
Log3 $name, 1,"[YAAHM] found twodays=vacation \"$twodesc\" in calendar $vacdayDev"; Log3 $name, 1,"[YAAHM] found twodays=vacation \"$twodesc\" in calendar $vacdayDev";
} }
} }
@ -2710,78 +2707,80 @@ sub YAAHM_GetDayStatus($) {
} }
} }
#-- put into readings #-- put into readings
if( $todaytype eq "vacation" ){ if( $todaytype eq $atype ){
$hash->{DATA}{"DD"}[0]{"daytype"} = "vacation"; $hash->{DATA}{"DD"}[0]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc; $hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc;
$hash->{DATA}{"DD"}[0]{"vacflag"} = 1; $hash->{DATA}{"DD"}[0]{"vacflag"} = 1;
} }
if( $tomtype eq "vacation" ){ if( $tomtype eq $atype ){
$hash->{DATA}{"DD"}[1]{"daytype"} = "vacation"; $hash->{DATA}{"DD"}[1]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc; $hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc;
$hash->{DATA}{"DD"}[1]{"vacflag"} = 1; $hash->{DATA}{"DD"}[1]{"vacflag"} = 1;
} }
if( $twotype eq "vacation" ){ if( $twotype eq $atype ){
$hash->{DATA}{"DD"}[2]{"daytype"} = "vacation"; $hash->{DATA}{"DD"}[2]{"daytype"} = $atype;
$hash->{DATA}{"DD"}[2]{"desc"} = $twodesc; $hash->{DATA}{"DD"}[2]{"desc"} = $twodesc;
$hash->{DATA}{"DD"}[2]{"vacflag"} = 1; $hash->{DATA}{"DD"}[2]{"vacflag"} = 1;
} }
#-- weekend has higher priority #-- weekend has higher priority
$atype = "weekend";
if( strftime('%u', localtime(time)) > 5){ if( strftime('%u', localtime(time)) > 5){
$todaytype = "weekend"; $todaytype = $atype;
if( $hash->{DATA}{"DD"}[0]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[0]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[0]{"desc"}; $hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[0]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"weekend"}[0]; $hash->{DATA}{"DD"}[0]{"desc"} = $yaahm_tt->{"weekend"}[0];
} }
$hash->{DATA}{"DD"}[0]{"daytype"} = "weekend"; $hash->{DATA}{"DD"}[0]{"daytype"} = $atype;
} }
if( strftime('%u', localtime(time+86400)) > 5){ if( strftime('%u', localtime(time+86400)) > 5){
$tomtype = "weekend"; $tomtype = $atype;
if( $hash->{DATA}{"DD"}[1]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[1]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[1]{"desc"}; $hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[1]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"weekend"}[0]; $hash->{DATA}{"DD"}[1]{"desc"} = $yaahm_tt->{"weekend"}[0];
} }
$hash->{DATA}{"DD"}[1]{"daytype"} = "weekend"; $hash->{DATA}{"DD"}[1]{"daytype"} = $atype;
} }
if( strftime('%u', localtime(time+2*86400)) > 5){ if( strftime('%u', localtime(time+2*86400)) > 5){
$twotype = "weekend"; $twotype = $atype;
if( $hash->{DATA}{"DD"}[2]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[2]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[2]{"desc"}; $hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"weekend"}[0].", ".$hash->{DATA}{"DD"}[2]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"weekend"}[0]; $hash->{DATA}{"DD"}[2]{"desc"} = $yaahm_tt->{"weekend"}[0];
} }
$hash->{DATA}{"DD"}[2]{"daytype"} = "weekend"; $hash->{DATA}{"DD"}[2]{"daytype"} = $atype;
} }
#-- holidays have the highest priority #-- holidays have the highest priority
$atype = "holiday";
my $holidayDevs = AttrVal( $name, "holidayDevices", "" ); my $holidayDevs = AttrVal( $name, "holidayDevices", "" );
foreach my $holidayDev ( split( /,/, $holidayDevs ) ) { foreach my $holidayDev ( split( /,/, $holidayDevs ) ) {
#-- device of type holiday #-- device of type holiday
if( IsDevice( $holidayDev, "holiday" )){ if( IsDevice( $holidayDev, $atype )){
$stoday = strftime('%m-%d', localtime(time)); $stoday = strftime('%m-%d', localtime(time));
$stom = strftime('%m-%d', localtime(time+86400)); $stom = strftime('%m-%d', localtime(time+86400));
$stwo = strftime('%m-%d', localtime(time+2*86400)); $stwo = strftime('%m-%d', localtime(time+2*86400));
my $tod = holiday_refresh( $holidayDev, $stoday ); my $tod = holiday_refresh( $holidayDev, $stoday );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$todaydesc = $tod; $todaydesc = $tod;
$todaytype = "holiday"; $todaytype = $atype;
Log3 $name, 5,"[YAAHM] found today=holiday \"$todaydesc\" in holiday $holidayDev"; Log3 $name, 5,"[YAAHM] found today=holiday \"$todaydesc\" in holiday $holidayDev";
} }
$tod = holiday_refresh( $holidayDev, $stom ); $tod = holiday_refresh( $holidayDev, $stom );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$tomdesc = $tod; $tomdesc = $tod;
$tomtype = "holiday"; $tomtype = $atype;
Log3 $name, 5,"[YAAHM] found tomorrow=holiday \"$tomdesc\" in holiday $holidayDev"; Log3 $name, 5,"[YAAHM] found tomorrow=holiday \"$tomdesc\" in holiday $holidayDev";
} }
$tod = holiday_refresh( $holidayDev, $stwo ); $tod = holiday_refresh( $holidayDev, $stwo );
if ( $tod ne "none" ) { if ( $tod ne "none" ) {
$twodesc = $tod; $twodesc = $tod;
$twotype = "holiday"; $twotype = $atype;
Log3 $name, 5,"[YAAHM] found twodays=holiday \"$twodesc\" in holiday $holidayDev"; Log3 $name, 5,"[YAAHM] found twodays=holiday \"$twodesc\" in holiday $holidayDev";
} }
@ -2792,7 +2791,7 @@ sub YAAHM_GetDayStatus($) {
$stwo = strftime('%d.%m.%Y', localtime(time+2*86400)); $stwo = strftime('%d.%m.%Y', localtime(time+2*86400));
$line=Calendar_Get($defs{$holidayDev},"get","events","format:text filter:mode=~'alarm|start|upcoming'"); $line=Calendar_Get($defs{$holidayDev},"get","events","format:text filter:mode=~'alarm|start|upcoming'");
#-- more complicated to check here, #-- more complicated to check here,
# format is <datestart> <timestart>-<dateend> <timeend> [<description>] # format is <datestart> <timestart> <dateend> <timeend> [<description>]
# 03.10.2018 00:00- Tag der Deutschen Einheit # 03.10.2018 00:00- Tag der Deutschen Einheit
if($line){ if($line){
chomp($line); chomp($line);
@ -2823,29 +2822,29 @@ sub YAAHM_GetDayStatus($) {
} }
#-- put into store #-- put into store
if( $todaytype eq "holiday" ){ if( $todaytype eq $atype ){
if( $hash->{DATA}{"DD"}[0]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[0]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc.", ".$hash->{DATA}{"DD"}[0]{"desc"}; $hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc.", ".$hash->{DATA}{"DD"}[0]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc; $hash->{DATA}{"DD"}[0]{"desc"} = $todaydesc;
} }
$hash->{DATA}{"DD"}[0]{"daytype"} = "holiday"; $hash->{DATA}{"DD"}[0]{"daytype"} = $atype;
} }
if( $tomtype eq "holiday" ){ if( $tomtype eq $atype ){
if( $hash->{DATA}{"DD"}[1]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[1]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc.", ".$hash->{DATA}{"DD"}[1]{"desc"}; $hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc.", ".$hash->{DATA}{"DD"}[1]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc; $hash->{DATA}{"DD"}[1]{"desc"} = $tomdesc;
} }
$hash->{DATA}{"DD"}[1]{"daytype"} = "holiday"; $hash->{DATA}{"DD"}[1]{"daytype"} = $atype;
} }
if( $twotype eq "holiday" ){ if( $twotype eq $atype ){
if( $hash->{DATA}{"DD"}[2]{"daytype"} ne "workday" ){ if( $hash->{DATA}{"DD"}[2]{"daytype"} ne "workday" ){
$hash->{DATA}{"DD"}[2]{"desc"} = $twodesc.", ".$hash->{DATA}{"DD"}[2]{"desc"}; $hash->{DATA}{"DD"}[2]{"desc"} = $twodesc.", ".$hash->{DATA}{"DD"}[2]{"desc"};
}else{ }else{
$hash->{DATA}{"DD"}[2]{"desc"} = $twodesc; $hash->{DATA}{"DD"}[2]{"desc"} = $twodesc;
} }
$hash->{DATA}{"DD"}[2]{"daytype"} = "holiday"; $hash->{DATA}{"DD"}[2]{"daytype"} = $atype;
} }
#-- sunrise, sunset and the offsets #-- sunrise, sunset and the offsets