![]() |
|
easy way to search trough scenes? - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: easy way to search trough scenes? (/showthread.php?tid=5871) |
easy way to search trough scenes? - kgroenhoej - 29.01.2025 Is there an easy way to search for a GA in all scenes? I use "print script listings" to search trough all the scripts for a specific text a lot - and I would love to have a similar "dump" of all the scenes. Thanks. RE: easy way to search trough scenes? - admin - 30.01.2025 Create scenes.lp file and upload it via FTP to user directory using apps login. FTP can be enabled in System config > Services. Then you can access it via http://LM_IP/user/scenes.lp Code: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/apps/css/bootstrap.css.gz">
<style>body { padding: 20px 20px 0 20px; }</style>
<title>Scenes</title>
</head>
<body>
<table class="table">
<?
require('apps')
function isdefined(val)
return toboolean(val)
end
function numtoga(addr)
return isdefined(addr) and buslib.decodega(addr) or ''
end
scenes = db:getall([[
SELECT s.id, s.name, s.trig_object, s.trig_value, o.name AS trig_name
FROM scenes s
LEFT JOIN objects o ON s.trig_object=o.id
ORDER BY s.name
]])
for _, scene in ipairs(scenes) do
?>
<tr class="bg-primary">
<td colspan="3"><b><?=escape(scene.name)?></b></td>
</tr>
<?
if isdefined(scene.trig_object) then
?>
<tr class="bg-info">
<td><?=numtoga(scene.trig_object)?></td>
<td><?=escape(scene.trig_name or '')?></td>
<td><?=escape(scene.trig_value)?></td>
</tr>
<?
end
sequence = db:getall([[
SELECT s.object, s.value, o.name
FROM scene_sequence s
LEFT JOIN objects o ON s.object=o.id
WHERE s.scene=?
ORDER BY s.sortorder
]], scene.id)
for _, item in ipairs(sequence) do
?>
<tr>
<td><?=numtoga(item.object)?></td>
<td><?=escape(item.name or '')?></td>
<td><?=escape(item.value)?></td>
</tr>
<?
end
end
?>
</table>
</body>
</html>RE: easy way to search trough scenes? - kgroenhoej - 30.01.2025 Super - it works perfect. Thanks for your fantastic support (as always). RE: easy way to search trough scenes? - kgroenhoej - 20.02.2025 Hi Admin is it possible to do the same/similar for the Homekit-app? RE: easy way to search trough scenes? - admin - 21.02.2025 Try this: Code: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/apps/css/bootstrap.css.gz">
<style>body { padding: 20px 20px 0 20px; }</style>
<title>Homekit</title>
</head>
<body>
<table class="table">
<?
require('apps')
devices = storage.exec('hgetall', 'app:homekit:devices')
for _, device in pairs(devices) do
props = json.pdecode(device) or {}
?>
<tr class="bg-primary">
<td colspan="2"><b><?=escape(props.name)?></b> (<?=escape(props.type)?>)</td>
</tr>
<?
for key, val in pairs(props) do
if (key:find('_status') or key:find('_control')) and type(val) == 'string' and #val > 0 then
?>
<tr>
<td><?=escape(key)?></td>
<td><?=escape(val)?></td>
</tr>
<?
end
end
end
?>
</table>
</body>
</html>RE: easy way to search trough scenes? - kgroenhoej - 21.02.2025 (21.02.2025, 09:53)admin Wrote: Try this: Works perfectly :-) Thanks again (and again and ...) |