From 714db9fb2541bdec086a6fedefe0ce6641b1ee61 Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Sun, 17 Mar 2024 08:51:28 +0100 Subject: [PATCH] ADD: own function for parsing subscriptions --- FHEM/98_NTFY_CLIENT.pm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/FHEM/98_NTFY_CLIENT.pm b/FHEM/98_NTFY_CLIENT.pm index 7c49efb..e2831ad 100644 --- a/FHEM/98_NTFY_CLIENT.pm +++ b/FHEM/98_NTFY_CLIENT.pm @@ -150,17 +150,25 @@ sub NTFY_Define return; } +sub NTFY_Get_Subscriptions +{ + my $hash = shift; + my @subscriptions; + + for my $k (keys %{$modules{NTFY_TOPIC}{defptr}}) + { + $k=~/^(.*)_(.*)$/; + push(@subscriptions,$2); + } + + return @subscriptions; +} + sub NTFY_Update_Subscriptions_Readings { my $hash = shift; - my @topics; + my @topics = NTFY_Get_Subscriptions($hash); - for my $k (keys %{$modules{NTFY_TOPIC}{defptr}}) - { - $k=~/^(.*)_(.*)$/; - push(@topics,$2); - } - readingsSingleUpdate($hash,"subscriptions", join(",", @topics),1); }