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