mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 17:26:34 +00:00
configDB - added command "search" for full text search in configDB
git-svn-id: https://svn.fhem.de/fhem/trunk@5697 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
01a1c4598f
commit
29fc8182b6
@ -1,6 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
- SVN
|
- SVN
|
||||||
|
- feature: configdb: new command search
|
||||||
- feature: LUXTRONIK2: estimation of electrical power consumption,
|
- feature: LUXTRONIK2: estimation of electrical power consumption,
|
||||||
considers time depending tariffs (activeTariff)
|
considers time depending tariffs (activeTariff)
|
||||||
- added: configDB functions for handling binary files
|
- added: configDB functions for handling binary files
|
||||||
|
@ -301,6 +301,14 @@ sub CommandConfigdb($$) {
|
|||||||
$ret = _cfgDB_Reorg($a[1]);
|
$ret = _cfgDB_Reorg($a[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when ('search') {
|
||||||
|
return "\n Syntax: configdb search <searchTerm> [searchVersion]" if @a < 2;
|
||||||
|
$param1 = $param1 ? $param1 : '%';
|
||||||
|
$param2 = $param2 ? $param2 : 0;
|
||||||
|
Log3('configdb', 4, "configdb: list requested for device: $param1 in version $param2.");
|
||||||
|
$ret = _cfgDB_Search($param1,$param2);
|
||||||
|
}
|
||||||
|
|
||||||
when ('uuid') {
|
when ('uuid') {
|
||||||
$param1 = _cfgDB_Uuid;
|
$param1 = _cfgDB_Uuid;
|
||||||
Log3('configdb', 4, "configdb: uuid requested: $param1");
|
Log3('configdb', 4, "configdb: uuid requested: $param1");
|
||||||
@ -311,19 +319,20 @@ sub CommandConfigdb($$) {
|
|||||||
$ret = "\n Syntax:\n".
|
$ret = "\n Syntax:\n".
|
||||||
" configdb attr [attribute] [value]\n".
|
" configdb attr [attribute] [value]\n".
|
||||||
" configdb backup\n".
|
" configdb backup\n".
|
||||||
" configDB binfileimport <pathToFilename>\n"
|
" configDB binfileimport <pathToFilename>\n".
|
||||||
" configdb diff <device> <version>\n".
|
" configdb diff <device> <version>\n".
|
||||||
" configDB filedelete <pathToFilename>\n"
|
" configDB filedelete <pathToFilename>\n".
|
||||||
" configDB fileimport <pathToFilename>\n"
|
" configDB fileimport <pathToFilename>\n".
|
||||||
" configDB fileexport <pathToFilename>\n"
|
" configDB fileexport <pathToFilename>\n".
|
||||||
" configDB filelist\n"
|
" configDB filelist\n".
|
||||||
" configDB filemove <pathToFilename>\n"
|
" configDB filemove <pathToFilename>\n".
|
||||||
" configDB fileshow <pathToFilename>\n"
|
" configDB fileshow <pathToFilename>\n".
|
||||||
" configdb info\n".
|
" configdb info\n".
|
||||||
" configdb list [device] [version]\n".
|
" configdb list [device] [version]\n".
|
||||||
" configdb migrate\n".
|
" configdb migrate\n".
|
||||||
" configdb recover <version>\n".
|
" configdb recover <version>\n".
|
||||||
" configdb reorg [keepVersions]\n".
|
" configdb reorg [keepVersions]\n".
|
||||||
|
" configdb search <searchTerm> [version]\n".
|
||||||
" configdb uuid\n".
|
" configdb uuid\n".
|
||||||
"";
|
"";
|
||||||
}
|
}
|
||||||
@ -614,6 +623,29 @@ Ver 0 always indicates the currently running configuration.<br/>
|
|||||||
database reorganisation when called from an at-Definition.<br/>
|
database reorganisation when called from an at-Definition.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<li><code>configdb search <searchTerm> [searchVersion]</code></li><br/>
|
||||||
|
Search for specified searchTerm in any given version (default=0)<br/>
|
||||||
|
<pre>
|
||||||
|
Example:
|
||||||
|
|
||||||
|
configdb search %2286BC%
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
search result for: %2286BC% in version: 0
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
define az_RT CUL_HM 2286BC
|
||||||
|
define az_RT_Clima CUL_HM 2286BC04
|
||||||
|
define az_RT_Climate CUL_HM 2286BC02
|
||||||
|
define az_RT_ClimaTeam CUL_HM 2286BC05
|
||||||
|
define az_RT_remote CUL_HM 2286BC06
|
||||||
|
define az_RT_Weather CUL_HM 2286BC01
|
||||||
|
define az_RT_WindowRec CUL_HM 2286BC03
|
||||||
|
attr Melder_FAl peerIDs 00000000,2286BC03,
|
||||||
|
attr Melder_FAr peerIDs 00000000,2286BC03,
|
||||||
|
</pre>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<li><code>configdb uuid</code></li><br/>
|
<li><code>configdb uuid</code></li><br/>
|
||||||
Returns a uuid that can be used for own purposes.<br/>
|
Returns a uuid that can be used for own purposes.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
@ -927,6 +959,29 @@ Ver 0 bezeichnet immer die aktuell verwendete Konfiguration.<br/>
|
|||||||
Mit dieser Funktion läßt sich eine nächtliche Reorganisation per at umsetzen.<br/>
|
Mit dieser Funktion läßt sich eine nächtliche Reorganisation per at umsetzen.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<li><code>configdb search <suchBegriff> [inVersion]</code></li><br/>
|
||||||
|
Sucht nach dem Suchbegriff in der angegeben Konfigurationsversion (default=0)<br/>
|
||||||
|
<pre>
|
||||||
|
Beispiel:
|
||||||
|
|
||||||
|
configdb search %2286BC%
|
||||||
|
|
||||||
|
Ergebnis:
|
||||||
|
|
||||||
|
search result for: %2286BC% in version: 0
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
define az_RT CUL_HM 2286BC
|
||||||
|
define az_RT_Clima CUL_HM 2286BC04
|
||||||
|
define az_RT_Climate CUL_HM 2286BC02
|
||||||
|
define az_RT_ClimaTeam CUL_HM 2286BC05
|
||||||
|
define az_RT_remote CUL_HM 2286BC06
|
||||||
|
define az_RT_Weather CUL_HM 2286BC01
|
||||||
|
define az_RT_WindowRec CUL_HM 2286BC03
|
||||||
|
attr Melder_FAl peerIDs 00000000,2286BC03,
|
||||||
|
attr Melder_FAr peerIDs 00000000,2286BC03,
|
||||||
|
</pre>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<li><code>configdb uuid</code></li><br/>
|
<li><code>configdb uuid</code></li><br/>
|
||||||
Liefert eine uuid, die man für eigene Zwecke verwenden kann.<br/>
|
Liefert eine uuid, die man für eigene Zwecke verwenden kann.<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -705,6 +705,29 @@ sub _cfgDB_List(;$$) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _cfgDB_Search($;$) {
|
||||||
|
my ($search,$searchversion) = @_;
|
||||||
|
return 'Syntax error.' if(!(defined($search)));
|
||||||
|
$searchversion = $searchversion ? $searchversion : 0;
|
||||||
|
my $fhem_dbh = _cfgDB_Connect;
|
||||||
|
my ($sql, $sth, @line, $row, @result, $ret);
|
||||||
|
$sql = "SELECT command, device, p1, p2 FROM fhemconfig as c join fhemversions as v ON v.versionuuid=c.versionuuid ".
|
||||||
|
"WHERE v.version = '$searchversion' AND command not like '#create%' ".
|
||||||
|
"AND (device like '$search%' OR P1 like '$search%' OR P2 like '$search%') ".
|
||||||
|
"ORDER BY lower(device),command DESC";
|
||||||
|
$sth = $fhem_dbh->prepare( $sql);
|
||||||
|
$sth->execute();
|
||||||
|
push @result, "search result for: $search in version: $searchversion";
|
||||||
|
push @result, "--------------------------------------------------------------------------------";
|
||||||
|
while (@line = $sth->fetchrow_array()) {
|
||||||
|
$row = "$line[0] $line[1] $line[2] $line[3]";
|
||||||
|
push @result, "$row";
|
||||||
|
}
|
||||||
|
$fhem_dbh->disconnect();
|
||||||
|
$ret = join("\n", @result);
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
# called from cfgDB_Diff
|
# called from cfgDB_Diff
|
||||||
sub __cfgDB_Diff($$$) {
|
sub __cfgDB_Diff($$$) {
|
||||||
my ($fhem_dbh,$search,$searchversion) = @_;
|
my ($fhem_dbh,$search,$searchversion) = @_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user