Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "number",
"title": {
"en": "Heat exchanger speed"
},
"icon": "/assets/capabilities/measure_motor_rpm.svg",
"units": {
"en": "%"
},
"min": 0,
"max": 100,
"decimals": 0,
"getable": true,
"setable": false,
"uiComponent": "sensor",
"insights": true
}
19 changes: 19 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
"measure_humidity",
"dehumidification_active",
"free_cooling_active",
"measure_heat_exchanger_speed_percent",
"measure_power",
"fan_mode",
"ventilation_stopped",
Expand Down Expand Up @@ -1227,6 +1228,7 @@
"measure_humidity",
"dehumidification_active",
"free_cooling_active",
"measure_heat_exchanger_speed_percent",
"measure_power",
"fan_mode",
"ventilation_stopped",
Expand Down Expand Up @@ -1896,6 +1898,23 @@
"setable": false,
"insights": true
},
"measure_heat_exchanger_speed_percent": {
"type": "number",
"title": {
"en": "Heat exchanger speed"
},
"icon": "/assets/capabilities/measure_motor_rpm.svg",
"units": {
"en": "%"
},
"min": 0,
"max": 100,
"decimals": 0,
"getable": true,
"setable": false,
"uiComponent": "sensor",
"insights": true
},
"measure_motor_rpm": {
"type": "number",
"title": {
Expand Down
1 change: 1 addition & 0 deletions drivers/nordic-cloud/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"measure_humidity",
"dehumidification_active",
"free_cooling_active",
"measure_heat_exchanger_speed_percent",
"measure_power",
"fan_mode",
"ventilation_stopped",
Expand Down
1 change: 1 addition & 0 deletions drivers/nordic/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"measure_humidity",
"dehumidification_active",
"free_cooling_active",
"measure_heat_exchanger_speed_percent",
"measure_power",
"fan_mode",
"ventilation_stopped",
Expand Down
1 change: 1 addition & 0 deletions lib/FlexitNordicBaseDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const REQUIRED_CAPABILITIES = [
RESET_FILTER_CAPABILITY,
'measure_fan_setpoint_percent',
'measure_fan_setpoint_percent.extract',
'measure_heat_exchanger_speed_percent',
] as const;

interface SuppressedSetting {
Expand Down
15 changes: 8 additions & 7 deletions lib/UnitRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const COOKER_HOOD_ON = 1;
const FREE_COOLING_ACTIVE_MODE_VALUE = 10;

const BACNET_OBJECTS = {
heatExchangerSpeed: { type: OBJECT_TYPE.ANALOG_OUTPUT, instance: 0 },
comfortButton: { type: OBJECT_TYPE.BINARY_VALUE, instance: 50 },
comfortButtonDelay: { type: OBJECT_TYPE.POSITIVE_INTEGER_VALUE, instance: 318 },
ventilationMode: { type: OBJECT_TYPE.MULTI_STATE_VALUE, instance: 42 },
Expand Down Expand Up @@ -359,6 +360,7 @@ const CAPABILITY_MAPPINGS = [
{ dataKey: 'measure_temperature.outdoor', capability: 'measure_temperature.outdoor' },
{ dataKey: 'measure_temperature.exhaust', capability: 'measure_temperature.exhaust' },
{ dataKey: 'measure_temperature.extract', capability: 'measure_temperature.extract' },
{ dataKey: 'measure_heat_exchanger_speed_percent', capability: 'measure_heat_exchanger_speed_percent' },
{ dataKey: 'measure_power', capability: 'measure_power' },
{ dataKey: 'measure_humidity', capability: 'measure_humidity' },
{ dataKey: 'measure_motor_rpm', capability: 'measure_motor_rpm' },
Expand Down Expand Up @@ -865,6 +867,7 @@ function buildPollRequest() {
presentValueRequest({ type: OBJECT_TYPE.ANALOG_INPUT, instance: 96 }), // Humidity
presentValueRequest({ type: OBJECT_TYPE.ANALOG_VALUE, instance: 194 }), // Heater Power
presentValueRequest(BACNET_OBJECTS.heatingCoilEnable), // Heating coil enable
presentValueRequest(BACNET_OBJECTS.heatExchangerSpeed), // Rotor speed %

// Fan capabilities
presentValueRequest({ type: OBJECT_TYPE.ANALOG_INPUT, instance: 5 }), // Fan RPM Supply
Expand Down Expand Up @@ -911,6 +914,10 @@ function buildPollRequest() {
}

const POLL_VALUE_MAPPINGS: Record<string, (value: number, target: PollParseTarget) => void> = {
[objectKey(
BACNET_OBJECTS.heatExchangerSpeed.type,
BACNET_OBJECTS.heatExchangerSpeed.instance,
)]: mapPollValue('measure_heat_exchanger_speed_percent'),
[objectKey(
TARGET_TEMPERATURE_OBJECTS.home.type,
TARGET_TEMPERATURE_OBJECTS.home.instance,
Expand Down Expand Up @@ -4564,13 +4571,7 @@ export class UnitRegistry {
paths.slice(midpoint),
depth + 1,
);
const datapoints = { ...firstHalf, ...secondHalf };
if (Object.keys(datapoints).length === 0) {
throw new Error(
`[UnitRegistry] Cloud poll for ${unit.unitId} (plant ${plantId}) returned no datapoints`,
);
}
return datapoints;
return { ...firstHalf, ...secondHalf };
}
}

Expand Down
38 changes: 38 additions & 0 deletions test/cloud_transport.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function defaultSensorValues(): Array<{ type: number; instance: number; value: n
{ type: OBJ.ANALOG_VALUE, instance: 194, value: 0.5 }, // heater power (kW)
{ type: OBJ.BINARY_VALUE, instance: 445, value: 1 }, // heating coil on

// Rotor speed percentage is separate from heater power and efficiency.
{ type: OBJ.ANALOG_OUTPUT, instance: 0, value: 6.25 },

// Fan
{ type: OBJ.ANALOG_INPUT, instance: 5, value: 1200 }, // supply RPM
{ type: OBJ.ANALOG_INPUT, instance: 12, value: 1180 }, // extract RPM
Expand Down Expand Up @@ -411,6 +414,7 @@ describe('Cloud transport – UnitRegistry integration', () => {
expect(mock.capabilityValues['measure_temperature.exhaust']).toBe(22.0);
expect(mock.capabilityValues['measure_temperature.extract']).toBe(23.1);
expect(mock.capabilityValues['measure_humidity']).toBe(45);
expect(mock.capabilityValues['measure_heat_exchanger_speed_percent']).toBe(6.25);
expect(mock.capabilityValues['measure_motor_rpm']).toBe(1200);
expect(mock.capabilityValues['measure_motor_rpm.extract']).toBe(1180);
expect(mock.capabilityValues['measure_fan_speed_percent']).toBe(75);
Expand All @@ -422,6 +426,40 @@ describe('Cloud transport – UnitRegistry integration', () => {
expect(mock.capabilityValues['measure_power']).toBe(500);
});

it.each([0, 6.25, 100])('reports heat exchanger speed %s as a percentage via cloud', async (speed) => {
const sensorValues = defaultSensorValues();
sensorValues.find((entry) => entry.type === OBJ.ANALOG_OUTPUT && entry.instance === 0)!.value = speed;
mockClient = makeMockCloudClient({ sensorValues });
registry.registerCloud(UNIT_ID, mock.device, { plantId: PLANT_ID, client: mockClient });
await sleep(50);

expect(mock.capabilityValues['measure_heat_exchanger_speed_percent']).toBe(speed);
const paths = mockClient.readDatapoints.getCalls().flatMap((call) => call.args[1]);
expect(paths).toContain(bacnetObjectToCloudPath(OBJ.ANALOG_OUTPUT, 0));
expect(mockClient.writeDatapoint.called).toBe(false);
});

it.each([
{ paths: [bacnetObjectToCloudPath(OBJ.ANALOG_OUTPUT, 0)] },
{ paths: [bacnetObjectToCloudPath(OBJ.ANALOG_OUTPUT, 0), bacnetObjectToCloudPath(OBJ.ANALOG_INPUT, 5)] },
])('continues cloud polling without inventing rotor speed with unsupported paths $paths', async ({ paths }) => {
mockClient = makeMockCloudClient({
sensorValues: defaultSensorValues().filter((entry) => (
entry.type !== OBJ.ANALOG_OUTPUT || entry.instance !== 0
)),
unsupportedReadPaths: paths,
});
registry.registerCloud(UNIT_ID, mock.device, { plantId: PLANT_ID, client: mockClient });
await sleep(100);

const unit = (registry as any).units.get(UNIT_ID);
expect(paths.every((path) => unit.unsupportedCloudPollPaths.has(path))).toBe(true);
expect(unit.consecutiveFailures).toBe(0);
expect(mock.capabilityValues['measure_heat_exchanger_speed_percent']).toBe(undefined);
expect(mock.capabilityValues.measure_temperature).toBe(21.5);
expect(mock.device.setUnavailable.called).toBe(false);
});

it('writes temperature setpoint via cloud', async () => {
registry.registerCloud(UNIT_ID, mock.device, {
plantId: PLANT_ID,
Expand Down
12 changes: 12 additions & 0 deletions test/nordic_device.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ describe('Nordic device', () => {
expect(registryStub.register.calledOnceWithExactly('test_unit', device)).toBe(true);
});

it('adds the heat exchanger sensor to an existing paired device', async () => {
const device = new DeviceClass();
device.hasCapability.withArgs('measure_heat_exchanger_speed_percent').returns(false);

await device.onInit();

expect(device.addCapability.calledOnceWithExactly('measure_heat_exchanger_speed_percent')).toBe(true);
expect(device.registerCapabilityListener.getCalls().some((call: any) => (
call.args[0] === 'measure_heat_exchanger_speed_percent'
))).toBe(false);
});

it('adds dehumidification capability during onInit when missing', async () => {
const device = new DeviceClass();
device.hasCapability.withArgs(EXHAUST_TEMP_CAPABILITY).returns(true);
Expand Down
15 changes: 15 additions & 0 deletions test/unit_registry_fake_e2e.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,21 @@ describe('UnitRegistry fake-unit e2e', { timeout: 10000 }, () => {
expect(device.setUnavailable.notCalled).toBe(true);
});

it('polls heat exchanger speed over BACnet and reports zero when ventilation stops', async () => {
const device = makeMockDevice(SERVER_BIND_ADDRESS, serverPort, 4380);
registry.register('test_unit', device);
const hasSpeed = (speed: number) => device.setCapabilityValue.getCalls().some((call: any) => (
call.args[0] === 'measure_heat_exchanger_speed_percent' && call.args[1] === speed
));

await waitFor(() => hasSpeed(65));
const observed = state.readPresentValue(OBJECT_TYPE.ANALOG_OUTPUT, 0, PROPERTY_ID.PRESENT_VALUE);
expect(observed.ok && observed.value.value).toBe(65);

await registry.stopVentilation('test_unit');
await waitFor(() => hasSpeed(0));
});

it('writes filter change interval to the unit and verifies it', async () => {
const device = makeMockDevice(SERVER_BIND_ADDRESS, serverPort, 4380);
state.setFilterLimitHours(4380);
Expand Down
Loading