From 44224b4d6b6fd0ce760db1697011b08e887f8794 Mon Sep 17 00:00:00 2001 From: Hacker-CB Date: Wed, 30 Sep 2020 20:52:11 +0300 Subject: [PATCH] Added ETOP HT-08 Thermostat and HT-10 TRV (#4491) * Added ETOP HT-08 Thermostat References: * https://github.com/Koenkk/zigbee2mqtt/issues/4185 * https://github.com/Koenkk/zigbee2mqtt/issues/1856 * https://github.com/Koenkk/zigbee2mqtt/issues/4486 * http://www.etopcontrols.com/thermostat/detail/HT-08.html * Rename `away` to `away_mode` * Added ETOP HT-10 TRV Minor fixes for HT-08 References: * https://github.com/Koenkk/zigbee2mqtt/issues/1856 * http://www.etopcontrols.com/thermostat/detail/HT-10.html --- lib/extension/homeassistant.js | 41 ++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 5d377c2e..8538d770 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -861,10 +861,25 @@ const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heati } // hold_modes empty <=> don't use presets if (holdModes.length > 0) { - retVal.discovery_payload.hold_modes = holdModes; - retVal.discovery_payload.hold_command_topic = true; - retVal.discovery_payload.hold_state_template = `{{ value_json.preset }}`; - retVal.discovery_payload.hold_state_topic = true; + // NOTE: Preset 'none' will be added as first item on HA side `mqtt/climate.py preset_modes()` + const indexOfNone = holdModes.indexOf('none'); + if (indexOfNone > -1) holdModes.splice(indexOfNone, 1); + + // HA has special behaviour for the away mode + const indexOfAway = holdModes.indexOf('away'); + if (indexOfAway > -1) { + holdModes.splice(indexOfAway, 1); // HA will add "Away" to modes by itself + retVal.discovery_payload.away_mode_command_topic = true; + retVal.discovery_payload.away_mode_state_topic = true; + retVal.discovery_payload.away_mode_state_template = + '{{ value_json.away_mode }}'; + } + if (holdModes.length > 0 || indexOfAway > -1) { + retVal.discovery_payload.hold_modes = holdModes; + retVal.discovery_payload.hold_command_topic = true; + retVal.discovery_payload.hold_state_template = `{{ value_json.preset }}`; + retVal.discovery_payload.hold_state_topic = true; + } } // fan_modes empty <=> don't use fan modes if (fanModes.length > 0) { @@ -1842,6 +1857,16 @@ const mapping = { climate(5, 30, 'current_heating_setpoint', 0.5, [], [], ['schedule', 'manual', 'away', 'boost', 'complex', 'comfort', 'eco']), ], + 'HT-08': [ + cfg.lock_child_lock, + climate(5, 35, 'current_heating_setpoint', 0.5, + ['off', 'heat', 'auto'], [], ['none', 'away']), + ], + 'HT-10': [ + cfg.lock_child_lock, cfg.binary_sensor_battery_low, + climate(5, 35, 'current_heating_setpoint', 0.5, + ['off', 'heat', 'auto'], [], ['none', 'away']), + ], 'WXKG07LM': [cfg.sensor_action, cfg.sensor_battery], 'MCLH-03': [cfg.switch, cfg.sensor_voltage, cfg.sensor_power, cfg.sensor_current], '752189': [cfg.sensor_action, cfg.sensor_battery], @@ -2363,6 +2388,14 @@ class HomeAssistant extends Extension { payload.hold_state_topic = stateTopic; } + if (payload.away_mode_state_topic) { + payload.away_mode_state_topic = stateTopic; + } + + if (payload.away_mode_command_topic) { + payload.away_mode_command_topic = `${stateTopic}/set/away_mode`; + } + if (payload.current_temperature_topic) { payload.current_temperature_topic = stateTopic; }