AI_UIAutomation/scripts/probe-lights.ts

21 lines
739 B
TypeScript

import { createDriver } from '../drivers/factory';
(async () => {
const d = createDriver();
await d.createSession();
try {
await d.dismissPopupIfPresent(); await d.goBackToHomepage();
await new Promise(r=>setTimeout(r,1000));
const names = new Set<string>();
for (let i=0;i<10;i++){
const src = await d.getSource();
for (const m of src.matchAll(/text="([^"]+)"/g)) {
const t=m[1];
if (/light|lamp|bulb|neon|strip|ceiling|floor|outdoor/i.test(t)) names.add(t);
}
await d.swipe(540,1500,540,700,0.4).catch(()=>{});
await new Promise(r=>setTimeout(r,700));
}
console.log('LIGHTS_ON_HOME='+JSON.stringify([...names]));
} finally { await d.destroySession(); }
})();