Follow-me stair light for the Apollo MTR-1 and WLED
ESPHome package for the Apollo MTR-1: tracks people on the stairs with the LD2450 radar and streams a lit window to a WLED controller over DDP. The sensor serves a setup wizard that measures the stairs with one walk and stores the setup on the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
24 files changed
+10874
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// Serves the wizard folder on the LAN so a phone can open it.
|
||||
// node wizard/tools/serve.mjs [port]
|
||||
// Then open http://<this machine>:<port>/ on the phone and enter the sensor's
|
||||
// address in the bar that opens (or add ?host=<address>).
|
||||
import http from 'node:http';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const port = +(process.argv[2] || 8080);
|
||||
const types = {'.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.mjs': 'text/javascript', '.json': 'application/json',
|
||||
'.css': 'text/css', '.woff2': 'font/woff2', '.txt': 'text/plain; charset=utf-8'};
|
||||
|
||||
http.createServer((req, res) => {
|
||||
const p = decodeURIComponent(new URL(req.url, 'http://x').pathname);
|
||||
const f = path.join(root, p === '/' ? 'wizard.html' : p);
|
||||
if (!f.startsWith(root + path.sep)) { res.writeHead(403).end(); return; }
|
||||
fs.readFile(f, (err, data) => {
|
||||
if (err) { res.writeHead(404).end('not found'); return; }
|
||||
res.writeHead(200, {'Content-Type': types[path.extname(f)] || 'application/octet-stream', 'Cache-Control': 'no-store'}).end(data);
|
||||
console.log(new Date().toLocaleTimeString(), req.socket.remoteAddress, p);
|
||||
});
|
||||
}).listen(port, '0.0.0.0', () => console.log(`serving ${root} on port ${port}`));
|
||||
Reference in new issue
Block a user