Skip to content

Commit

Permalink
Merge pull request #139 from Jalle19/ha-sensors
Browse files Browse the repository at this point in the history
Expose "exhaustAirTemperatureBeforeHeatRecovery" and "returnWaterTemp…  …erature" sensors to Home Assistant
  • Loading branch information
Jalle19 authored Feb 20, 2025
2 parents 4eabe94 + c5cfd7f commit 92bab2a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ in Home Assistant automatically through the MQTT integration. The following enti
state require a restart of the unit to resume normal operation. However, the unit cannot be restarted via Modbus
(at least not officially), so it's best to acknowledge such alarms manually.

* Some readings may be nonsensical depending on the exact ventilation unit used, e.g. "Exhaust air temperature
(before heat recovery)" can erroneously show -40 °C.

## Troubleshooting

See [docs/CONNECTION.md](./docs/CONNECTION.md)
Expand Down
10 changes: 5 additions & 5 deletions app/enervent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const ANALOG_INPUT_SENSOR_TYPES: AnalogInput[] = [

type AnalogSensorReadings = Record<string, number>

export enum AutomationHeatingType {
export enum HeatingType {
ED = 'ED/MD',
EDW = 'EDW/MDW',
EDX = 'EDX/MDX',
Expand Down Expand Up @@ -261,10 +261,10 @@ export const getAutomationAndHeatingTypeName = (heatingType: number): string =>
// M prefix is used for units with MD automation
return (
[
AutomationHeatingType.ED, // prettier-hack
AutomationHeatingType.EDW,
AutomationHeatingType.EDX,
AutomationHeatingType.EDE,
HeatingType.ED, // prettier-hack
HeatingType.EDW,
HeatingType.EDX,
HeatingType.EDE,
][heatingType] || 'unknown'
)
}
Expand Down
14 changes: 14 additions & 0 deletions app/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { createLogger } from './logger'
import {
AlarmDescription,
HeatingType,
AutomationType,
AVAILABLE_ALARMS,
createModelNameString,
Expand All @@ -28,6 +29,7 @@ export const configureMqttDiscovery = async (modbusClient: ModbusRTU, mqttClient
const modbusDeviceInformation = await getDeviceInformation(modbusClient)
const softwareVersion = modbusDeviceInformation.softwareVersion
const automationType = modbusDeviceInformation.automationType
const heatingType = modbusDeviceInformation.heatingTypeInstalled
const modelName = createModelNameString(modbusDeviceInformation)
const deviceIdentifier = createDeviceIdentifierString(modbusDeviceInformation)

Expand Down Expand Up @@ -69,6 +71,18 @@ export const configureMqttDiscovery = async (modbusClient: ModbusRTU, mqttClient
'exhaustAirTemperature',
'Exhaust air temperature'
),
'exhaustAirTemperatureBeforeHeatRecovery': createTemperatureSensorConfiguration(
configurationBase,
'exhaustAirTemperatureBeforeHeatRecovery',
'Exhaust air temperature (before heat recovery)',
{ 'enabled_by_default': heatingType !== HeatingType.EDW }
),
'returnWaterTemperature': createTemperatureSensorConfiguration(
configurationBase,
'returnWaterTemperature',
'Return water temperature',
{ 'enabled_by_default': heatingType === HeatingType.EDW }
),
'wasteAirTemperature': createTemperatureSensorConfiguration(
configurationBase,
'wasteAirTemperature',
Expand Down
4 changes: 2 additions & 2 deletions app/modbus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Readings,
Settings,
AlarmStatus,
AutomationHeatingType,
HeatingType,
} from './enervent'
import ModbusRTU from 'modbus-serial'
import { ReadCoilResult, ReadRegisterResult } from 'modbus-serial/ModbusRTU'
Expand Down Expand Up @@ -195,7 +195,7 @@ export const getReadings = async (modbusClient: ModbusRTU): Promise<Readings> =>
// While the value stored in both registers are always identical we publish two separate
// sensors to avoid confusion.
result = await mutex.runExclusive(async () => tryReadHoldingRegisters(modbusClient, 11, 2))
if (deviceInformation.heatingTypeInstalled === AutomationHeatingType.EDW) {
if (deviceInformation.heatingTypeInstalled === HeatingType.EDW) {
readings = {
...readings,
'returnWaterTemperature': parseTemperature(result.data[1]),
Expand Down

0 comments on commit 92bab2a

Please sign in to comment.