- Added LightHA class to manage light services. - Implemented searchLight method for device discovery. - Created app.ts and index.ts for application setup and routing. - Developed callText function to parse and execute light commands. - Established routes for handling Home Assistant control commands. - Configured Bun for building the application with TypeScript support.
27 lines
887 B
TypeScript
27 lines
887 B
TypeScript
import { speaker, showMore, text } from './common.ts';
|
|
|
|
// const entities = await speaker.getSpeakerEntities();
|
|
const entities = await text.getSpeakerEntities();
|
|
|
|
|
|
|
|
console.log(showMore(entities));
|
|
|
|
console.log(`实体数量: ${entities.length}`);
|
|
|
|
// const res = await speaker.runService({
|
|
// entity_id: 'text.xiaomi_lx06_9e08_execute_text_directive',
|
|
// service: 'set_value',
|
|
// serverName: 'text',
|
|
// data: {
|
|
// value: '关闭阳台灯'
|
|
// }
|
|
// });
|
|
|
|
// console.log(showMore(res));
|
|
|
|
const res2 = await text.executeTextDirective('text.xiaomi_lx06_9e08_execute_text_directive', '打开阳台灯');
|
|
|
|
console.log(showMore(res2));
|
|
|
|
// const call = { "type": "call_service", "domain": "text", "service": "set_value", "target": { "entity_id": "text.xiaomi_lx06_9e08_execute_text_directive" }, "return_response": false, "service_data": { "value": "关闭阳台灯" }, "id": 101 }
|