mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2026-06-17 13:30:15 +00:00
Compare commits
1 Commits
dependabot
...
claude/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87dded2e4a |
2
.github/workflows/builder.yaml
vendored
2
.github/workflows/builder.yaml
vendored
@@ -98,7 +98,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: env.BUILD_ARGS != '--test'
|
if: env.BUILD_ARGS != '--test'
|
||||||
uses: docker/login-action@v3.7.0
|
uses: docker/login-action@v3.5.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
|
|||||||
@@ -370,16 +370,25 @@ export function _meter__components(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map FIMP unit names to HA-compatible unit_of_measurement values
|
||||||
|
const haUnit =
|
||||||
|
unit === 'power_factor' ? '' :
|
||||||
|
unit === 'VAr' ? 'var' :
|
||||||
|
unit === 'kVArh' ? 'kvarh' : unit;
|
||||||
|
|
||||||
const component: SensorComponent = {
|
const component: SensorComponent = {
|
||||||
unique_id: componentId,
|
unique_id: componentId,
|
||||||
platform: 'sensor',
|
platform: 'sensor',
|
||||||
entity_category: 'diagnostic',
|
entity_category: 'diagnostic',
|
||||||
name: friendlyName,
|
name: friendlyName,
|
||||||
unit_of_measurement: unit,
|
|
||||||
state_class: stateClass,
|
state_class: stateClass,
|
||||||
value_template: `{{ value_json['${svc.addr}'].meter.${unit}.val | default(0) }}`,
|
value_template: `{{ value_json['${svc.addr}'].meter.${unit}.val | default(0) }}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (haUnit) {
|
||||||
|
component.unit_of_measurement = haUnit;
|
||||||
|
}
|
||||||
|
|
||||||
if (deviceClass) {
|
if (deviceClass) {
|
||||||
component.device_class = deviceClass;
|
component.device_class = deviceClass;
|
||||||
}
|
}
|
||||||
@@ -460,16 +469,24 @@ export function _meter__components(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map FIMP unit names to HA-compatible unit_of_measurement values
|
||||||
|
const haUnit =
|
||||||
|
unit === 'VAr' ? 'var' :
|
||||||
|
unit === 'kVArh' ? 'kvarh' : unit;
|
||||||
|
|
||||||
const component: SensorComponent = {
|
const component: SensorComponent = {
|
||||||
unique_id: componentId,
|
unique_id: componentId,
|
||||||
platform: 'sensor',
|
platform: 'sensor',
|
||||||
entity_category: 'diagnostic',
|
entity_category: 'diagnostic',
|
||||||
name: friendlyName,
|
name: friendlyName,
|
||||||
unit_of_measurement: unit,
|
|
||||||
state_class: stateClass,
|
state_class: stateClass,
|
||||||
value_template: `{{ value_json['${svc.addr}'].meter_export.${unit}.val | default(0) }}`,
|
value_template: `{{ value_json['${svc.addr}'].meter_export.${unit}.val | default(0) }}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (haUnit) {
|
||||||
|
component.unit_of_measurement = haUnit;
|
||||||
|
}
|
||||||
|
|
||||||
if (deviceClass) {
|
if (deviceClass) {
|
||||||
component.device_class = deviceClass;
|
component.device_class = deviceClass;
|
||||||
}
|
}
|
||||||
@@ -510,14 +527,25 @@ export function _meter__components(
|
|||||||
|
|
||||||
// Determine unit based on value name
|
// Determine unit based on value name
|
||||||
let unit = '';
|
let unit = '';
|
||||||
if (
|
const isPhasePower =
|
||||||
valueName.startsWith('p_') ||
|
valueName.startsWith('p_') ||
|
||||||
valueName.startsWith('p1') ||
|
valueName.startsWith('p1') ||
|
||||||
valueName.startsWith('p2') ||
|
valueName.startsWith('p2') ||
|
||||||
valueName.startsWith('p3') ||
|
valueName.startsWith('p3');
|
||||||
valueName === 'dc_p'
|
if (isPhasePower && valueName.includes('_react')) {
|
||||||
) {
|
unit = 'var';
|
||||||
|
} else if (isPhasePower && valueName.includes('_apparent')) {
|
||||||
|
unit = 'VA';
|
||||||
|
} else if (isPhasePower || valueName === 'dc_p') {
|
||||||
unit = 'W';
|
unit = 'W';
|
||||||
|
} else if (
|
||||||
|
(valueName.startsWith('e_') ||
|
||||||
|
valueName.startsWith('e1') ||
|
||||||
|
valueName.startsWith('e2') ||
|
||||||
|
valueName.startsWith('e3')) &&
|
||||||
|
valueName.includes('_react')
|
||||||
|
) {
|
||||||
|
unit = 'kvarh';
|
||||||
} else if (
|
} else if (
|
||||||
valueName.startsWith('e_') ||
|
valueName.startsWith('e_') ||
|
||||||
valueName.startsWith('e1') ||
|
valueName.startsWith('e1') ||
|
||||||
@@ -565,9 +593,9 @@ export function _meter__components(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set suggested display precision
|
// Set suggested display precision
|
||||||
if (unit === 'kWh') {
|
if (unit === 'kWh' || unit === 'kvarh') {
|
||||||
component.suggested_display_precision = 3;
|
component.suggested_display_precision = 3;
|
||||||
} else if (unit === 'W' || unit === 'V' || unit === 'A') {
|
} else if (unit === 'W' || unit === 'V' || unit === 'A' || unit === 'var' || unit === 'VA') {
|
||||||
component.suggested_display_precision = 1;
|
component.suggested_display_precision = 1;
|
||||||
} else if (unit === 'Hz') {
|
} else if (unit === 'Hz') {
|
||||||
component.suggested_display_precision = 2;
|
component.suggested_display_precision = 2;
|
||||||
|
|||||||
@@ -72,12 +72,15 @@ export function _sensor_numeric__components(
|
|||||||
|
|
||||||
if (!data) return undefined;
|
if (!data) return undefined;
|
||||||
|
|
||||||
const device_class = data[0];
|
let device_class = data[0];
|
||||||
const name = data[1];
|
const name = data[1];
|
||||||
let unit = svc.props?.sup_units?.[0] ?? data[2];
|
let unit = svc.props?.sup_units?.[0] ?? data[2];
|
||||||
if (unit === 'C') unit = '°C';
|
if (unit === 'C') unit = '°C';
|
||||||
if (unit === 'F') unit = '°F';
|
if (unit === 'F') unit = '°F';
|
||||||
if (unit === 'kph') unit = 'km/h';
|
if (unit === 'kph') unit = 'km/h';
|
||||||
|
if (unit === 'Lux') unit = 'lx';
|
||||||
|
// HA rejects illuminance + %; drop device_class for percentage-reporting sensors
|
||||||
|
if (device_class === 'illuminance' && unit === '%') device_class = undefined;
|
||||||
const state_class = data[3];
|
const state_class = data[3];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user