From db66e5bc5491aad079307e4bffba2387b6a11333 Mon Sep 17 00:00:00 2001 From: erwin <> Date: Sun, 22 Jan 2023 18:26:08 +0000 Subject: [PATCH] 10_KNX.pm: feature KNX_scan cmd, (Forum #122582) git-svn-id: https://svn.fhem.de/fhem/trunk@27104 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_KNX.pm | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/10_KNX.pm b/fhem/FHEM/10_KNX.pm index fc553c3be..a7755d915 100644 --- a/fhem/FHEM/10_KNX.pm +++ b/fhem/FHEM/10_KNX.pm @@ -115,6 +115,7 @@ # modify KNX_parse - reply msg code # modify KNX_set # add pulldown menu for attr IODev with vaild IO-devs +# KNX_scan now avail also from cmd-line package KNX; ## no critic 'package' @@ -148,6 +149,7 @@ BEGIN { AssignIoPort IOWrite CommandDefMod CommandModify CommandDelete defs modules attr + cmds FW_detail FW_wname FW_directNotify readingFnAttributes InternalTimer RemoveInternalTimer @@ -428,6 +430,10 @@ sub Initialize { "$readingFnAttributes "; #standard attributes $hash->{noAutocreatedFilelog} = 1; # autocreate devices create no FileLog $hash->{AutoCreate} = {'KNX_.*' => { ATTR => 'disable:1'} }; #autocreate devices are disabled by default + + # register KNX_scan cmd (use from cmd-line) + $cmds{KNX_scan} = { Fn => "KNX_scancmd", Hlp => ', get values from KNX-devices',}; + return; } @@ -1921,6 +1927,13 @@ sub KNX_gadNameByNO { } ########## public utility functions ########## +# when called from FHEM cmd-line +sub main::KNX_scancmd { + my $cl = shift; + my $devs = shift; + $devs = undef if ($devs eq q{}); + return main::KNX_scan($devs); +} ### get state of devices from KNX_Hardware # called with devspec as argument @@ -2341,19 +2354,27 @@ The result of the "get" cmd will be stored in the respective readings - same as Returns number of "get's" issued.

Examples:
-KNX_scan()                    - scan all possible devices
-KNX_scan('dev-A')             - scan device-A only
-KNX_scan('dev-A,dev-B,dev-C') - scan device-A, device-B, device-C
-KNX_scan('room=Kueche')       - scan all KNX-devices in room Kueche
-{KNX_scan('device')}          - syntax when used from FHEM-cmdline
-knxscan device                - syntax when used from FHEM-cmdline via cmd-alias definition, see below
+syntax when used as perl-function (eg. in at, notify,...)
+   KNX_scan()                    - scan all possible devices
+   KNX_scan('dev-A')             - scan device-A only
+   KNX_scan('dev-A,dev-B,dev-C') - scan device-A, device-B, device-C
+   KNX_scan('room=Kueche')       - scan all KNX-devices in room Kueche
+   KNX_scan('EG_.*')             - scan all KNX-devices where device-names begin with EG_ 
+syntax when used from FHEM-cmdline
+   KNX_scan                      - scan all possible devices
+   KNX_scan dev-A                - scan device-A only
+   KNX_scan dev-A,dev-B,dev-C    - scan device-A, device-B, device-C
+   KNX_scan room=Kueche          - scan all KNX-devices in room Kueche
+   KNX_scan EG_.*                - scan all KNX-devices where device-names begin with EG_
 
-When using KNX_scan() or any 'set|get <device> ...' in a global:INITIALIZED notify, pls. ensure to have some delay in processing the cmd's by using fhem sleep. +When using KNX_scan or any 'set or get <device> ...' in a global:INITIALIZED notify, pls. ensure to have some delay in processing the cmd's by using fhem sleep.
Example:
-defmod initialized_nf notify global:INITIALIZED sleep 10 quiet;; set KNX_date now;; set KNX_time now;; {KNX_scan();;} +defmod initialized_nf notify global:INITIALIZED sleep 10 quiet;; set KNX_date now;; set KNX_time now;; KNX_scan;;
This avoids sending requests while the KNX-Gateway has not finished its initial handshake-procedure with FHEM (the KNX-IO-device). +