Merge pull request #42 from earwin/master

Conform to changed climate traits API from esphome v1.9.4

Fixes GH-41
This commit is contained in:
Geoff Davis 2021-08-17 21:01:38 -07:00 committed by GitHub
commit fd97fca488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View File

@ -70,17 +70,19 @@ def to_code(config):
if CONF_BAUD_RATE in config:
cg.add(var.set_baud_rate(config[CONF_BAUD_RATE]))
traits = []
for mode in config[CONF_SUPPORTS][CONF_MODE]:
supports = config[CONF_SUPPORTS]
traits = var.config_traits()
for mode in supports[CONF_MODE]:
if mode == 'OFF':
continue
traits.append(f'set_supports_{mode.lower()}_mode')
for mode in config[CONF_SUPPORTS][CONF_FAN_MODE]:
traits.append(f'set_supports_fan_mode_{mode.lower()}')
for mode in config[CONF_SUPPORTS][CONF_SWING_MODE]:
traits.append(f'set_supports_swing_mode_{mode.lower()}')
for trait in traits:
cg.add(getattr(var.config_traits(), trait)(True))
cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode]))
for mode in supports[CONF_FAN_MODE]:
cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode]))
for mode in supports[CONF_SWING_MODE]:
cg.add(traits.add_supported_swing_mode(climate.CLIMATE_SWING_MODES[mode]))
yield cg.register_component(var, config)
yield climate.register_climate(var, config)

View File

@ -37,7 +37,6 @@ MitsubishiHeatPump::MitsubishiHeatPump(
this->traits_.set_supports_action(true);
this->traits_.set_supports_current_temperature(true);
this->traits_.set_supports_two_point_target_temperature(false);
this->traits_.set_supports_away(false);
this->traits_.set_visual_min_temperature(ESPMHP_MIN_TEMPERATURE);
this->traits_.set_visual_max_temperature(ESPMHP_MAX_TEMPERATURE);
this->traits_.set_visual_temperature_step(ESPMHP_TEMPERATURE_STEP);