Small change for dimmable status icon to match toggle

Begonnen von Woody14623, 04 April 2024, 01:23:14

Vorheriges Thema - Nächstes Thema

Woody14623


Hello! While I love FHEM, I unfortunately do not speak German. (Though I'm learning more every day, and am visiting Berlin in July.)

I have a small change I would like to see to change the behavior of dimmable lights so they match on/off only lights. It was noted elsewhere that patches should be submitted to the maintainer in the proper subforum.  My guess was this is the proper place, but if it is not, please advise where to post this.

Thanks for all the great work done in maintaining this project!

--- FHEM/10_MQTT2_DEVICE.pm     2024-04-03 19:10:11.472701979 -0400
+++ FHEM/10_MQTT2_DEVICE.pm     2024-04-03 19:10:00.181241704 -0400
@@ -875,9 +875,9 @@

   my $too = $defs{$name}->{TIMED_OnOff};
   $useSetExtension = 0 if(!$too);
-  my $state = lc(ReadingsVal($name,"state","on"));
-  if(!$useSetExtension && $state =~ m/off$/) { # set_off or off
-    return ".*:off:toggle";
+  my $state = lc(ReadingsVal($name,"state","set_off"));
+  if(!$useSetExtension && ($state =~ m/off$/ || $state =~ m/^set/)) { # set_off or off
+    return ".*:".$state.":toggle";
   }

   my $pct = ReadingsNum($name, "brightness", 255);


Beta-User

Hi, thanks for your suggestion, posting in english is ok.

@Rudi & Woody14623:
Don't have any definite opinion on that, but at first sight, I'd change the behaviour as well, but start (as is) with plain "on" default, but reissue the last set command in case it's still marked with the "set_" prefix. (This might also fix some strange behaviour of the shelly 2nd gen. devices reported some weeks ago?)

(Didn't look into the code for the surrounding context, might need additional changes as well; in case code proposal is wanted, pls wait until next week).
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

rudolfkoenig

I propose to wait for Beta-Users solution to avoid too many changes for our end-user.

Beta-User

Zitat von: rudolfkoenig am 04 April 2024, 12:34:07I propose to wait for Beta-Users solution to avoid too many changes for our end-user.
here you are....
 
my $too = $defs{$name}->{TIMED_OnOff};
  $useSetExtension = 0 if(!$too);
  my $state = lc(ReadingsVal($name,"state","on"));
  my $missed = $state =~ m/^set_(on|off)$/;
  $missed = $1 if $missed;
  if(!$useSetExtension || $missed) {
    if($missed) { # set_off or set_on
      return ".*:$state:$missed";          # repeat same cmd
    }
    if($state eq 'off') {
      return '.*:off:toggle';
    }
  }

Btw: afair we (justme1968 and myself) had some comparable discussion in the past for the color-devStateIcon code (e.g. used for the MiLight- or Tasmota-RGB-MQTT2-Devices; in this case the set_-prefix is also used for brightness or colour). Didn't doublecheck that, but maybe SetExtensions needs also a review wrt. to "lost" commands (e.g. in case ZWDongle is configured for the "set_"-prefix)?
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files