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; }