8
8
TOPIC_PREFIX_SETTINGS ,
9
9
} from './mqtt.mjs'
10
10
import { createLogger } from './logger.mjs'
11
- import { AVAILABLE_ALARMS , createModelNameString } from './enervent.mjs'
11
+ import { AUTOMATION_TYPE_LEGACY_EDA , AVAILABLE_ALARMS , createModelNameString } from './enervent.mjs'
12
12
13
13
const logger = createLogger ( 'homeassistant' )
14
14
@@ -17,6 +17,7 @@ export const configureMqttDiscovery = async (modbusClient, mqttClient) => {
17
17
// names, so it must match [a-zA-Z0-9_-].
18
18
const modbusDeviceInformation = await getDeviceInformation ( modbusClient )
19
19
const softwareVersion = modbusDeviceInformation . softwareVersion
20
+ const automationType = modbusDeviceInformation . automationType
20
21
const modelName = createModelNameString ( modbusDeviceInformation )
21
22
const deviceIdentifier = createDeviceIdentifierString ( modbusDeviceInformation )
22
23
@@ -208,7 +209,7 @@ export const configureMqttDiscovery = async (modbusClient, mqttClient) => {
208
209
}
209
210
210
211
// Configurable switches
211
- const switchConfigurationMap = {
212
+ let switchConfigurationMap = {
212
213
// Mode switches
213
214
'away' : createModeSwitchConfiguration ( configurationBase , 'away' , 'Away' ) ,
214
215
'longAway' : createModeSwitchConfiguration ( configurationBase , 'longAway' , 'Long away' ) ,
@@ -223,8 +224,6 @@ export const configureMqttDiscovery = async (modbusClient, mqttClient) => {
223
224
) ,
224
225
'eco' : createModeSwitchConfiguration ( configurationBase , 'eco' , 'Eco' ) ,
225
226
// Settings switches
226
- 'coolingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'coolingAllowed' , 'Cooling allowed' ) ,
227
- 'heatingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'heatingAllowed' , 'Heating allowed' ) ,
228
227
'awayCoolingAllowed' : createSettingSwitchConfiguration (
229
228
configurationBase ,
230
229
'awayCoolingAllowed' ,
@@ -247,6 +246,16 @@ export const configureMqttDiscovery = async (modbusClient, mqttClient) => {
247
246
) ,
248
247
}
249
248
249
+ // Optional switches depending on automation type
250
+ if ( automationType !== AUTOMATION_TYPE_LEGACY_EDA ) {
251
+ switchConfigurationMap = {
252
+ ...switchConfigurationMap ,
253
+ // Settings switches
254
+ 'coolingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'coolingAllowed' , 'Cooling allowed' ) ,
255
+ 'heatingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'heatingAllowed' , 'Heating allowed' ) ,
256
+ }
257
+ }
258
+
250
259
// Binary sensors for alarms
251
260
let binarySensorConfigurationMap = { }
252
261
0 commit comments