ADD: delete subscribed topics on delete of client device

This commit is contained in:
Dominik Meyer 2024-02-25 13:33:25 +01:00
parent 8490e7046f
commit 2d613ea87e
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97

View File

@ -112,6 +112,7 @@ sub NTFY_CLIENT_Initialize
$hash->{ReadFn} = 'NTFY_Read'; $hash->{ReadFn} = 'NTFY_Read';
$hash->{AttrFn} = 'NTFY_Attr'; $hash->{AttrFn} = 'NTFY_Attr';
$hash->{ParseFn} = 'NTFY_Parse'; $hash->{ParseFn} = 'NTFY_Parse';
$hash->{DeleteFn} = 'NTFY_Delete';
$hash->{AttrList} = "defaultTopic " $hash->{AttrList} = "defaultTopic "
. $readingFnAttributes; . $readingFnAttributes;
@ -417,6 +418,19 @@ sub NTFY_Parse ($$)
return; return;
} }
sub NTFY_Delete
{
my ( $hash, $name ) = @_;
#we need to delete all topic devices
for my $k (keys %{$modules{NTFY_TOPIC}{defptr}})
{
$k=~/^(.*)_(.*)$/;
my $h = $modules{NTFY_TOPIC}{defptr}{$k};
fhem("delete " . $h->{NAME});
}
}
1; 1;
######################################### #########################################