update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { LightHA, AutoHA, EventHA, ScriptHA, ButtonHA } from "../src/index.ts";
|
||||
import { LightHA, AutoHA, EventHA, ScriptHA, ButtonHA, HACore, SpeakerHA, TextHA } from "../src/index.ts";
|
||||
|
||||
import util from 'node:util';
|
||||
import dotenv from 'dotenv';
|
||||
@@ -7,13 +7,15 @@ export const showMore = (obj: any) => {
|
||||
return util.inspect(obj, { depth: null, colors: true });
|
||||
}
|
||||
|
||||
export const hacore = new LightHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
export const hacore = new HACore({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
export const light = new LightHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
|
||||
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 });
|
||||
|
||||
export const speaker = new SpeakerHA({ token: process.env.HAAS_TOKEN || '', homeassistantURL: process.env.HAAS_URL });
|
||||
export const text = new TextHA({ 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);
|
||||
|
||||
|
||||
27
test/speaker.ts
Normal file
27
test/speaker.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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 }
|
||||
Reference in New Issue
Block a user