更新版本号,重构核心类,移除未使用的自动化和事件功能,优化灯光管理,调整测试用例以适应新结构
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { auto, showMore } from './common.ts'
|
||||
|
||||
const autos = await auto.getAutos();
|
||||
const autos = await auto.getServiceEntities();
|
||||
|
||||
console.log(showMore(autos));
|
||||
@@ -13,16 +13,10 @@ export const auto = new AutoHA({ token: process.env.HAAS_TOKEN || '', homeassist
|
||||
export const event = new EventHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
export const script = new ScriptHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
|
||||
// const enti = await hacore.getLights();
|
||||
// console.log(showMore(enti), enti.length);
|
||||
const enti = await hacore.getEntities((item) => item.attributes?.friendly_name?.includes('电视'));
|
||||
console.log(showMore(enti), enti.length);
|
||||
|
||||
// const lightEntities = enti.filter((entity: any) => {
|
||||
// const hasLight = entity.entity_id.startsWith('light.');
|
||||
// const name = entity.attributes?.friendly_name || '';
|
||||
|
||||
// // return hasLight && name.includes('次卧');
|
||||
// return hasLight;
|
||||
// });
|
||||
// const lightEntities = await hacore.getInfoList();
|
||||
|
||||
// console.log(showMore(lightEntities));
|
||||
|
||||
@@ -116,7 +110,7 @@ export const script = new ScriptHA({ token: process.env.HAAS_TOKEN || '', homeas
|
||||
// }
|
||||
// ]
|
||||
|
||||
// const res = await hacore.toggleLight({
|
||||
// const res = await hacore.runService({
|
||||
// // name: '次卧灯',
|
||||
// // service: 'turn_off'
|
||||
// name: '阳台灯'
|
||||
|
||||
@@ -2,6 +2,7 @@ import { hacore, showMore } from "./common.ts";
|
||||
import Fuse from 'fuse.js';
|
||||
|
||||
const devices = await hacore.getInfoList();
|
||||
console.log(showMore(devices));
|
||||
const fuse = new Fuse(devices, {
|
||||
keys: ['name'], // 搜索字段
|
||||
threshold: 0.4, // 匹配宽松度:0~1,越小越严格
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { script, showMore } from './common.ts';
|
||||
|
||||
const scripts = await script.getScripts();
|
||||
const scripts = await script.getEntities();
|
||||
|
||||
const values = scripts.map(e => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user