mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Add support for 'indicator_ctrl' service
This commit is contained in:
parent
e8274850d1
commit
dcab7a7112
@ -6,6 +6,7 @@
|
|||||||
- Set 'battery' entity category to 'diagnostic' to hide it from the main HA view.
|
- Set 'battery' entity category to 'diagnostic' to hide it from the main HA view.
|
||||||
- Do not expose 'battery' entity twice if it supports both level and low/high binary state.
|
- Do not expose 'battery' entity twice if it supports both level and low/high binary state.
|
||||||
- Changed the default 'sensor_lumin' unit from 'Lux' to 'lx'.
|
- Changed the default 'sensor_lumin' unit from 'Lux' to 'lx'.
|
||||||
|
- Added support for 'indicator_ctrl' service (identify devices).
|
||||||
|
|
||||||
# 0.1.0 (24.07.2025)
|
# 0.1.0 (24.07.2025)
|
||||||
|
|
||||||
|
@ -156,15 +156,15 @@ todo: links to the .ts service implementations below
|
|||||||
|
|
||||||
## System or meta, not essential services
|
## System or meta, not essential services
|
||||||
|
|
||||||
| Service | Implementation status |
|
| Service | Implementation status | Description |
|
||||||
| --- | --- |
|
| --- | --- | --- |
|
||||||
| gateway | |
|
| gateway | | |
|
||||||
| association | |
|
| association | | |
|
||||||
| diagnostic | |
|
| diagnostic | | |
|
||||||
| indicator_ctrl | |
|
| indicator_ctrl | ✅ | Identify devices |
|
||||||
| ota | |
|
| ota | | |
|
||||||
| parameters | |
|
| parameters | | |
|
||||||
| technology_specific | |
|
| technology_specific | | |
|
||||||
| time | |
|
| time | | |
|
||||||
| version | |
|
| version | | |
|
||||||
| dev_sys | |
|
| dev_sys | | |
|
||||||
|
@ -43,6 +43,7 @@ export async function sendFimpMsg({
|
|||||||
cmd,
|
cmd,
|
||||||
val,
|
val,
|
||||||
val_t,
|
val_t,
|
||||||
|
props = {},
|
||||||
timeoutMs = 10000,
|
timeoutMs = 10000,
|
||||||
}: {
|
}: {
|
||||||
address: string;
|
address: string;
|
||||||
@ -50,6 +51,7 @@ export async function sendFimpMsg({
|
|||||||
cmd: string;
|
cmd: string;
|
||||||
val: unknown;
|
val: unknown;
|
||||||
val_t: FimpValueType;
|
val_t: FimpValueType;
|
||||||
|
props?: any;
|
||||||
timeoutMs?: number;
|
timeoutMs?: number;
|
||||||
}): Promise<FimpResponse> {
|
}): Promise<FimpResponse> {
|
||||||
const uid = uuidv4();
|
const uid = uuidv4();
|
||||||
@ -57,7 +59,7 @@ export async function sendFimpMsg({
|
|||||||
const message = JSON.stringify({
|
const message = JSON.stringify({
|
||||||
corid: null,
|
corid: null,
|
||||||
ctime: new Date().toISOString(),
|
ctime: new Date().toISOString(),
|
||||||
props: {},
|
props: props,
|
||||||
resp_to: 'pt:j1/mt:rsp/rt:app/rn:ha-futurehome/ad:addon',
|
resp_to: 'pt:j1/mt:rsp/rt:app/rn:ha-futurehome/ad:addon',
|
||||||
serv: service,
|
serv: service,
|
||||||
src: 'ha-futurehome',
|
src: 'ha-futurehome',
|
||||||
|
@ -8,6 +8,7 @@ import { basic__components } from '../services/basic';
|
|||||||
import { battery__components } from '../services/battery';
|
import { battery__components } from '../services/battery';
|
||||||
import { color_ctrl__components } from '../services/color_ctrl';
|
import { color_ctrl__components } from '../services/color_ctrl';
|
||||||
import { fan_ctrl__components } from '../services/fan_ctrl';
|
import { fan_ctrl__components } from '../services/fan_ctrl';
|
||||||
|
import { indicator_ctrl__components } from '../services/indicator_ctrl';
|
||||||
import { out_bin_switch__components } from '../services/out_bin_switch';
|
import { out_bin_switch__components } from '../services/out_bin_switch';
|
||||||
import { out_lvl_switch__components } from '../services/out_lvl_switch';
|
import { out_lvl_switch__components } from '../services/out_lvl_switch';
|
||||||
import { scene_ctrl__components } from '../services/scene_ctrl';
|
import { scene_ctrl__components } from '../services/scene_ctrl';
|
||||||
@ -161,6 +162,7 @@ const serviceHandlers: {
|
|||||||
battery: battery__components,
|
battery: battery__components,
|
||||||
color_ctrl: color_ctrl__components,
|
color_ctrl: color_ctrl__components,
|
||||||
fan_ctrl: fan_ctrl__components,
|
fan_ctrl: fan_ctrl__components,
|
||||||
|
indicator_ctrl: indicator_ctrl__components,
|
||||||
out_bin_switch: out_bin_switch__components,
|
out_bin_switch: out_bin_switch__components,
|
||||||
out_lvl_switch: out_lvl_switch__components,
|
out_lvl_switch: out_lvl_switch__components,
|
||||||
scene_ctrl: scene_ctrl__components,
|
scene_ctrl: scene_ctrl__components,
|
||||||
|
54
futurehome/src/services/indicator_ctrl.ts
Normal file
54
futurehome/src/services/indicator_ctrl.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { sendFimpMsg } from '../fimp/fimp';
|
||||||
|
import {
|
||||||
|
VinculumPd7Device,
|
||||||
|
VinculumPd7Service,
|
||||||
|
} from '../fimp/vinculum_pd7_device';
|
||||||
|
import { HaMqttComponent } from '../ha/mqtt_components/_component';
|
||||||
|
import {
|
||||||
|
CommandHandlers,
|
||||||
|
ServiceComponentsCreationResult,
|
||||||
|
} from '../ha/publish_device';
|
||||||
|
|
||||||
|
export function indicator_ctrl__components(
|
||||||
|
topicPrefix: string,
|
||||||
|
device: VinculumPd7Device,
|
||||||
|
svc: VinculumPd7Service,
|
||||||
|
): ServiceComponentsCreationResult | undefined {
|
||||||
|
const components: Record<string, HaMqttComponent> = {};
|
||||||
|
const commandHandlers: CommandHandlers = {};
|
||||||
|
|
||||||
|
if (svc.intf?.includes('cmd.indicator.set_visual_element')) {
|
||||||
|
const commandTopic = `${topicPrefix}${svc.addr}/cmd.indicator.set_visual_element/command`;
|
||||||
|
|
||||||
|
components[`${svc.addr}/set_visual_element`] = {
|
||||||
|
unique_id: `${svc.addr}/set_visual_element`,
|
||||||
|
platform: 'button',
|
||||||
|
entity_category: 'diagnostic',
|
||||||
|
device_class: 'identify',
|
||||||
|
command_topic: commandTopic,
|
||||||
|
};
|
||||||
|
|
||||||
|
commandHandlers[commandTopic] = async (_payload: string) => {
|
||||||
|
await sendFimpMsg({
|
||||||
|
address: svc.addr,
|
||||||
|
service: 'indicator_ctrl',
|
||||||
|
cmd: 'cmd.indicator.set_visual_element',
|
||||||
|
val_t: 'null',
|
||||||
|
val: null,
|
||||||
|
props: {
|
||||||
|
duration: '3',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd.indicator.set_text is not used anymore
|
||||||
|
|
||||||
|
// since cmd.indicator.set_visual_element should always be present when cmd.indicator.identify is,
|
||||||
|
// there's no need to handle cmd.indicator.identify separately.
|
||||||
|
|
||||||
|
return {
|
||||||
|
components,
|
||||||
|
commandHandlers,
|
||||||
|
};
|
||||||
|
}
|
@ -28,7 +28,7 @@ export function scene_ctrl__components(
|
|||||||
svc: VinculumPd7Service,
|
svc: VinculumPd7Service,
|
||||||
): ServiceComponentsCreationResult | undefined {
|
): ServiceComponentsCreationResult | undefined {
|
||||||
const components: Record<string, HaMqttComponent> = {};
|
const components: Record<string, HaMqttComponent> = {};
|
||||||
const handlers: CommandHandlers = {};
|
const commandHandlers: CommandHandlers = {};
|
||||||
|
|
||||||
// ───────────── read-only entities ─────────────
|
// ───────────── read-only entities ─────────────
|
||||||
if (svc.intf?.includes('evt.scene.report')) {
|
if (svc.intf?.includes('evt.scene.report')) {
|
||||||
@ -63,7 +63,7 @@ export function scene_ctrl__components(
|
|||||||
value_template: `{{ value_json['${svc.addr}'].scene }}`,
|
value_template: `{{ value_json['${svc.addr}'].scene }}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
handlers[commandTopic] = async (payload: string) => {
|
commandHandlers[commandTopic] = async (payload: string) => {
|
||||||
if (!supScenes.includes(payload)) return; // ignore bogus payloads
|
if (!supScenes.includes(payload)) return; // ignore bogus payloads
|
||||||
|
|
||||||
await sendFimpMsg({
|
await sendFimpMsg({
|
||||||
@ -81,6 +81,6 @@ export function scene_ctrl__components(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
components,
|
components,
|
||||||
commandHandlers: Object.keys(handlers).length ? handlers : undefined,
|
commandHandlers,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user