mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Add support for 'scene_ctrl' service
This commit is contained in:
parent
0a945b679a
commit
63533c0199
@ -67,7 +67,6 @@ todo periodical refresh of state
|
|||||||
| garage_door | | |
|
| garage_door | | |
|
||||||
| gas_detector | | |
|
| gas_detector | | |
|
||||||
| gate | | |
|
| gate | | |
|
||||||
| gateway | | |
|
|
||||||
| heat_detector | | |
|
| heat_detector | | |
|
||||||
| heat_pump | | |
|
| heat_pump | | |
|
||||||
| heater | | |
|
| heater | | |
|
||||||
@ -82,8 +81,7 @@ todo periodical refresh of state
|
|||||||
| out_bin_switch | | ✅ |
|
| out_bin_switch | | ✅ |
|
||||||
| out_lvl_switch | [Smart LED Dimmer](https://www.futurehome.io/en_no/shop/smart-led-dimmer-polar-white) | ✅ |
|
| out_lvl_switch | [Smart LED Dimmer](https://www.futurehome.io/en_no/shop/smart-led-dimmer-polar-white) | ✅ |
|
||||||
| power_regulator | | |
|
| power_regulator | | |
|
||||||
| scene_ctrl | | |
|
| scene_ctrl | | ✅ |
|
||||||
| sensor | | |
|
|
||||||
| sensor_accelx | | ✅ |
|
| sensor_accelx | | ✅ |
|
||||||
| sensor_accely | | ✅ |
|
| sensor_accely | | ✅ |
|
||||||
| sensor_accelz | | ✅ |
|
| sensor_accelz | | ✅ |
|
||||||
@ -132,13 +130,15 @@ todo periodical refresh of state
|
|||||||
| virtual_meter_elec | | |
|
| virtual_meter_elec | | |
|
||||||
| water_heater | | |
|
| water_heater | | |
|
||||||
| water_valve | | |
|
| water_valve | | |
|
||||||
|
|
||||||
|
| gateway | | |
|
||||||
|
| sensor | | |
|
||||||
| association | | |
|
| association | | |
|
||||||
| diagnostic | | |
|
| diagnostic | | |
|
||||||
| indicator_ctrl | | |
|
| indicator_ctrl | | |
|
||||||
| ota | | |
|
| ota | | |
|
||||||
| parameters | | |
|
| parameters | | |
|
||||||
| technology_specific | | |
|
| technology_specific | | |
|
||||||
|
|
||||||
| time | | |
|
| time | | |
|
||||||
| version | | |
|
| version | | |
|
||||||
| dev_sys | | |
|
| dev_sys | | |
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
||||||
name: Futurehome
|
name: Futurehome
|
||||||
version: "0.0.20"
|
version: "0.0.21"
|
||||||
slug: futurehome
|
slug: futurehome
|
||||||
description: Local Futurehome Smarthub integration
|
description: Local Futurehome Smarthub integration
|
||||||
url: "https://github.com/adrianjagielak/home-assistant-futurehome"
|
url: "https://github.com/adrianjagielak/home-assistant-futurehome"
|
||||||
|
@ -5,6 +5,7 @@ import { basic__components } from "../services/basic";
|
|||||||
import { battery__components } from "../services/battery";
|
import { battery__components } from "../services/battery";
|
||||||
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 { sensor_accelx__components } from "../services/sensor_accelx";
|
import { sensor_accelx__components } from "../services/sensor_accelx";
|
||||||
import { sensor_accely__components } from "../services/sensor_accely";
|
import { sensor_accely__components } from "../services/sensor_accely";
|
||||||
import { sensor_accelz__components } from "../services/sensor_accelz";
|
import { sensor_accelz__components } from "../services/sensor_accelz";
|
||||||
@ -80,7 +81,7 @@ type HaDeviceConfig = {
|
|||||||
qos: number,
|
qos: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HaComponent = SensorComponent | BinarySensorComponent | SwitchComponent | NumberComponent | ClimateComponent;
|
export type HaComponent = SensorComponent | BinarySensorComponent | SwitchComponent | NumberComponent | ClimateComponent | SelectComponent;
|
||||||
|
|
||||||
// Device class supported values: https://www.home-assistant.io/integrations/homeassistant/#device-class
|
// Device class supported values: https://www.home-assistant.io/integrations/homeassistant/#device-class
|
||||||
|
|
||||||
@ -148,6 +149,17 @@ export type ClimateComponent = {
|
|||||||
optimistic: boolean;
|
optimistic: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://www.home-assistant.io/integrations/select.mqtt/
|
||||||
|
export type SelectComponent = {
|
||||||
|
unique_id: string;
|
||||||
|
// platform
|
||||||
|
p: 'select';
|
||||||
|
options: string[];
|
||||||
|
command_topic: string;
|
||||||
|
optimistic: boolean;
|
||||||
|
value_template: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type ServiceComponentsCreationResult = {
|
export type ServiceComponentsCreationResult = {
|
||||||
components: { [key: string]: HaComponent };
|
components: { [key: string]: HaComponent };
|
||||||
commandHandlers?: CommandHandlers;
|
commandHandlers?: CommandHandlers;
|
||||||
@ -162,6 +174,7 @@ const serviceHandlers: {
|
|||||||
battery: battery__components,
|
battery: battery__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,
|
||||||
sensor_accelx: sensor_accelx__components,
|
sensor_accelx: sensor_accelx__components,
|
||||||
sensor_accely: sensor_accely__components,
|
sensor_accely: sensor_accely__components,
|
||||||
sensor_accelz: sensor_accelz__components,
|
sensor_accelz: sensor_accelz__components,
|
||||||
|
83
futurehome/src/services/scene_ctrl.ts
Normal file
83
futurehome/src/services/scene_ctrl.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Maps a Futurehome “scene_ctrl” service to MQTT entities
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// FIMP ➞ HA state paths used by the value templates
|
||||||
|
// value_json[svc.addr].scene – last reported scene name (string)
|
||||||
|
// value_json[svc.addr].lvl – last reported level (int)
|
||||||
|
//
|
||||||
|
// HA ➞ FIMP commands
|
||||||
|
// <topicPrefix><addr>/scene/command → cmd.scene.set
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
import { sendFimpMsg } from "../fimp/fimp";
|
||||||
|
import { VinculumPd7Device, VinculumPd7Service } from "../fimp/vinculum_pd7_device";
|
||||||
|
import {
|
||||||
|
CommandHandlers,
|
||||||
|
HaComponent,
|
||||||
|
ServiceComponentsCreationResult,
|
||||||
|
} from "../ha/publish_device";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates MQTT components for a single *scene_ctrl* service.
|
||||||
|
*/
|
||||||
|
export function scene_ctrl__components(
|
||||||
|
topicPrefix: string,
|
||||||
|
_device: VinculumPd7Device,
|
||||||
|
svc: VinculumPd7Service
|
||||||
|
): ServiceComponentsCreationResult | undefined {
|
||||||
|
const components: Record<string, HaComponent> = {};
|
||||||
|
const handlers: CommandHandlers = {};
|
||||||
|
|
||||||
|
// ───────────── read-only entities ─────────────
|
||||||
|
if (svc.intf?.includes("evt.scene.report")) {
|
||||||
|
components[`${svc.addr}_scene`] = {
|
||||||
|
unique_id: `${svc.addr}_scene`,
|
||||||
|
p: "sensor",
|
||||||
|
unit_of_measurement: "",
|
||||||
|
value_template: `{{ value_json['${svc.addr}'].scene }}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (svc.intf?.includes("evt.lvl.report")) {
|
||||||
|
components[`${svc.addr}_lvl`] = {
|
||||||
|
unique_id: `${svc.addr}_lvl`,
|
||||||
|
p: "sensor",
|
||||||
|
unit_of_measurement: "",
|
||||||
|
value_template: `{{ value_json['${svc.addr}'].lvl }}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ───────────── writeable “select” (scene activator) ─────────────
|
||||||
|
const supScenes: string[] = svc.props?.sup_scenes ?? [];
|
||||||
|
if (svc.intf?.includes("cmd.scene.set") && supScenes.length) {
|
||||||
|
const commandTopic = `${topicPrefix}${svc.addr}/scene/command`;
|
||||||
|
|
||||||
|
components[`${svc.addr}_select`] = {
|
||||||
|
unique_id: `${svc.addr}_select`,
|
||||||
|
p: "select",
|
||||||
|
options: supScenes,
|
||||||
|
command_topic: commandTopic,
|
||||||
|
optimistic: true,
|
||||||
|
value_template: `{{ value_json['${svc.addr}'].scene }}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
handlers[commandTopic] = async (payload: string) => {
|
||||||
|
if (!supScenes.includes(payload)) return; // ignore bogus payloads
|
||||||
|
|
||||||
|
await sendFimpMsg({
|
||||||
|
address: svc.addr!,
|
||||||
|
service: "scene_ctrl",
|
||||||
|
cmd: "cmd.scene.set",
|
||||||
|
val_t: "string",
|
||||||
|
val: payload,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing useful to expose?
|
||||||
|
if (!Object.keys(components).length) return undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
components,
|
||||||
|
commandHandlers: Object.keys(handlers).length ? handlers : undefined,
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user