mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-11-18 09:09:03 +00:00
Add support for 'dev_sys' service
This commit is contained in:
@@ -14,6 +14,7 @@ import { battery__components } from '../services/battery';
|
||||
import { chargepoint__components } from '../services/chargepoint';
|
||||
import { color_ctrl__components } from '../services/color_ctrl';
|
||||
import { complex_alarm_system__components } from '../services/complex_alarm_system';
|
||||
import { dev_sys__components } from '../services/dev_sys';
|
||||
import { door_lock__components } from '../services/door_lock';
|
||||
import { doorman__components } from '../services/doorman';
|
||||
import { fan_ctrl__components } from '../services/fan_ctrl';
|
||||
@@ -155,6 +156,7 @@ const serviceHandlers: {
|
||||
chargepoint: chargepoint__components,
|
||||
color_ctrl: color_ctrl__components,
|
||||
complex_alarm_system: complex_alarm_system__components,
|
||||
dev_sys: dev_sys__components,
|
||||
door_lock: door_lock__components,
|
||||
doorman: doorman__components,
|
||||
fan_ctrl: fan_ctrl__components,
|
||||
|
||||
51
futurehome/src/services/dev_sys.ts
Normal file
51
futurehome/src/services/dev_sys.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
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 dev_sys__components(
|
||||
topicPrefix: string,
|
||||
device: VinculumPd7Device,
|
||||
svc: VinculumPd7Service,
|
||||
svcName: string,
|
||||
): ServiceComponentsCreationResult | undefined {
|
||||
const components: Record<string, HaMqttComponent> = {};
|
||||
const commandHandlers: CommandHandlers = {};
|
||||
|
||||
if (svc.intf?.includes('cmd.thing.reboot')) {
|
||||
const rebootCommandTopic = `${topicPrefix}${svc.addr}/reboot/command`;
|
||||
|
||||
components[`${svc.addr}_reboot`] = {
|
||||
unique_id: `${svc.addr}_reboot`,
|
||||
platform: 'button',
|
||||
device_class: 'restart',
|
||||
entity_category: 'config',
|
||||
command_topic: rebootCommandTopic,
|
||||
};
|
||||
|
||||
commandHandlers[rebootCommandTopic] = async (_payload: string) => {
|
||||
await sendFimpMsg({
|
||||
address: svc.addr,
|
||||
service: svcName,
|
||||
cmd: 'cmd.thing.reboot',
|
||||
// App always sends a `null`. In theory some devices could support a force reboot, with `true` value.
|
||||
val_t: 'null',
|
||||
val: null,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Nothing useful to expose?
|
||||
if (!Object.keys(components).length) return undefined;
|
||||
|
||||
return {
|
||||
components,
|
||||
commandHandlers,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user