diff --git a/FHEM/73_HailoLibero.pm b/FHEM/73_HailoLibero.pm index 426f59d..15cf01e 100644 --- a/FHEM/73_HailoLibero.pm +++ b/FHEM/73_HailoLibero.pm @@ -69,6 +69,7 @@ sub Initialize { $hash->{AttrFn} = 'FHEM::Hailo::Libero::Attr'; $hash->{AttrList} = 'disable:1 ' + . 'interval ' . 'LiberoIP ' . $readingFnAttributes; $hash->{parseParams} = 1; @@ -123,6 +124,7 @@ sub Initialize { Attributes @@ -167,6 +169,7 @@ sub Initialize { Attributes diff --git a/controls_HailoLibero.txt b/controls_HailoLibero.txt index d114b37..c3e6c4c 100644 --- a/controls_HailoLibero.txt +++ b/controls_HailoLibero.txt @@ -1,2 +1,2 @@ -UPD 2021-06-06_19:47:44 5194 FHEM/73_HailoLibero.pm -UPD 2021-06-06_19:50:09 12904 lib/FHEM/Hailo/Libero.pm +UPD 2021-06-09_08:34:36 5354 FHEM/73_HailoLibero.pm +UPD 2021-06-09_08:40:28 13545 lib/FHEM/Hailo/Libero.pm diff --git a/lib/FHEM/Hailo/Libero.pm b/lib/FHEM/Hailo/Libero.pm index b8dfb8c..46df2d1 100644 --- a/lib/FHEM/Hailo/Libero.pm +++ b/lib/FHEM/Hailo/Libero.pm @@ -86,7 +86,7 @@ sub Define { my $name = shift @$aArg; $hash->{URL} = AttrVal( $name, 'LiberoIP', 'http://192.168.0.1:81'); - + $hash->{INTERVAL} = 60; $hash->{NOTIFYDEV} = "global,$name"; $hash->{VERSION} = version->parse($VERSION)->normal; @@ -110,7 +110,8 @@ sub Undef { my $name = shift; $hash->{helper}->{passObj}->setDeletePassword($name); - + RemoveInternalTimer($hash); + return; } @@ -129,6 +130,22 @@ sub Attr { Log3($name, 3, qq{HailoLibero ($name) - enabled}); } } + elsif ( $attrName eq 'interval' ) { + if ( $cmd eq 'set' ) { + return 'Interval must be greater than 0' + if ( $attrVal == 0 ); + RemoveInternalTimer($hash); + $hash->{INTERVAL} = $attrVal; + Log3 $name, 3, + qq{HailoLibero ($name) - set interval: $attrVal}; + } + elsif ( $cmd eq 'del' ) { + RemoveInternalTimer($hash); + $hash->{INTERVAL} = 60; + Log3 $name, 3, + qq{HailoLibero ($name) - delete User interval and set default: 60}; + } + } elsif ( $attrName eq 'LiberoIP') { if ( $cmd eq 'set' ) { $hash->{URL} = "http://$attrVal:81"; @@ -183,7 +200,7 @@ sub Notify { if ( $devtype eq 'HailoLibero' && ( - grep /^cookie:.*$/, + grep /^state:.connected$/, @{$events} ) && ( @@ -191,11 +208,11 @@ sub Notify { ) ) { - getSettings($hash); - #InternalTimer( gettimeofday() + $hash->{INTERVAL}, - # "FHEM::HailoLibero::getSettings", $hash ); + getCookie($hash); + InternalTimer( gettimeofday() + $hash->{INTERVAL}, + "FHEM::HailoLibero::getCookie", $hash ); Log3 $name, 4, -"HailoLibero ($name) - set internal timer function for recall getSettings sub"; + "HailoLibero ($name) - set internal timer function for recall getCookie sub"; } return;