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
@@ -223,30 +224,46 @@ 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' ,
231
- 'Cooling allowed (away mode)'
230
+ 'Cooling allowed (away mode)' ,
231
+ // Not supported by some units
232
+ { 'enabled_by_default' : automationType !== AUTOMATION_TYPE_LEGACY_EDA }
232
233
) ,
233
234
'awayHeatingAllowed' : createSettingSwitchConfiguration (
234
235
configurationBase ,
235
236
'awayHeatingAllowed' ,
236
- 'Heating allowed (away mode)'
237
+ 'Heating allowed (away mode)' ,
238
+ // Not supported by some units
239
+ { 'enabled_by_default' : automationType !== AUTOMATION_TYPE_LEGACY_EDA }
237
240
) ,
238
241
'longAwayCoolingAllowed' : createSettingSwitchConfiguration (
239
242
configurationBase ,
240
243
'longAwayCoolingAllowed' ,
241
- 'Cooling allowed (long away mode)'
244
+ 'Cooling allowed (long away mode)' ,
245
+ // Not supported by some units
246
+ { 'enabled_by_default' : automationType !== AUTOMATION_TYPE_LEGACY_EDA }
242
247
) ,
243
248
'longAwayHeatingAllowed' : createSettingSwitchConfiguration (
244
249
configurationBase ,
245
250
'longAwayHeatingAllowed' ,
246
- 'Heating allowed (long away mode)'
251
+ 'Heating allowed (long away mode)' ,
252
+ // Not supported by some units
253
+ { 'enabled_by_default' : automationType !== AUTOMATION_TYPE_LEGACY_EDA }
247
254
) ,
248
255
}
249
256
257
+ // Optional switches depending on automation type
258
+ if ( automationType !== AUTOMATION_TYPE_LEGACY_EDA ) {
259
+ switchConfigurationMap = {
260
+ ...switchConfigurationMap ,
261
+ // Settings switches
262
+ 'coolingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'coolingAllowed' , 'Cooling allowed' ) ,
263
+ 'heatingAllowed' : createSettingSwitchConfiguration ( configurationBase , 'heatingAllowed' , 'Heating allowed' ) ,
264
+ }
265
+ }
266
+
250
267
// Binary sensors for alarms
251
268
let binarySensorConfigurationMap = { }
252
269
0 commit comments