This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

easy way to search trough scenes?
#2
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>
Reply


Messages In This Thread
RE: easy way to search trough scenes? - by admin - 30.01.2025, 06:40

Forum Jump: