mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Add support for 'basic' service
This commit is contained in:
parent
1c6407f0c2
commit
0a945b679a
@ -52,7 +52,7 @@ todo periodical refresh of state
|
||||
| alarm_weather | | |
|
||||
| appliance | | |
|
||||
| barrier_ctrl | | |
|
||||
| basic | | |
|
||||
| basic | | ✅ |
|
||||
| battery | | ✅ |
|
||||
| blinds | | |
|
||||
| boiler | | |
|
||||
@ -137,7 +137,8 @@ todo periodical refresh of state
|
||||
| indicator_ctrl | | |
|
||||
| ota | | |
|
||||
| parameters | | |
|
||||
| dev_sys | | |
|
||||
| technology_specific | | |
|
||||
|
||||
| time | | |
|
||||
| version | | |
|
||||
| dev_sys | | |
|
||||
|
@ -1,6 +1,6 @@
|
||||
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
||||
name: Futurehome
|
||||
version: "0.0.19"
|
||||
version: "0.0.20"
|
||||
slug: futurehome
|
||||
description: Local Futurehome Smarthub integration
|
||||
url: "https://github.com/adrianjagielak/home-assistant-futurehome"
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { InclusionReport } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device, VinculumPd7Service } from "../fimp/vinculum_pd7_device";
|
||||
import { log } from "../logger";
|
||||
import { basic__components } from "../services/basic";
|
||||
import { battery__components } from "../services/battery";
|
||||
import { out_bin_switch__components } from "../services/out_bin_switch";
|
||||
import { out_lvl_switch__components } from "../services/out_lvl_switch";
|
||||
@ -157,6 +158,7 @@ export type CommandHandlers = { [topic: string]: (payload: string) => Promise<vo
|
||||
const serviceHandlers: {
|
||||
[name: string]: (topicPrefix: string, device: VinculumPd7Device, svc: VinculumPd7Service) => ServiceComponentsCreationResult | undefined
|
||||
} = {
|
||||
basic: basic__components,
|
||||
battery: battery__components,
|
||||
out_bin_switch: out_bin_switch__components,
|
||||
out_lvl_switch: out_lvl_switch__components,
|
||||
|
56
futurehome/src/services/basic.ts
Normal file
56
futurehome/src/services/basic.ts
Normal file
@ -0,0 +1,56 @@
|
||||
// Maps a Futurehome “basic” service to one MQTT *number* entity.
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
// FIMP ➞ HA state path used by the template
|
||||
// value_json[svc.addr].lvl – current level (0-255)
|
||||
//
|
||||
// HA ➞ FIMP commands
|
||||
// command_topic → cmd.lvl.set
|
||||
// ───────────────────────────────────────────────────────────────
|
||||
|
||||
import { sendFimpMsg } from "../fimp/fimp";
|
||||
import { VinculumPd7Device, VinculumPd7Service } from "../fimp/vinculum_pd7_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function basic__components(
|
||||
topicPrefix: string,
|
||||
_device: VinculumPd7Device,
|
||||
svc: VinculumPd7Service
|
||||
): ServiceComponentsCreationResult | undefined {
|
||||
// MQTT topic that HA will publish commands to
|
||||
const cmdTopic = `${topicPrefix}${svc.addr}/command`;
|
||||
|
||||
// Z-Wave “Basic” uses a 0-255 range (0 = off, 255 = on, 1-254 = dim level)
|
||||
const MIN_LVL = 0;
|
||||
const MAX_LVL = 255;
|
||||
|
||||
return {
|
||||
components: {
|
||||
[svc.addr]: {
|
||||
unique_id: svc.addr,
|
||||
p: "number",
|
||||
min: MIN_LVL,
|
||||
max: MAX_LVL,
|
||||
step: 1,
|
||||
command_topic: cmdTopic,
|
||||
optimistic: true,
|
||||
value_template: `{{ value_json['${svc.addr}'].lvl }}`,
|
||||
},
|
||||
},
|
||||
|
||||
// ─────── HA → FIMP bridge ───────
|
||||
commandHandlers: {
|
||||
[cmdTopic]: async (payload: string) => {
|
||||
const lvl = parseInt(payload, 10);
|
||||
if (Number.isNaN(lvl)) return;
|
||||
|
||||
await sendFimpMsg({
|
||||
address: svc.addr!,
|
||||
service: "basic",
|
||||
cmd: "cmd.lvl.set",
|
||||
val_t: "int",
|
||||
val: lvl,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user