mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Add device control and support for 'out_bin_switch' service
This commit is contained in:
parent
b92b919008
commit
d608afb455
@ -17,10 +17,12 @@ export type FimpResponse = {
|
||||
type?: string | null;
|
||||
uid?: any;
|
||||
val?: any;
|
||||
val_t?: string;
|
||||
val_t?: FimpValueType;
|
||||
ver?: any;
|
||||
};
|
||||
|
||||
type FimpValueType = 'string' | 'int' | 'float' | 'bool' | 'null' | 'str_array' | 'int_array' | 'float_array' | 'str_map' | 'int_map' | 'float_map' | 'bool_map' | 'object' | 'bin';
|
||||
|
||||
export async function sendFimpMsg({
|
||||
address,
|
||||
service,
|
||||
@ -33,7 +35,7 @@ export async function sendFimpMsg({
|
||||
service: string;
|
||||
cmd: string;
|
||||
val: unknown;
|
||||
val_t: string;
|
||||
val_t: FimpValueType;
|
||||
timeoutMs?: number;
|
||||
}): Promise<FimpResponse> {
|
||||
const uid = uuidv4();
|
||||
@ -121,13 +123,14 @@ export async function sendFimpMsg({
|
||||
// }
|
||||
|
||||
const hasValidType = msg.type != null && msg.type.startsWith('evt.');
|
||||
const msgParts = msg.type?.split('.') ?? [];
|
||||
const cmdParts = cmd.split('.');
|
||||
const hasThreeParts = msgParts.length === 3 && cmdParts.length === 3;
|
||||
const middlePartMatches = msgParts[1] === cmdParts[1];
|
||||
const endsWithLastPart = cmd.endsWith(msgParts.at(-1)!);
|
||||
const reqCmdParts = cmd.split('.');
|
||||
const resCmdParts = msg.type?.split('.') ?? [];
|
||||
const hasThreeParts = resCmdParts.length === 3 && reqCmdParts.length === 3;
|
||||
const middlePartMatches = resCmdParts[1] === reqCmdParts[1];
|
||||
const endsWithLastPart = cmd.endsWith(resCmdParts.at(-1)!);
|
||||
const reqEndsWithSetAndResEndsWithReport = reqCmdParts[2] === 'set' && resCmdParts[2] === 'report'
|
||||
const sameService = msg.serv === service;
|
||||
if (hasValidType && hasThreeParts && middlePartMatches && endsWithLastPart && sameService) {
|
||||
if (hasValidType && hasThreeParts && middlePartMatches && (endsWithLastPart || reqEndsWithSetAndResEndsWithReport) && sameService) {
|
||||
log.debug(`Received FIMP response for message ${uid} (matched using event name).`);
|
||||
|
||||
clearTimeout(timeout);
|
||||
|
@ -6,7 +6,9 @@ export type VinculumPd7Device = {
|
||||
id: number,
|
||||
services?: any,
|
||||
type?: {
|
||||
// User-defined device type (e.g. "sensor", "chargepoint", or "light")
|
||||
type?: string | null,
|
||||
// User-defined device subtype (e.g. "presence" or "car_charger")
|
||||
subtype?: string | null,
|
||||
} | null,
|
||||
};
|
||||
|
@ -1,7 +1,14 @@
|
||||
import { MqttClient } from "mqtt/*";
|
||||
import { CommandHandlers } from "./publish_device";
|
||||
|
||||
export let ha: MqttClient | undefined = undefined;
|
||||
|
||||
export function setHa(client: MqttClient) {
|
||||
ha = client;
|
||||
}
|
||||
|
||||
export let haCommandHandlers: CommandHandlers | undefined = undefined;
|
||||
|
||||
export function setHaCommandHandlers(handlers: CommandHandlers) {
|
||||
haCommandHandlers = handlers;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ import { sensor_watflow__components } from "../services/sensor_watflow";
|
||||
import { sensor_watpressure__components } from "../services/sensor_watpressure";
|
||||
import { sensor_wattemp__components } from "../services/sensor_wattemp";
|
||||
import { sensor_weight__components } from "../services/sensor_weight";
|
||||
import { ha } from "./globals";
|
||||
import { ha, setHaCommandHandlers } from "./globals";
|
||||
|
||||
type HaDeviceConfig = {
|
||||
// device
|
||||
@ -85,7 +85,7 @@ type SensorComponent = {
|
||||
// platform
|
||||
p: 'sensor';
|
||||
device_class?: string;
|
||||
unit_of_measurement?: string;
|
||||
unit_of_measurement: string;
|
||||
value_template: string;
|
||||
}
|
||||
|
||||
@ -101,10 +101,32 @@ type SwitchComponent = {
|
||||
unique_id: string;
|
||||
// platform
|
||||
p: 'switch';
|
||||
command_topic: string;
|
||||
optimistic: boolean;
|
||||
value_template: string;
|
||||
}
|
||||
|
||||
// todo button reference
|
||||
// "cmps": {
|
||||
// "bla1": {
|
||||
// "p": "device_automation",
|
||||
// "automation_type": "trigger",
|
||||
// "payload": "short_press",
|
||||
// "topic": "foobar/triggers/button1",
|
||||
// "type": "button_short_press",
|
||||
// "subtype": "button_1"
|
||||
// },
|
||||
// },
|
||||
|
||||
export type ServiceComponentsCreationResult = {
|
||||
components: { [key: string]: HaComponent };
|
||||
commandHandlers?: CommandHandlers;
|
||||
}
|
||||
|
||||
export type CommandHandlers = { [topic: string]: (payload: string) => Promise<void> }
|
||||
|
||||
const serviceHandlers: {
|
||||
[name: string]: (vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService) => { [key: string]: HaComponent }
|
||||
[name: string]: (topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService) => ServiceComponentsCreationResult
|
||||
} = {
|
||||
battery: battery__components,
|
||||
out_bin_switch: out_bin_switch__components,
|
||||
@ -151,59 +173,32 @@ const serviceHandlers: {
|
||||
sensor_weight: sensor_weight__components,
|
||||
};
|
||||
|
||||
export function haPublishDevice(parameters: { hubId: string, vinculumDeviceData: VinculumPd7Device, deviceInclusionReport: InclusionReport }) {
|
||||
export function haPublishDevice(parameters: { hubId: string, vinculumDeviceData: VinculumPd7Device, deviceInclusionReport: InclusionReport }): { commandHandlers: CommandHandlers } {
|
||||
if (!parameters.deviceInclusionReport.services) {
|
||||
return;
|
||||
return { commandHandlers: {} };
|
||||
}
|
||||
|
||||
let cmps: { [key: string]: HaComponent } = {};
|
||||
const components: { [key: string]: HaComponent } = {};
|
||||
const handlers: CommandHandlers = {};
|
||||
|
||||
// e.g. "homeassistant/device/futurehome_123456_1"
|
||||
const topicPrefix = `homeassistant/device/futurehome_${parameters.hubId}_${parameters.deviceInclusionReport.address}`;
|
||||
|
||||
for (const svc of parameters.deviceInclusionReport.services) {
|
||||
if (!svc.name) { continue; }
|
||||
const handler = serviceHandlers[svc.name];
|
||||
if (handler) {
|
||||
const result = handler(parameters.vinculumDeviceData, svc);
|
||||
for (const key in result) {
|
||||
cmps[key] = result[key];
|
||||
}
|
||||
const result = handler(topicPrefix, parameters.vinculumDeviceData, svc);
|
||||
Object.assign(components, result.components);
|
||||
Object.assign(handlers, result.commandHandlers);
|
||||
} else {
|
||||
log.error(`No handler for service: ${svc.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// "cmps": {
|
||||
// "some_unique_component_id1": {
|
||||
// "p": "sensor",
|
||||
// "device_class":"temperature",
|
||||
// "unit_of_measurement":"°C",
|
||||
// "value_template":"{{ value_json.temperature }}",
|
||||
// "unique_id":"temp01ae_t"
|
||||
// },
|
||||
// "some_unique_id2": {
|
||||
// "p": "sensor",
|
||||
// "device_class":"humidity",
|
||||
// "unit_of_measurement":"%",
|
||||
// "value_template":"{{ value_json.humidity }}",
|
||||
// "unique_id":"temp01ae_h"
|
||||
// },
|
||||
// "bla1": {
|
||||
// "p": "device_automation",
|
||||
// "automation_type": "trigger",
|
||||
// "payload": "short_press",
|
||||
// "topic": "foobar/triggers/button1",
|
||||
// "type": "button_short_press",
|
||||
// "subtype": "button_1"
|
||||
// },
|
||||
// "bla2": {
|
||||
// "p": "sensor",
|
||||
// "state_topic": "foobar/sensor/sensor1",
|
||||
// "unique_id": "bla_sensor001"
|
||||
// }
|
||||
// },
|
||||
|
||||
const configTopic = `homeassistant/device/futurehome_${parameters.hubId}_${parameters.deviceInclusionReport.address}/config`
|
||||
const stateTopic = `homeassistant/device/futurehome_${parameters.hubId}_${parameters.deviceInclusionReport.address}/state`
|
||||
const availabilityTopic = `homeassistant/device/futurehome_${parameters.hubId}_${parameters.deviceInclusionReport.address}/availability`
|
||||
const configTopic = `${topicPrefix}/config`
|
||||
const stateTopic = `${topicPrefix}/state`
|
||||
const availabilityTopic = `${topicPrefix}/availability`
|
||||
const config: HaDeviceConfig = {
|
||||
dev: {
|
||||
ids: parameters.deviceInclusionReport.address,
|
||||
@ -221,12 +216,14 @@ export function haPublishDevice(parameters: { hubId: string, vinculumDeviceData:
|
||||
name: 'futurehome',
|
||||
url: 'https://github.com/adrianjagielak/home-assistant-futurehome',
|
||||
},
|
||||
cmps: cmps,
|
||||
cmps: components,
|
||||
stat_t: stateTopic,
|
||||
avty_t: availabilityTopic,
|
||||
qos: 2,
|
||||
};
|
||||
|
||||
log.debug(`Publishing HA device "${configTopic}"`)
|
||||
log.debug(`Publishing HA device "${configTopic}"`);
|
||||
ha?.publish(configTopic, JSON.stringify(config), { retain: true, qos: 2 });
|
||||
|
||||
return { commandHandlers: handlers };
|
||||
}
|
@ -4,8 +4,8 @@ import { log } from "./logger";
|
||||
import { FimpResponse, sendFimpMsg, setFimp } from "./fimp/fimp";
|
||||
import { getInclusionReport } from "./fimp/inclusion_report";
|
||||
import { adapterAddressFromServiceAddress, adapterServiceFromServiceAddress } from "./fimp/helpers";
|
||||
import { setHa } from "./ha/globals";
|
||||
import { haPublishDevice } from "./ha/publish_device";
|
||||
import { haCommandHandlers, setHa, setHaCommandHandlers } from "./ha/globals";
|
||||
import { CommandHandlers, haPublishDevice } from "./ha/publish_device";
|
||||
import { haUpdateState, haUpdateStateSensorReport } from "./ha/update_state";
|
||||
import { VinculumPd7Device } from "./fimp/vinculum_pd7_device";
|
||||
import { haUpdateAvailability } from "./ha/update_availability";
|
||||
@ -82,6 +82,7 @@ import { haUpdateAvailability } from "./ha/update_availability";
|
||||
}
|
||||
}
|
||||
|
||||
const commandHandlers: CommandHandlers = {};
|
||||
for (const device of devices.val.param.device) {
|
||||
const vinculumDeviceData: VinculumPd7Device = device
|
||||
const deviceId = vinculumDeviceData.id.toString()
|
||||
@ -100,8 +101,10 @@ import { haUpdateAvailability } from "./ha/update_availability";
|
||||
// Set initial availability
|
||||
haUpdateAvailability({ hubId, deviceAvailability: { address: deviceId, status: 'UP' } });
|
||||
}
|
||||
haPublishDevice({ hubId, vinculumDeviceData, deviceInclusionReport })
|
||||
const result = haPublishDevice({ hubId, vinculumDeviceData, deviceInclusionReport });
|
||||
Object.assign(commandHandlers, result.commandHandlers);
|
||||
}
|
||||
setHaCommandHandlers(commandHandlers);
|
||||
|
||||
// todo
|
||||
// exposeSmarthubTools();
|
||||
@ -120,30 +123,16 @@ import { haUpdateAvailability } from "./ha/update_availability";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'evt.sensor.report': {
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: 'sensor' })
|
||||
break;
|
||||
}
|
||||
case 'evt.presence.report': {
|
||||
if (!(msg.serv === 'sensor_presence')) { return; }
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: 'presence' })
|
||||
break;
|
||||
}
|
||||
case 'evt.open.report': {
|
||||
if (!(msg.serv === 'sensor_contact')) { return; }
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: 'open' })
|
||||
break;
|
||||
}
|
||||
case 'evt.lvl.report': {
|
||||
if (!(msg.serv === 'battery')) { return; }
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: 'lvl' })
|
||||
break;
|
||||
}
|
||||
case 'evt.alarm.report': {
|
||||
if (!(msg.serv === 'battery')) { return; }
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: 'alarm' })
|
||||
break;
|
||||
}
|
||||
case 'evt.sensor.report':
|
||||
case 'evt.presence.report':
|
||||
case 'evt.open.report':
|
||||
case 'evt.lvl.report':
|
||||
case 'evt.alarm.report':
|
||||
case 'evt.binary.report':
|
||||
{
|
||||
haUpdateStateSensorReport({ topic, value: msg.val, attrName: msg.type.split('.')[1] })
|
||||
break;
|
||||
}
|
||||
case 'evt.network.all_nodes_report': {
|
||||
const devicesAvailability = msg.val;
|
||||
if (!devicesAvailability) { return; }
|
||||
@ -166,4 +155,15 @@ import { haUpdateAvailability } from "./ha/update_availability";
|
||||
val: { cmd: "get", component: null, param: { components: ['state'] } },
|
||||
val_t: 'object',
|
||||
});
|
||||
|
||||
ha.on('message', (topic, buf) => {
|
||||
// Handle Home Assistant command messages
|
||||
const handler = haCommandHandlers?.[topic];
|
||||
if (handler) {
|
||||
log.debug(`Handling Home Assistant command topic: ${topic}, payload: ${buf.toString()}`);
|
||||
handler(buf.toString()).catch((e) => {
|
||||
log.warn(`Failed executing handler for topic: ${topic}, payload: ${buf.toString()}`, e);
|
||||
});
|
||||
}
|
||||
})
|
||||
})();
|
||||
|
@ -1,29 +1,33 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function battery__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function battery__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
if (svc.props?.sup_events?.includes('low_battery')) {
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: 'battery',
|
||||
value_template: `{{ (value_json['${svc.address}'].alarm.status == 'activ') | iif('ON', 'OFF') }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: 'battery',
|
||||
value_template: `{{ (value_json['${svc.address}'].alarm.status == 'activ') | iif('ON', 'OFF') }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'battery',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].lvl }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'battery',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].lvl }}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,31 @@
|
||||
import { sendFimpMsg } from "../fimp/fimp";
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function out_bin_switch__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function out_bin_switch__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
return {
|
||||
// [svc.address]: {
|
||||
// p: "sensor",
|
||||
// device_class: "temperature",
|
||||
// unit_of_measurement: "°C",
|
||||
// value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
// },
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'switch',
|
||||
command_topic: `${topicPrefix}${svc.address}/command`,
|
||||
optimistic: false,//todo
|
||||
value_template: `{{ (value_json['${svc.address}'].binary) | iif('ON', 'OFF') }}`,
|
||||
},
|
||||
},
|
||||
commandHandlers: {
|
||||
[`${topicPrefix}${svc.address}/command`]: async (payload: string) => {
|
||||
await sendFimpMsg({
|
||||
address: svc.address!,
|
||||
service: 'out_bin_switch',
|
||||
cmd: 'cmd.binary.set',
|
||||
val: payload === 'ON',
|
||||
val_t: 'bool',
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function out_lvl_switch__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function out_lvl_switch__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return {components: {}}; }
|
||||
|
||||
return {
|
||||
components: {
|
||||
// [svc.address]: {
|
||||
// p: "sensor",
|
||||
// device_class: "temperature",
|
||||
// p: 'sensor',
|
||||
// device_class: 'temperature",
|
||||
// unit_of_measurement: "°C",
|
||||
// value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
// },
|
||||
};
|
||||
},};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_accelx__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_accelx__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm/s2';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm/s2',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_accely__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_accely__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm/s2';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm/s2',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_accelz__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_accelz__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm/s2';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm/s2',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_airflow__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_airflow__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm3/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm3/h',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_airq__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_airq__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'aqi';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'pm25';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'aqi',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'pm25',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_anglepos__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_anglepos__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? '%';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_atmo__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_atmo__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'atmospheric_pressure';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'kPa';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'atmospheric_pressure',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'kPa',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_baro__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_baro__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'atmospheric_pressure';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'kPa';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'atmospheric_pressure',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'kPa',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_co__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_co__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'carbon_monoxide';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'mol/m3';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'carbon_monoxide',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'mol/m3',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_co2__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_co2__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'carbon_dioxide';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'ppm';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'carbon_dioxide',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'ppm',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_contact__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_contact__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'opening'
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: 'opening',
|
||||
value_template: `{{ value_json['${svc.address}'].open | iif('ON', 'OFF') }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: device_class,
|
||||
value_template: `{{ value_json['${svc.address}'].open | iif('ON', 'OFF') }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_current__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_current__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'current';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'A';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'current',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'A',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,21 +1,24 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_dew__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_dew__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'temperature'
|
||||
let unit = svc.props?.sup_units?.[0] ?? "°C";
|
||||
if (unit === 'C') unit = '°C';
|
||||
if (unit === 'F') unit = '°F';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'temperature',
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_direct__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_direct__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'wind_direction';
|
||||
const unit = svc.props?.sup_units?.[0] ?? '°';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'wind_direction',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '°',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_distance__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_distance__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'distance';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'distance',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_elresist__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_elresist__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'ohm/m';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'Ω·m',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_freq__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_freq__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'frequency';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'Hz';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'frequency',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'Hz',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_gp__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_gp__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? '%';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,19 +1,23 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_gust__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_gust__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "km/h";
|
||||
if (unit === 'kph') unit = 'km/h';
|
||||
const device_class = undefined;
|
||||
let unit = svc.props?.sup_units?.[0] ?? 'km/h';
|
||||
if (unit === 'kph') unit = 'km/h'
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_humid__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_humid__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'humidity';
|
||||
const unit = svc.props?.sup_units?.[0] ?? '%';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'humidity',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_lumin__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_lumin__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'illuminance';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'Lux';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'illuminance',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'Lux',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_moist__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_moist__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'moisture';
|
||||
const unit = svc.props?.sup_units?.[0] ?? '%';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'moisture',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? '%',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_noise__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_noise__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'sound_pressure';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'dB';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'sound_pressure',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'dB',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_power__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_power__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'power';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'W';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'power',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'W',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_presence__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_presence__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'occupancy'
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: 'occupancy',
|
||||
value_template: `{{ value_json['${svc.address}'].presence | iif('ON', 'OFF') }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'binary_sensor',
|
||||
device_class: device_class,
|
||||
value_template: `{{ value_json['${svc.address}'].presence | iif('ON', 'OFF') }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_rain__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_rain__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'precipitation_intensity';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'mm/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'precipitation_intensity',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'mm/h',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_rotation__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_rotation__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'rpm';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'rpm',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_seismicint__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_seismicint__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'EMCRO';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'EMCRO',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_seismicmag__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_seismicmag__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'MB';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'MB',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_solarrad__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_solarrad__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'W/m2';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'w/m2',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_tank__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_tank__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'volume_storage';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'l';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'volume_storage',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'l',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,21 +1,24 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_temp__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_temp__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'temperature'
|
||||
let unit = svc.props?.sup_units?.[0] ?? "°C";
|
||||
if (unit === 'C') unit = '°C';
|
||||
if (unit === 'F') unit = '°F';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'temperature',
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_tidelvl__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_tidelvl__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_uv__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_uv__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'index';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'index',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_veloc__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_veloc__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = undefined;
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'm/2';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'm/s',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_voltage__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_voltage__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'voltage';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'V';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'voltage',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'V',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_watflow__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_watflow__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'volume_flow_rate';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'l/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'volume_flow_rate',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'l/h',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_watpressure__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_watpressure__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'pressure';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'kPa';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'pressure',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'kPa',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,21 +1,24 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_wattemp__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_wattemp__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'temperature';
|
||||
let unit = svc.props?.sup_units?.[0] ?? "°C";
|
||||
if (unit === 'C') unit = '°C';
|
||||
if (unit === 'F') unit = '°F';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'temperature',
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_weight__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_weight__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
const device_class = 'weight';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'kg';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'weight',
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'kg',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { HaComponent } from "../ha/publish_device";
|
||||
import { ServiceComponentsCreationResult } from "../ha/publish_device";
|
||||
|
||||
export function sensor_wind__components(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: HaComponent } {
|
||||
if (!svc.address) { return {}; }
|
||||
export function sensor_wind__components(topicPrefix: string, vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): ServiceComponentsCreationResult {
|
||||
if (!svc.address) { return { components: {} }; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "km/h";
|
||||
if (unit === 'kph') unit = 'km/h';
|
||||
const device_class = 'wind_speed';
|
||||
const unit = svc.props?.sup_units?.[0] ?? 'km/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: 'wind_speed',
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
components: {
|
||||
[svc.address]: {
|
||||
unique_id: svc.address,
|
||||
p: 'sensor',
|
||||
device_class: device_class,
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user