mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2026-02-11 07:15:38 +00:00
Add support for 'parameters' service
This commit is contained in:
@@ -22,6 +22,7 @@ import { indicator_ctrl__components } from '../services/indicator_ctrl';
|
||||
import { media_player__components } from '../services/media_player';
|
||||
import { out_bin_switch__components } from '../services/out_bin_switch';
|
||||
import { out_lvl_switch__components } from '../services/out_lvl_switch';
|
||||
import { parameters__components } from '../services/parameters';
|
||||
import { scene_ctrl__components } from '../services/scene_ctrl';
|
||||
import { schedule_entry__components } from '../services/schedule_entry';
|
||||
import { siren_ctrl__components } from '../services/siren_ctrl';
|
||||
@@ -169,6 +170,7 @@ const serviceHandlers: {
|
||||
meter_cooling: _meter__components,
|
||||
out_bin_switch: out_bin_switch__components,
|
||||
out_lvl_switch: out_lvl_switch__components,
|
||||
parameters: parameters__components,
|
||||
scene_ctrl: scene_ctrl__components,
|
||||
schedule_entry: schedule_entry__components,
|
||||
sensor_accelx: _sensor_numeric__components,
|
||||
@@ -301,9 +303,6 @@ export function haPublishDevice(parameters: {
|
||||
svcName,
|
||||
);
|
||||
if (!result) {
|
||||
log.error(
|
||||
`Invalid service data prevented component creation: ${parameters.vinculumDeviceData} ${svc}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ const attributeTypeKeyMap: Record<string, string> = {
|
||||
alarm: 'event',
|
||||
meter: 'props.unit',
|
||||
meter_export: 'props.unit',
|
||||
param: 'parameter_id',
|
||||
};
|
||||
|
||||
function getNestedValue(obj: any, path: string): any {
|
||||
@@ -211,10 +212,21 @@ function processAttributeValues(values: any[], attrName?: string): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Sort by timestamp to get the latest values first
|
||||
// Special handling for "param" attributes
|
||||
if (attrName === 'param') {
|
||||
const paramMap: Record<string, any> = {};
|
||||
for (const entry of values) {
|
||||
if (entry.parameter_id) {
|
||||
paramMap[entry.parameter_id] = { ...entry };
|
||||
}
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
// Sort by timestamp to get the latest values first (only if ts exists)
|
||||
const sortedValues = [...values].sort((a, b) => {
|
||||
const tsA = new Date(a.ts).getTime();
|
||||
const tsB = new Date(b.ts).getTime();
|
||||
const tsA = a.ts ? new Date(a.ts).getTime() : 0;
|
||||
const tsB = b.ts ? new Date(b.ts).getTime() : 0;
|
||||
return tsB - tsA; // Latest first
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user