diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 2af4b18a..2ef6f697 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -296,6 +296,25 @@ const configurations = { value_template: '{{ value_json.state }}', }, }, + + // Thermostat/HVAC + 'thermostat': { + type: 'climate', + object_id: 'climate', + discovery_payload: { + 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, + }, + }, }; const switchWithPostfix = (postfix) => { @@ -501,7 +520,7 @@ const mapping = { 'GL-B-008Z': [configurations.light_brightness_colortemp_colorxy], 'AV2010/25': [configurations.switch, configurations.sensor_power], 'E12-N14': [configurations.light_brightness], - '1TST-EU': [], + '1TST-EU': [configurations.thermostat, configurations.sensor_battery], 'RB 178 T': [configurations.light_brightness_colortemp], '45856GE': [configurations.switch], 'GL-D-003Z': [configurations.light_brightness_colortemp_colorxy], @@ -709,7 +728,7 @@ class HomeAssistant { // Set json_attributes_topic for types which support this // https://github.com/Koenkk/zigbee2mqtt/issues/840 - if (['binary_sensor', 'sensor', 'lock'].includes(config.type)) { + if (['binary_sensor', 'sensor', 'lock', 'climate'].includes(config.type)) { payload.json_attributes_topic = payload.state_topic; } @@ -762,6 +781,26 @@ class HomeAssistant { payload.set_position_topic = payload.command_topic; } + if (payload.mode_state_topic) { + payload.mode_state_topic = stateTopic; + } + + if (payload.mode_command_topic) { + payload.mode_command_topic = `${stateTopic}/set/system_mode`; + } + + if (payload.current_temperature_topic) { + payload.current_temperature_topic = stateTopic; + } + + if (payload.temperature_state_topic) { + payload.temperature_state_topic = stateTopic; + } + + if (payload.temperature_command_topic) { + payload.temperature_command_topic = `${stateTopic}/set/occupied_heating_setpoint`; + } + // Override configuration with user settings. if (device.hasOwnProperty('homeassistant')) { const add = (obj) => {