Neue Beta Test Runde für alle MAX Module

Begonnen von Wzut, 14 Oktober 2020, 17:41:04

Vorheriges Thema - Nächstes Thema

adn77

#195
Zitat von: asdfasdfasdfasdfasdf am 29 September 2025, 13:10:51I believe there may be a mistake in line 2003 of the 10_MAX.pm file. I think that instead...
elsif (AttrNum($name, 'keepAuto', 0)  && (ReadingsVal($hash, 'mode', 'auto') eq 'auto')) {

should be
elsif (AttrNum($name, 'keepAuto', 0)  && (ReadingsVal($name, 'mode', 'auto') eq 'auto')) {

I guess you're right about the correction, but fixing that leads to some unwanted behavior. I eventually came up with this:
--- FHEM/10_MAX.pm      2026-03-16 09:11:35.998161250 +0100
+++ FHEM/10_MAX.pm      2026-04-12 18:14:04.885823595 +0200
@@ -1986,25 +1986,27 @@

        $ctrlmode = 0; # auto
     } # auto
-
-    if ($args[0] eq 'boost') {
+    elsif ($args[0] eq 'boost') {
        return Log3Return($name, 'set_desiredTemp : too many parameters for boost') if (@args > 1);
        $temperature = 0;
        $ctrlmode = 3;
-       # TODO: auto mode with temperature is also possible
     }
-
-    if ($args[0] eq 'manual') {
+    elsif ($args[0] eq 'manual') {
        # User explicitly asked for manual mode
        $ctrlmode = 1; #manual, possibly overwriting keepAuto
        shift @args;
        return Log3Return($name, 'set_desiredTemp : not enough parameters after desiredTemperature manual') if (!@args);
     }
-    elsif (AttrNum($name, 'keepAuto', 0)  && (ReadingsVal($name, 'mode', 'auto') eq 'auto')) {
+    elsif (AttrNum($name, 'keepAuto', 0)) {
        # User did not ask for any mode explicitly, but has keepAuto
-       Log3($hash, 5, "$name, SetTemperature: keepAuto and mode auto = staying in auto mode");
+       Log3($name, 5, "$name, SetTemperature: keepAuto and mode auto = staying in auto mode");
        $ctrlmode = 0; # auto
     }
+    else {
+       if (ReadingsVal($name, 'mode', 'auto') eq 'auto') { $ctrlmode = 0; }
+       else { $ctrlmode = 1; }
+       Log3($name, 5, "$name, SetTemperature: no mode explcitly given = staying in current mode");
+    }

     $temperature = MAX_ReadingsVal($hash, 'ecoTemperature') if ($args[0] eq 'eco');