add internal

This commit is contained in:
Sebastian 2021-06-09 08:41:04 +02:00
parent eacc462e18
commit 732fa6ed4a
3 changed files with 29 additions and 9 deletions

View File

@ -69,6 +69,7 @@ sub Initialize {
$hash->{AttrFn} = 'FHEM::Hailo::Libero::Attr'; $hash->{AttrFn} = 'FHEM::Hailo::Libero::Attr';
$hash->{AttrList} = $hash->{AttrList} =
'disable:1 ' 'disable:1 '
. 'interval '
. 'LiberoIP ' . 'LiberoIP '
. $readingFnAttributes; . $readingFnAttributes;
$hash->{parseParams} = 1; $hash->{parseParams} = 1;
@ -123,6 +124,7 @@ sub Initialize {
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li>LiberoIP - IP e.g. 192.168.1.200</li> <li>LiberoIP - IP e.g. 192.168.1.200</li>
<li>interval - eat cookie interval in seconds | default: 60</li>
</ul> </ul>
</ul> </ul>
@ -167,6 +169,7 @@ sub Initialize {
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li>LiberoIP - IP e.g. 192.168.1.200</li> <li>LiberoIP - IP e.g. 192.168.1.200</li>
<li>interval - eat cookie interval in sekunden | standard: 60</li>
</ul> </ul>
</ul> </ul>

View File

@ -1,2 +1,2 @@
UPD 2021-06-06_19:47:44 5194 FHEM/73_HailoLibero.pm UPD 2021-06-09_08:34:36 5354 FHEM/73_HailoLibero.pm
UPD 2021-06-06_19:50:09 12904 lib/FHEM/Hailo/Libero.pm UPD 2021-06-09_08:40:28 13545 lib/FHEM/Hailo/Libero.pm

View File

@ -86,7 +86,7 @@ sub Define {
my $name = shift @$aArg; my $name = shift @$aArg;
$hash->{URL} = $hash->{URL} =
AttrVal( $name, 'LiberoIP', 'http://192.168.0.1:81'); AttrVal( $name, 'LiberoIP', 'http://192.168.0.1:81');
$hash->{INTERVAL} = 60;
$hash->{NOTIFYDEV} = "global,$name"; $hash->{NOTIFYDEV} = "global,$name";
$hash->{VERSION} = version->parse($VERSION)->normal; $hash->{VERSION} = version->parse($VERSION)->normal;
@ -110,6 +110,7 @@ sub Undef {
my $name = shift; my $name = shift;
$hash->{helper}->{passObj}->setDeletePassword($name); $hash->{helper}->{passObj}->setDeletePassword($name);
RemoveInternalTimer($hash);
return; return;
} }
@ -129,6 +130,22 @@ sub Attr {
Log3($name, 3, qq{HailoLibero ($name) - enabled}); 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') { elsif ( $attrName eq 'LiberoIP') {
if ( $cmd eq 'set' ) { if ( $cmd eq 'set' ) {
$hash->{URL} = "http://$attrVal:81"; $hash->{URL} = "http://$attrVal:81";
@ -183,7 +200,7 @@ sub Notify {
if ( if (
$devtype eq 'HailoLibero' $devtype eq 'HailoLibero'
&& ( && (
grep /^cookie:.*$/, grep /^state:.connected$/,
@{$events} @{$events}
) )
&& ( && (
@ -191,11 +208,11 @@ sub Notify {
) )
) )
{ {
getSettings($hash); getCookie($hash);
#InternalTimer( gettimeofday() + $hash->{INTERVAL}, InternalTimer( gettimeofday() + $hash->{INTERVAL},
# "FHEM::HailoLibero::getSettings", $hash ); "FHEM::HailoLibero::getCookie", $hash );
Log3 $name, 4, Log3 $name, 4,
"HailoLibero ($name) - set internal timer function for recall getSettings sub"; "HailoLibero ($name) - set internal timer function for recall getCookie sub";
} }
return; return;