diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 88966aae..6b14baa2 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -361,23 +361,25 @@ const cfg = { }, // Thermostat/HVAC - 'thermostat': { - type: 'climate', - object_id: 'climate', - discovery_payload: { - state_topic: false, - min_temp: 7, - max_temp: 30, - modes: ['off', 'auto', 'heat'], - mode_state_topic: true, - mode_state_template: '{{ value_json.system_mode }}', - mode_command_topic: true, - current_temperature_topic: true, - current_temperature_template: '{{ value_json.local_temperature }}', - temperature_state_topic: true, - temperature_state_template: '{{ value_json.occupied_heating_setpoint }}', - temperature_command_topic: true, - }, + 'thermostat': (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heating_setpoint') => { + return { + type: 'climate', + object_id: 'climate', + discovery_payload: { + state_topic: false, + min_temp: `${minTemp}`, + max_temp: `${maxTemp}`, + modes: ['off', 'auto', 'heat'], + mode_state_topic: true, + mode_state_template: '{{ value_json.system_mode }}', + mode_command_topic: true, + current_temperature_topic: true, + current_temperature_template: '{{ value_json.local_temperature }}', + temperature_state_topic: true, + temperature_state_template: `{{ value_json.${temperatureStateProperty} }}`, + temperature_command_topic: temperatureStateProperty, + }, + }; }, // Fan @@ -596,7 +598,7 @@ const mapping = { 'GL-B-008Z': [cfg.light_brightness_colortemp_colorxy], 'AV2010/25': [cfg.switch, cfg.sensor_power], 'E12-N14': [cfg.light_brightness], - '1TST-EU': [cfg.thermostat, cfg.sensor_battery], + '1TST-EU': [cfg.thermostat(), cfg.sensor_battery], 'RB 178 T': [cfg.light_brightness_colortemp], '45856GE': [cfg.switch], 'GL-D-003Z': [cfg.light_brightness_colortemp_colorxy], @@ -627,7 +629,7 @@ const mapping = { '4090130P7': [cfg.light_brightness_colortemp_colorxy], '100.110.39': [cfg.light_brightness_colortemp_colorxy], 'TI0001': [switchWithPostfix('left'), switchWithPostfix('right')], - 'SPZB0001': [cfg.thermostat, cfg.sensor_battery], + 'SPZB0001': [cfg.thermostat(5, 30, 'current_heating_setpoint'), cfg.sensor_battery], 'HS3CG': [cfg.binary_sensor_gas], '81825': [cfg.sensor_action], 'Z809AF': [cfg.switch, cfg.sensor_power], @@ -851,8 +853,8 @@ const mapping = { 'ZM-CSW002-D': [switchWithPostfix('l1'), switchWithPostfix('l2'), cfg.sensor_power], 'LVS-SN10ZW': [cfg.sensor_battery, cfg.binary_sensor_occupancy], 'LVS-ZB15R': [cfg.switch], - 'TH1123ZB': [cfg.thermostat], - 'Zen-01-W': [cfg.thermostat], + 'TH1123ZB': [cfg.thermostat()], + 'Zen-01-W': [cfg.thermostat()], '9290022166': [cfg.light_brightness_colortemp_colorxy], 'PM-C140-ZB': [cfg.sensor_power, cfg.switch], 'ptvo.switch': [ @@ -1088,7 +1090,7 @@ class HomeAssistant extends BaseExtension { } if (payload.temperature_command_topic) { - payload.temperature_command_topic = `${stateTopic}/set/occupied_heating_setpoint`; + payload.temperature_command_topic = `${stateTopic}/set/${payload.temperature_command_topic}`; } if (payload.speed_command_topic) {