diff --git a/fhem/CHANGED b/fhem/CHANGED index fefb2e812..e9c7a6db4 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 76_SolarForecast: fix get Automatic State - change: 76_SolarForecast: optimize battery management once more - change: 76_SolarForecast: optimize batterymanagement - change: 93_DbLog: minor change of configCheck diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index 70e6e9160..d4f03ec2f 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -155,6 +155,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.6.4" => "09.01.2024 fix get Automatic State, use key switchdev for auto-Reading if switchdev is set in consumer attr ", "1.6.3" => "08.01.2024 optimize battery management once more ", "1.6.2" => "07.01.2024 optimize battery management ", "1.6.1" => "04.01.2024 new sub __setPhysSwState, edit ___setConsumerPlanningState, boost performance of collectAllRegConsumers ". @@ -6598,7 +6599,7 @@ sub _manageConsumerData { my $chour = $paref->{chour}; my $day = $paref->{day}; - my $nhour = $chour+1; + my $nhour = $chour + 1; $paref->{nhour} = sprintf("%02d",$nhour); for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) { @@ -6743,7 +6744,8 @@ sub _manageConsumerData { } $paref->{consumer} = $c; - + + __getAutomaticState ($paref); # Automatic Status des Consumers abfragen __calcEnergyPieces ($paref); # Energieverbrauch auf einzelne Stunden für Planungsgrundlage aufteilen __planSwitchTimes ($paref); # Consumer Switch Zeiten planen __setTimeframeState ($paref); # Timeframe Status ermitteln @@ -6776,6 +6778,49 @@ sub _manageConsumerData { return; } +################################################################ +# Consumer Status Automatic Modus abfragen und im +# Hash consumers aktualisieren +################################################################ +sub __getAutomaticState { + my $paref = shift; + my $hash = $paref->{hash}; + my $name = $paref->{name}; + my $type = $paref->{type}; + my $c = $paref->{consumer}; + + my $consumer = AttrVal ($name, "consumer${c}", ""); + my ($ac,$hc) = parseParams ($consumer); + $consumer = $ac->[0] // ""; + + if (!$consumer || !$defs{$consumer}) { + my $err = qq{ERROR - the device "$consumer" doesn't exist anymore! Delete or change the attribute "consumer${c}".}; + Log3 ($name, 1, "$name - $err"); + return; + } + + my $dswitch = $hc->{switchdev}; # alternatives Schaltdevice + + if ($dswitch) { + if (!$defs{$dswitch}) { + my $err = qq{ERROR - the device "$dswitch" doesn't exist anymore! Delete or change the attribute "consumer${c}".}; + Log3 ($name, 1, "$name - $err"); + return; + } + } + else { + $dswitch = $consumer; + } + + my $rauto = $hc->{auto} // q{}; + my $auto = 1; + $auto = ReadingsVal ($dswitch, $rauto, 1) if($rauto); # Reading für Ready-Bit -> Einschalten möglich ? + + $data{$type}{$name}{consumers}{$c}{auto} = $auto; # Automaticsteuerung: 1 - Automatic ein, 0 - Automatic aus + +return; +} + ################################################################### # Energieverbrauch auf einzelne Stunden für Planungsgrundlage # aufteilen @@ -9948,8 +9993,8 @@ sub _graphicConsumerLegend { my $cmdon = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 set $dswname $oncom')"}; my $cmdoff = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 set $dswname $offcom')"}; - my $cmdautoon = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 setreading $cname $autord 1')"}; - my $cmdautooff = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 setreading $cname $autord 0')"}; + my $cmdautoon = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 setreading $dswname $autord 1')"}; + my $cmdautooff = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 setreading $dswname $autord 0')"}; my $implan = qq{"FW_cmd('$FW_ME$FW_subdir?XHR=1&cmd=set $name clientAction $c 0 consumerImmediatePlanning $c')"}; if ($ftui eq "ftui") { @@ -16368,7 +16413,7 @@ to ensure that the system configuration is correct. switchdev The specified <device> is assigned to the consumer as a switch device (optional). Switching operations are performed with this device. The key is useful for consumers where energy measurement and switching is carried out with different devices - e.g. Homematic or readingsProxy. If switchdev is specified, the keys on, off, swstate and asynchronous refer to this device. + e.g. Homematic or readingsProxy. If switchdev is specified, the keys on, off, swstate, auto, asynchronous refer to this device. mode Consumer planning mode (optional). Allowed are: can - Scheduling takes place at the time when there is probably enough PV surplus available (default). @@ -16412,6 +16457,7 @@ to ensure that the system configuration is correct. notafter Schedule start time consumer not after specified hour (01..23) (optional) auto Reading in the consumer device which enables or blocks the switching of the consumer (optional) + If the key switchdev is given, the reading is set and evaluated in this device. Reading value = 1 - switching enabled (default), 0: switching blocked pcurr Reading:Unit (W/kW) which provides the current energy consumption (optional) @@ -18384,116 +18430,117 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden.