mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2025-10-11 06:52:07 -06:00
32 lines
820 B
TypeScript
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 }}`,
|
|
},
|
|
},
|
|
};
|
|
}
|