From 308643471c209e2679c83f4be00a97b8842ae006 Mon Sep 17 00:00:00 2001 From: zap <> Date: Fri, 4 Feb 2022 14:37:05 +0000 Subject: [PATCH] AndroidDB: added attribute presetFile git-svn-id: https://svn.fhem.de/fhem/trunk@25626 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/89_AndroidDB.pm | 21 +++++++++++++-------- fhem/FHEM/89_AndroidDBHost.pm | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 0cf425fe8..7088cb9c2 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 89_AndroidDB: added attribute presetFile - bugfix: 70_ESCVP21net.pm: fix perl warning, set standard port - feature: 88_HMCCU.pm: Optimized RPC requests - feature: 30_HUEBridge: added get v2effects & set v2json diff --git a/fhem/FHEM/89_AndroidDB.pm b/fhem/FHEM/89_AndroidDB.pm index ea0ad9b8b..86eb0fea5 100644 --- a/fhem/FHEM/89_AndroidDB.pm +++ b/fhem/FHEM/89_AndroidDB.pm @@ -4,7 +4,7 @@ # # 89_AndroidDB # -# Version 0.3 +# Version 0.4 # # FHEM Integration for Android Devices # @@ -36,7 +36,7 @@ sub AndroidDB_Initialize ($) $hash->{ShutdownFn} = "AndroidDB::Shutdown"; $hash->{parseParams} = 1; - $hash->{AttrList} = 'macros:textField-long preset:MagentaTVStick,SonyTV'; + $hash->{AttrList} = 'macros:textField-long preset:MagentaTVStick,SonyTV presetFile'; } package AndroidDB; @@ -195,9 +195,10 @@ sub Attr ($@) $PRESET{_custom_}{$macroName} = $macroKeycodes; } } - elsif ($attrName eq 'preset' && $attrVal =~ /^\@(.+)$/) { - if (!LoadPreset ($hash, $1)) { - Log3 $hash, 2, "Can't load preset from file $1"; + elsif ($attrName eq 'presetFile') { + if (!LoadPreset ($hash, $attrVal)) { + Log3 $hash, 2, "Can't load preset from file $attrVal"; + return "Cannot load preset from file $attrVal"; } } } @@ -306,9 +307,13 @@ sub LoadPreset ($$) Several macro definitions can be specified by seperating them using a blank character.
-
  • preset {<PresetName>|@<PresetFileName>}
    - Select a preset of keycode macros or load a set of macros from a preset defintion - file. If the same macro name is defined in the selected +
  • preset <PresetName>
    + Select a preset of keycode macros. +

  • + +
  • presetFile <Filename>
    + Load a set of macros from a preset defintion file. + If the same macro name is defined in the selected preset and in attribute 'macros', the definition in the 'macros' attribute overwrites the definition in the preset.
    A preset defintion file is using the following format:
    diff --git a/fhem/FHEM/89_AndroidDBHost.pm b/fhem/FHEM/89_AndroidDBHost.pm index a01c48589..3660cae32 100644 --- a/fhem/FHEM/89_AndroidDBHost.pm +++ b/fhem/FHEM/89_AndroidDBHost.pm @@ -45,7 +45,7 @@ package AndroidDBHost; use strict; use warnings; -use Data::Dumper; +# use Data::Dumper; use IPC::Open3; use SetExtensions;