From 16769fa15117ec06821fa245e5fbe649ce604876 Mon Sep 17 00:00:00 2001 From: fichtennadel <> Date: Sat, 16 Nov 2024 19:05:02 +0000 Subject: [PATCH] 98_fronius.pm: V0.2: set GetActiveDeviceInfo; re-init timer for fronius_GetActiveDeviceInfo in fronius_GetMeterRealtimeData and fronius_GetInverterRealtimeData if DeviceInfo_ is missing;internal VERSION git-svn-id: https://svn.fhem.de/fhem/trunk@29348 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/98_fronius.pm | 44 +++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/fhem/contrib/98_fronius.pm b/fhem/contrib/98_fronius.pm index 84e27fbae..4382cfd5c 100755 --- a/fhem/contrib/98_fronius.pm +++ b/fhem/contrib/98_fronius.pm @@ -2,6 +2,12 @@ # ############################################## # +# 2024.05.27 - fichtennadel v0.2 +# - CHANGE: +# - set GetActiveDeviceInfo +# - re-init timer for fronius_GetActiveDeviceInfo in fronius_GetMeterRealtimeData and fronius_GetInverterRealtimeData if DeviceInfo_ is missing +# - internal VERSION +# # 2024.05.27 - fichtennadel v0.1 # - INFO: check in to svn trunk/fhem/contrib/fichtennadel # - renamed file to lower case fronius to match device type (fhem standard) @@ -110,7 +116,7 @@ use Date::Parse; use Time::Piece; use lib ('./FHEM/lib', './lib'); -my $ModulVersion = "0.1"; +my $ModulVersion = "0.2"; ############################################################################## sub fronius_Initialize($) { @@ -149,6 +155,9 @@ sub fronius_Define($$$) { # nur notifies für global $hash->{NOTIFYDEV} = "global"; + # current version + $hash->{VERSION} = $ModulVersion; + # Internaltimer löschen RemoveInternalTimer($hash); @@ -269,6 +278,7 @@ sub fronius_Set($@) { "GetStorageData" => "noArg", "GetMeterData" => "noArg", "GetInverterData" => "noArg", + "GetActiveDeviceInfo" => "noArg", "RestartInterval" => "noArg" ); my %order = ( @@ -277,19 +287,27 @@ sub fronius_Set($@) { "Meter" => -1, "Inverter" => -1 ); + + Log3 $name, 4, "[$name] [fronius_Set] $opt" if (($opt ne '?') && ($opt ne '')); if (($opt eq '?') || ($opt eq '')){ #return join( ' ', @options); return join(" ", sort keys %sets); + } elsif ($opt eq 'RestartInterval') { + RemoveInternalTimer($hash, "fronius_GetAPIVersionInfo"); + RemoveInternalTimer($hash, "fronius_GetActiveDeviceInfo"); RemoveInternalTimer($hash, "fronius_GetPowerFlowRealtimeData"); RemoveInternalTimer($hash, "fronius_GetStorageRealtimeData"); RemoveInternalTimer($hash, "fronius_GetMeterRealtimeData"); RemoveInternalTimer($hash, "fronius_GetInverterRealtimeData"); - InternalTimer(gettimeofday() + $interval, "fronius_GetPowerFlowRealtimeData", $hash, 0); - InternalTimer(gettimeofday() + 2 + $interval, "fronius_GetStorageRealtimeData", $hash, 0); - InternalTimer(gettimeofday() + 4 + $interval, "fronius_GetMeterRealtimeData", $hash, 0); - InternalTimer(gettimeofday() + 6 + $interval, "fronius_GetInverterRealtimeData", $hash, 0); + InternalTimer(gettimeofday() + $interval, "fronius_GetAPIVersionInfo", $hash, 0); + InternalTimer(gettimeofday() + 5 + $interval, "fronius_GetActiveDeviceInfo", $hash, 0); + InternalTimer(gettimeofday() + 10 + $interval, "fronius_GetPowerFlowRealtimeData", $hash, 0); + InternalTimer(gettimeofday() + 15 + $interval, "fronius_GetStorageRealtimeData", $hash, 0); + InternalTimer(gettimeofday() + 20 + $interval, "fronius_GetMeterRealtimeData", $hash, 0); + InternalTimer(gettimeofday() + 25 + $interval, "fronius_GetInverterRealtimeData", $hash, 0); + } elsif ($interval le 0) { if ($opt eq 'GetAllData') { #übergabeparameter durchsuchen auf gültigkeit und übernehmen @@ -325,6 +343,9 @@ sub fronius_Set($@) { InternalTimer(gettimeofday(), "fronius_GetMeterRealtimeData", $hash, 0); } elsif ($opt eq 'GetInverterData') { InternalTimer(gettimeofday(), "fronius_GetInverterRealtimeData", $hash, 0); + } elsif ($opt eq 'GetActiveDeviceInfo') { + RemoveInternalTimer($hash, "fronius_GetActiveDeviceInfo"); + InternalTimer(gettimeofday(), "fronius_GetActiveDeviceInfo", $hash, 0); } else { #return "Unknown argument $opt choose one of : " . join( ', ', @options); return "Unknown argument $opt choose one of : " . join(" ", sort keys %sets) . @@ -449,10 +470,14 @@ sub fronius_GetStorageRealtimeData($) { } } else { + Log3 $name, 4, "[$name] [fronius_GetStorageRealtimeData] removing DeviceInfo_Storage_ readings"; # Eventuell vorhandene Daten wieder löschen! foreach my $StorageDevice (sort keys %{$hash->{READINGS}}) { readingsDelete($hash, $StorageDevice) if ($StorageDevice =~ m/DeviceInfo_Storage_/ ); } + + Log3 $name, 4, "[$name] [fronius_GetStorageRealtimeData] calling GetActiveDeviceInfo"; + fronius_SendCommand($hash,"GetActiveDeviceInfo",""); } if ($interval > 0) { @@ -485,10 +510,14 @@ sub fronius_GetMeterRealtimeData($) { } } else { + Log3 $name, 4, "[$name] [fronius_GetMeterRealtimeData] removing DeviceInfo_Meter_ readings"; # Eventuell vorhandene Daten wieder löschen! foreach my $MeterDevice (sort keys %{$hash->{READINGS}}) { readingsDelete($hash, $MeterDevice) if ($MeterDevice =~ m/DeviceInfo_Meter_/ ); } + + Log3 $name, 4, "[$name] [fronius_GetStorageRealtimeData] calling GetActiveDeviceInfo"; + fronius_SendCommand($hash,"GetActiveDeviceInfo",""); } if ($interval > 0) { @@ -526,10 +555,14 @@ sub fronius_GetInverterRealtimeData($) { } } else { + Log3 $name, 4, "[$name] [fronius_GetInverterRealtimeData] removing DeviceInfo_Inverter_ readings"; # Eventuell vorhandene Daten wieder löschen! foreach my $InverterDevice (sort keys %{$hash->{READINGS}}) { readingsDelete($hash, $InverterDevice) if ($InverterDevice =~ m/DeviceInfo_Inverter_/ ); } + + Log3 $name, 4, "[$name] [fronius_GetInverterRealtimeData] calling GetActiveDeviceInfo"; + fronius_SendCommand($hash,"GetActiveDeviceInfo",""); } if ($interval > 0) { @@ -875,6 +908,7 @@ sub fronius_setState($$) {