添加 ButtonHA 类及其服务功能,更新相关测试用例以支持新功能
This commit is contained in:
9
test/button.ts
Normal file
9
test/button.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { button, showMore } from "./common.ts";
|
||||
|
||||
const buttons = await button.getServiceEntities();
|
||||
|
||||
// console.log(showMore(buttons));
|
||||
|
||||
const tv = buttons.filter(b => b.attributes?.friendly_name?.includes('电视控制'));
|
||||
|
||||
console.log(showMore(tv));
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LightHA, AutoHA, EventHA, ScriptHA } from "../src/index.ts";
|
||||
import { LightHA, AutoHA, EventHA, ScriptHA, ButtonHA } from "../src/index.ts";
|
||||
|
||||
import util from 'node:util';
|
||||
import dotenv from 'dotenv';
|
||||
@@ -12,9 +12,10 @@ export const hacore = new LightHA({ token: process.env.HAAS_TOKEN || '', homeass
|
||||
export const auto = new AutoHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
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 });
|
||||
export const button = new ButtonHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
|
||||
const enti = await hacore.getEntities((item) => item.attributes?.friendly_name?.includes('电视'));
|
||||
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 = await hacore.getInfoList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user