mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-09-13 15:47:08 +00:00
Implement all sensors and low battery state
This commit is contained in:
parent
ff38146ac4
commit
2c3a1bf0c5
@ -17,6 +17,10 @@ export type InclusionReport = {
|
||||
export type InclusionReportService = {
|
||||
name?: string | null;
|
||||
address?: string | null;
|
||||
props?: {
|
||||
sup_units?: string[] | null;
|
||||
sup_events?: string[] | null;
|
||||
} | null
|
||||
};
|
||||
|
||||
export async function getInclusionReport(parameters: { adapterAddress: string; adapterService: string; deviceId: string }): Promise<InclusionReport> {
|
||||
|
@ -4,8 +4,46 @@ import { log } from "../logger";
|
||||
import { cmps_battery } from "../services/battery";
|
||||
import { cmps_out_bin_switch } from "../services/out_bin_switch";
|
||||
import { cmps_out_lvl_switch } from "../services/out_lvl_switch";
|
||||
import { cmps_sensor_accelx } from "../services/sensor_accelx";
|
||||
import { cmps_sensor_accely } from "../services/sensor_accely";
|
||||
import { cmps_sensor_accelz } from "../services/sensor_accelz";
|
||||
import { cmps_sensor_airflow } from "../services/sensor_airflow";
|
||||
import { cmps_sensor_airq } from "../services/sensor_airq";
|
||||
import { cmps_sensor_anglepos } from "../services/sensor_anglepos";
|
||||
import { cmps_sensor_atmo } from "../services/sensor_atmo";
|
||||
import { cmps_sensor_baro } from "../services/sensor_baro";
|
||||
import { cmps_sensor_co } from "../services/sensor_co";
|
||||
import { cmps_sensor_co2 } from "../services/sensor_co2";
|
||||
import { cmps_sensor_contact } from "../services/sensor_contact";
|
||||
import { cmps_sensor_current } from "../services/sensor_current";
|
||||
import { cmps_sensor_dew } from "../services/sensor_dew";
|
||||
import { cmps_sensor_direct } from "../services/sensor_direct";
|
||||
import { cmps_sensor_distance } from "../services/sensor_distance";
|
||||
import { cmps_sensor_elresist } from "../services/sensor_elresist";
|
||||
import { cmps_sensor_freq } from "../services/sensor_freq";
|
||||
import { cmps_sensor_gp } from "../services/sensor_gp";
|
||||
import { cmps_sensor_gust } from "../services/sensor_gust";
|
||||
import { cmps_sensor_humid } from "../services/sensor_humid";
|
||||
import { cmps_sensor_lumin } from "../services/sensor_lumin";
|
||||
import { cmps_sensor_moist } from "../services/sensor_moist";
|
||||
import { cmps_sensor_noise } from "../services/sensor_noise";
|
||||
import { cmps_sensor_power } from "../services/sensor_power";
|
||||
import { cmps_sensor_presence } from "../services/sensor_presence";
|
||||
import { cmps_sensor_rain } from "../services/sensor_rain";
|
||||
import { cmps_sensor_rotation } from "../services/sensor_rotation";
|
||||
import { cmps_sensor_seismicint } from "../services/sensor_seismicint";
|
||||
import { cmps_sensor_seismicmag } from "../services/sensor_seismicmag";
|
||||
import { cmps_sensor_solarrad } from "../services/sensor_solarrad";
|
||||
import { cmps_sensor_tank } from "../services/sensor_tank";
|
||||
import { cmps_sensor_temp } from "../services/sensor_temp";
|
||||
import { cmps_sensor_tidelvl } from "../services/sensor_tidelvl";
|
||||
import { cmps_sensor_uv } from "../services/sensor_uv";
|
||||
import { cmps_sensor_veloc } from "../services/sensor_veloc";
|
||||
import { cmps_sensor_voltage } from "../services/sensor_voltage";
|
||||
import { cmps_sensor_watflow } from "../services/sensor_watflow";
|
||||
import { cmps_sensor_watpressure } from "../services/sensor_watpressure";
|
||||
import { cmps_sensor_wattemp } from "../services/sensor_wattemp";
|
||||
import { cmps_sensor_weight } from "../services/sensor_weight";
|
||||
import { ha } from "./globals";
|
||||
|
||||
type HaDeviceConfig = {
|
||||
@ -45,8 +83,46 @@ const serviceHandlers: {
|
||||
battery: cmps_battery,
|
||||
out_bin_switch: cmps_out_bin_switch,
|
||||
out_lvl_switch: cmps_out_lvl_switch,
|
||||
sensor_temp: cmps_sensor_temp,
|
||||
sensor_accelx: cmps_sensor_accelx,
|
||||
sensor_accely: cmps_sensor_accely,
|
||||
sensor_accelz: cmps_sensor_accelz,
|
||||
sensor_airflow: cmps_sensor_airflow,
|
||||
sensor_airq: cmps_sensor_airq,
|
||||
sensor_anglepos: cmps_sensor_anglepos,
|
||||
sensor_atmo: cmps_sensor_atmo,
|
||||
sensor_baro: cmps_sensor_baro,
|
||||
sensor_co: cmps_sensor_co,
|
||||
sensor_co2: cmps_sensor_co2,
|
||||
sensor_contact: cmps_sensor_contact,
|
||||
sensor_current: cmps_sensor_current,
|
||||
sensor_dew: cmps_sensor_dew,
|
||||
sensor_direct: cmps_sensor_direct,
|
||||
sensor_distance: cmps_sensor_distance,
|
||||
sensor_elresist: cmps_sensor_elresist,
|
||||
sensor_freq: cmps_sensor_freq,
|
||||
sensor_gp: cmps_sensor_gp,
|
||||
sensor_gust: cmps_sensor_gust,
|
||||
sensor_humid: cmps_sensor_humid,
|
||||
sensor_lumin: cmps_sensor_lumin,
|
||||
sensor_moist: cmps_sensor_moist,
|
||||
sensor_noise: cmps_sensor_noise,
|
||||
sensor_power: cmps_sensor_power,
|
||||
sensor_presence: cmps_sensor_presence,
|
||||
sensor_rain: cmps_sensor_rain,
|
||||
sensor_rotation: cmps_sensor_rotation,
|
||||
sensor_seismicint: cmps_sensor_seismicint,
|
||||
sensor_seismicmag: cmps_sensor_seismicmag,
|
||||
sensor_solarrad: cmps_sensor_solarrad,
|
||||
sensor_tank: cmps_sensor_tank,
|
||||
sensor_temp: cmps_sensor_temp,
|
||||
sensor_tidelvl: cmps_sensor_tidelvl,
|
||||
sensor_uv: cmps_sensor_uv,
|
||||
sensor_veloc: cmps_sensor_veloc,
|
||||
sensor_voltage: cmps_sensor_voltage,
|
||||
sensor_watflow: cmps_sensor_watflow,
|
||||
sensor_watpressure: cmps_sensor_watpressure,
|
||||
sensor_wattemp: cmps_sensor_wattemp,
|
||||
sensor_weight: cmps_sensor_weight,
|
||||
};
|
||||
|
||||
export function haPublishDevice(parameters: { hubId: string, vinculumDeviceData: VinculumPd7Device, deviceInclusionReport: InclusionReport }) {
|
||||
|
@ -5,13 +5,25 @@ import { CMP } from "../ha/publish_device";
|
||||
export function cmps_battery(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
if (svc.props?.sup_events?.includes('low_battery')) {
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
p: "binary_sensor",
|
||||
device_class: "battery",
|
||||
unit_of_measurement: "%",
|
||||
value_template: `{{ value_json['${svc.address}'].lvl }}`,
|
||||
value_template: `{{ value_json['${svc.address}'].alarm.status == 'activ' | iif('on', 'off') }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "battery",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "%",
|
||||
value_template: `{{ value_json['${svc.address}'].lvl }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
16
futurehome/src/services/sensor_accelx.ts
Normal file
16
futurehome/src/services/sensor_accelx.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_accelx(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m/s2",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_accely.ts
Normal file
16
futurehome/src/services/sensor_accely.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_accely(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m/s2",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_accelz.ts
Normal file
16
futurehome/src/services/sensor_accelz.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_accelz(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m/s2",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_airflow.ts
Normal file
16
futurehome/src/services/sensor_airflow.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_airflow(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m3/h",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_airq.ts
Normal file
17
futurehome/src/services/sensor_airq.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_airq(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "aqi",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "pm25",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_anglepos.ts
Normal file
16
futurehome/src/services/sensor_anglepos.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_anglepos(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "%",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_atmo.ts
Normal file
17
futurehome/src/services/sensor_atmo.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_atmo(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "atmospheric_pressure",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "kPa",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_baro.ts
Normal file
17
futurehome/src/services/sensor_baro.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_baro(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "atmospheric_pressure",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "kPa",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_co.ts
Normal file
17
futurehome/src/services/sensor_co.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_co(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[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 }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_co2.ts
Normal file
17
futurehome/src/services/sensor_co2.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_co2(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "carbon_dioxide",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "ppm",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_contact.ts
Normal file
16
futurehome/src/services/sensor_contact.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_contact(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "binary_sensor",
|
||||
device_class: "opening",
|
||||
value_template: `{{ value_json['${svc.address}'].open | iif('on', 'off') }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_current.ts
Normal file
17
futurehome/src/services/sensor_current.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_current(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "current",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "A",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
21
futurehome/src/services/sensor_dew.ts
Normal file
21
futurehome/src/services/sensor_dew.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_dew(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "℃";
|
||||
if (unit === 'C') unit = '℃';
|
||||
if (unit === 'F') unit = '℉';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "temperature",
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_direct.ts
Normal file
17
futurehome/src/services/sensor_direct.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_direct(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "wind_direction",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "°",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_distance.ts
Normal file
17
futurehome/src/services/sensor_distance.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_distance(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "distance",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_elresist.ts
Normal file
16
futurehome/src/services/sensor_elresist.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_elresist(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "Ω·m",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_freq.ts
Normal file
17
futurehome/src/services/sensor_freq.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_freq(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "frequency",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "Hz",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_gp.ts
Normal file
16
futurehome/src/services/sensor_gp.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_gp(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "%",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
19
futurehome/src/services/sensor_gust.ts
Normal file
19
futurehome/src/services/sensor_gust.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_gust(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "km/h";
|
||||
if (unit === 'kph') unit = 'km/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_humid.ts
Normal file
17
futurehome/src/services/sensor_humid.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_humid(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "humidity",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "%",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_lumin.ts
Normal file
17
futurehome/src/services/sensor_lumin.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_lumin(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "illuminance",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "Lux",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_moist.ts
Normal file
17
futurehome/src/services/sensor_moist.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_moist(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "moisture",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "%",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_noise.ts
Normal file
17
futurehome/src/services/sensor_noise.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_noise(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "sound_pressure",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "dB",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_power.ts
Normal file
17
futurehome/src/services/sensor_power.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_power(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "power",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "W",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
@ -9,7 +9,7 @@ export function cmps_sensor_presence(vinculumDeviceData: VinculumPd7Device, svc:
|
||||
[svc.address]: {
|
||||
p: "binary_sensor",
|
||||
device_class: "presence",
|
||||
value_template: `{{ value_json['${svc.address}'].presence }}`,
|
||||
value_template: `{{ value_json['${svc.address}'].presence | iif('on', 'off') }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
|
17
futurehome/src/services/sensor_rain.ts
Normal file
17
futurehome/src/services/sensor_rain.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_rain(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[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 }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_rotation.ts
Normal file
16
futurehome/src/services/sensor_rotation.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_rotation(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "rpm",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_seismicint.ts
Normal file
16
futurehome/src/services/sensor_seismicint.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_seismicint(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "EMCRO",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_seismicmag.ts
Normal file
16
futurehome/src/services/sensor_seismicmag.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_seismicmag(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "MB",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_solarrad.ts
Normal file
16
futurehome/src/services/sensor_solarrad.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_solarrad(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "w/m2",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_tank.ts
Normal file
17
futurehome/src/services/sensor_tank.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_tank(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "volume_storage",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "l",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
@ -5,11 +5,15 @@ import { CMP } from "../ha/publish_device";
|
||||
export function cmps_sensor_temp(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "℃";
|
||||
if (unit === 'C') unit = '℃';
|
||||
if (unit === 'F') unit = '℉';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "temperature",
|
||||
unit_of_measurement: "°C",
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
|
16
futurehome/src/services/sensor_tidelvl.ts
Normal file
16
futurehome/src/services/sensor_tidelvl.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_tidelvl(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_uv.ts
Normal file
16
futurehome/src/services/sensor_uv.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_uv(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? 'index',
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
16
futurehome/src/services/sensor_veloc.ts
Normal file
16
futurehome/src/services/sensor_veloc.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_veloc(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "m/s",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_voltage.ts
Normal file
17
futurehome/src/services/sensor_voltage.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_voltage(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "voltage",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "V",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_watflow.ts
Normal file
17
futurehome/src/services/sensor_watflow.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_watflow(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[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 }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_watpressure.ts
Normal file
17
futurehome/src/services/sensor_watpressure.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_watpressure(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "pressure",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "kPa",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
21
futurehome/src/services/sensor_wattemp.ts
Normal file
21
futurehome/src/services/sensor_wattemp.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_wattemp(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "℃";
|
||||
if (unit === 'C') unit = '℃';
|
||||
if (unit === 'F') unit = '℉';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "temperature",
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
17
futurehome/src/services/sensor_weight.ts
Normal file
17
futurehome/src/services/sensor_weight.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_weight(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "weigh",
|
||||
unit_of_measurement: svc.props?.sup_units?.[0] ?? "kg",
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
20
futurehome/src/services/sensor_wind.ts
Normal file
20
futurehome/src/services/sensor_wind.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { InclusionReportService } from "../fimp/inclusion_report";
|
||||
import { VinculumPd7Device } from "../fimp/vinculum_pd7_device";
|
||||
import { CMP } from "../ha/publish_device";
|
||||
|
||||
export function cmps_sensor_wind(vinculumDeviceData: VinculumPd7Device, svc: InclusionReportService): { [key: string]: CMP } {
|
||||
if (!svc.address) { return {}; }
|
||||
|
||||
let unit = svc.props?.sup_units?.[0] ?? "km/h";
|
||||
if (unit === 'kph') unit = 'km/h';
|
||||
|
||||
return {
|
||||
[svc.address]: {
|
||||
p: "sensor",
|
||||
device_class: "wind_speed",
|
||||
unit_of_measurement: unit,
|
||||
value_template: `{{ value_json['${svc.address}'].sensor }}`,
|
||||
unique_id: svc.address,
|
||||
},
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user