From e7391286953d23f9bacfb4da810ec737aa34bb7a Mon Sep 17 00:00:00 2001 From: neubert Date: Wed, 25 Aug 2021 06:01:00 +0000 Subject: [PATCH] 11_OWDevice: new attribute disable (forum #122563) git-svn-id: https://svn.fhem.de/fhem/trunk@24870 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/11_OWDevice.pm | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index d2f53f5bb..b748f155f 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. + - feature: 11_OWDevice: new attribute disable (forum #122563) - change: 50_TelegramBot: parseMode for Photo & Video / FIX: 0_none logmode - feature: 19_Revolt: add standard attributes ignore, showtime etc. - feature: 23_LUXTRONIK2: new set parameter ventBOSUPCircPumpDeaerate diff --git a/fhem/FHEM/11_OWDevice.pm b/fhem/FHEM/11_OWDevice.pm index 494bde0d0..05eb71b31 100644 --- a/fhem/FHEM/11_OWDevice.pm +++ b/fhem/FHEM/11_OWDevice.pm @@ -383,7 +383,7 @@ OWDevice_Initialize($) $hash->{UndefFn} = "OWDevice_Undef"; $hash->{AttrFn} = "OWDevice_Attr"; - $hash->{AttrList} = "IODev uncached trimvalues polls interfaces model cstrings ". + $hash->{AttrList} = "IODev uncached trimvalues polls interfaces model cstrings disable:0,1 ". "resolution:9,10,11,12 ". $readingFnAttributes; } @@ -506,6 +506,9 @@ OWDevice_UpdateValues($) { my ($hash)= @_; + my $name= $hash->{NAME}; + return if (AttrVal($name, 'disable', 0) == 1); + my @polls= @{$hash->{fhem}{polls}}; my @getters= @{$hash->{fhem}{getters}}; my @state= @{$hash->{fhem}{state}}; @@ -577,7 +580,12 @@ OWDevice_Attr($@) delete $hash->{fhem}{interfaces} if(defined($hash->{fhem}{interfaces})); Log3 $name, 5, "$name: no interfaces"; } - } + } + elsif($attrName eq "disable" && ($cmd eq 'del' || $attrVal == 0)) { # restart after disable + RemoveInternalTimer($hash); + InternalTimer(int(gettimeofday()) + $hash->{fhem}{interval}, "OWDevice_UpdateValues", $hash, 0) + if(defined($hash->{fhem}{interval})); + } } ################################### @@ -714,7 +722,7 @@ OWDevice_Notify($$) return if($dev->{NAME} ne "global"); return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); - return if($attr{$name} && $attr{$name}{disable}); + return if($attr{$name} && $attr{$name}{disable} == 1); OWDevice_InitValues($hash); RemoveInternalTimer($hash); @@ -908,6 +916,7 @@ OWDevice_InitValues($)
  • trimvalues: removes leading and trailing whitespace from readings. Default is 1 (on).
  • cstrings: interprets reading as C-style string, i.e. stops reading on the first zero byte. Default is 0 (off).
  • polls: a comma-separated list of readings to poll. This supersedes the list of default readings to poll.
  • +
  • disable: set to 1 to disable polling.
  • interfaces: supersedes the interfaces exposed by that device.
  • model: preset with device type, e.g. DS18S20.
  • resolution: resolution of temperature reading in bits, can be 9, 10, 11 or 12. @@ -1071,6 +1080,7 @@ OWDevice_InitValues($)
  • trimvalues: Entfernt voran- und nachgestellte Leerzeichen aus den readings. Standartwert ist 1 (ein).
  • cstrings: Interpretiert die readings als C-String, d.h. hört mit dem ersten 0-Byte zu lesen auf. Standardwert ist 0 (off).
  • polls: Eine per Komma getrennte Liste der abzurufenden readings. Mit diesem Attribut unterdrückt man alle standartmäßig abgerufenen readings und ersetzt sie durch die eigene Zusammenstellung.
  • +
  • disable: auf 1 setzen, um Polling abzustellen.
  • interfaces: Ersetzt die durch dieses Gerät erzeugten Interfaces.
  • model: Angabe des Gerätetyps, z.B.: DS18S20.
  • resolution: Angabe der Auflösung für die Temperaturmessung in bits, zur Verfügung stehen: 9, 10, 11 oder 12.