2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

98_CDCOpenData.pm: Version 01.12c

git-svn-id: https://svn.fhem.de/fhem/trunk@28335 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jowiemann 2024-01-03 12:41:09 +00:00
parent c52594bf1c
commit 2ac7cb3bb0

View File

@ -54,7 +54,7 @@ use warnings;
use Blocking;
use HttpUtils;
my $ModulVersion = "01.12b";
my $ModulVersion = "01.12c";
my $missingModul = "";
sub CDCOpenData_Log($$$);
@ -174,6 +174,19 @@ sub CDCOpenData_dbgLogInit($@) {
$hash->{DEBUGLOG} = "OFF";
$hash->{helper}{debugLog} = $name . "_debugLog";
$hash->{helper}{logDebug} = AttrVal($name, "verbose", 0) == 5;
if ($hash->{helper}{logDebug}) {
my ($seconds, $microseconds) = gettimeofday();
my @t = localtime($seconds);
my $nfile = ResolveDateWildcards($hash->{helper}{debugLog} . '-%Y-%m.dlog', @t);
$hash->{DEBUGLOG} = '<html>'
. '<a href="/fhem/FileLog_logWrapper&amp;dev='
. $hash->{helper}{debugLog}
. '&amp;type=text&amp;file='
. $nfile
. '">DEBUG Log kann hier eingesehen werden</a>'
. '</html>';
}
}
return if $aVal && $aVal == -1;
@ -181,21 +194,25 @@ sub CDCOpenData_dbgLogInit($@) {
my $dirdef = AttrVal('global', 'logdir', $attr{global}{modpath}.'/log/');
my $dbgLogFile = $dirdef . $hash->{helper}{debugLog} . '-%Y-%m.dlog';
if ($cmd eq "set" || $cmd eq "init") {
# if ($cmd eq "set" || $cmd eq "init") {
if ($cmd eq "set" ) {
if($aVal == 5) {
my $dMod = 'defmod ' . $hash->{helper}{debugLog} . ' FileLog ' . $dbgLogFile . ' FakeLog readonly';
unless (defined $defs{$hash->{helper}{debugLog}}) {
my $dMod = 'defmod ' . $hash->{helper}{debugLog} . ' FileLog ' . $dbgLogFile . ' FakeLog readonly';
fhem($dMod, 1);
if (my $dRoom = AttrVal($name, "room", undef)) {
$dMod = 'attr -silent ' . $hash->{helper}{debugLog} . ' room ' . $dRoom;
fhem($dMod, 1);
}
if (my $dGroup = AttrVal($name, "group", undef)) {
$dMod = 'attr -silent ' . $hash->{helper}{debugLog} . ' group ' . $dGroup;
fhem($dMod, 1);
if (my $dRoom = AttrVal($name, "room", undef)) {
$dMod = 'attr -silent ' . $hash->{helper}{debugLog} . ' room ' . $dRoom;
fhem($dMod, 1);
}
if (my $dGroup = AttrVal($name, "group", undef)) {
$dMod = 'attr -silent ' . $hash->{helper}{debugLog} . ' group ' . $dGroup;
fhem($dMod, 1);
}
}
CDCOpenData_Log $name, 3, "redirection debugLog: $dbgLogFile started";
@ -250,6 +267,24 @@ sub CDCOpenData_dbgLogInit($@) {
} # end CDCOpenData_dbgLogInit
#######################################################################
sub CDCOpenData_Notify($$)
{
my ($own_hash, $dev_hash) = @_;
my $ownName = $own_hash->{NAME}; # own name / hash
return "" if(IsDisabled($ownName)); # Return without any further action if the module is disabled
my $devName = $dev_hash->{NAME}; # Device that created the events
my $events = deviceEvents($dev_hash, 1);
if($devName eq "global" && grep(m/^INITIALIZED|REREADCFG$/, @{$events}))
{
# initialize DEGUB LOg function
CDCOpenData_dbgLogInit($own_hash, "init", "verbose", AttrVal($ownName, "verbose", -1));
# end initialize DEGUB LOg function
}
}
#######################################################################
sub CDCOpenData_Initialize($)
@ -260,6 +295,7 @@ sub CDCOpenData_Initialize($)
$hash->{UndefFn} = "CDCOpenData_Undefine";
$hash->{DeleteFn} = "CDCOpenData_Delete";
$hash->{RenameFn} = "CDCOpenData_Rename";
$hash->{NotifyFn} = "CDCOpenData_Notify";
$hash->{SetFn} = "CDCOpenData_Set";
$hash->{GetFn} = "CDCOpenData_Get";
@ -1059,7 +1095,7 @@ sub CDCOpenData_Readout_Run_Data($@)
for (my $i = 1; $i <= $holdCnt; $i++) {
my $holdTime = $i * 86400;
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, $Jahr, $Wochentag, $Jahrestag, $Sommerzeit) = localtime(time - (time % 86400) - $holdTime);
$time = ($Jahr + 1900) . "-" . ($Monat + 1) . "-" . substr("00" . $Monatstag, -2);
$time = ($Jahr + 1900) . "-" . sprintf("%02d",$Monat + 1) . "-" . substr("00" . $Monatstag, -2);
CDCOpenData_Log $name, 3, "start CDCOpenData_Readout_Run_getRain with $name, $fromGet, $time";
$returnStrD .= CDCOpenData_Readout_Run_getRain($name, $time, $latlong, $fromGet, $i) . "|";
return $name . "|" . encode_base64($returnStrR,"") if $returnStrD =~ /Error\|/;