2025-07-26 02:38:22 +02:00

32 lines
820 B
TypeScript

import {
VinculumPd7Device,
VinculumPd7Service,
} from '../fimp/vinculum_pd7_device';
import { ServiceComponentsCreationResult } from '../ha/publish_device';
export function sensor_temp__components(
topicPrefix: string,
device: VinculumPd7Device,
svc: VinculumPd7Service,
_svcName: string,
): ServiceComponentsCreationResult | undefined {
const device_class = 'temperature';
const name = undefined;
let unit = svc.props?.sup_units?.[0] ?? '°C';
if (unit === 'C') unit = '°C';
if (unit === 'F') unit = '°F';
return {
components: {
[svc.addr]: {
unique_id: svc.addr,
platform: 'sensor',
name: name,
device_class: device_class,
unit_of_measurement: unit,
value_template: `{{ value_json['${svc.addr}'].sensor }}`,
},
},
};
}