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

View File

@ -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

View File

@ -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;