From e7eda90b79f3c012885107689ac776784d66b78b Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 30 Aug 2018 19:38:48 +0000 Subject: [PATCH] fhem.pl: delFromDevAttrList from CoolTux (Forum #90698) git-svn-id: https://svn.fhem.de/fhem/trunk@17235 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 3dd06271a..00a066af1 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -3958,6 +3958,24 @@ addToDevAttrList($$) $attr{$dev}{userattr} = join(" ", sort keys %hash); } +# The counterpart: delete it. +sub +delFromDevAttrList($$) +{ + my ($dev,$arg) = @_; + + my $ua = $attr{$dev}{userattr}; + $ua = "" if(!$ua); + my %hash = map { ($_ => 1) } + grep { " $arg " !~ m/ $_ / } + split(" ", "$ua $arg"); + $attr{$dev}{userattr} = join(" ", sort keys %hash); + delete $attr{$dev}{userattr} + if(!keys %hash && defined($attr{$dev}{userattr})); + map { delete $attr{$dev}{$_} } split(" ", $arg); +} + + sub addToAttrList($) {