-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Use climate enums in mqtt #70696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Use climate enums in mqtt #70696
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| from homeassistant.components.climate import ( | ||
| PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA, | ||
| ClimateEntity, | ||
| ClimateEntityFeature, | ||
| ) | ||
| from homeassistant.components.climate.const import ( | ||
| ATTR_HVAC_MODE, | ||
|
|
@@ -23,14 +22,13 @@ | |
| FAN_HIGH, | ||
| FAN_LOW, | ||
| FAN_MEDIUM, | ||
| HVAC_MODE_AUTO, | ||
| HVAC_MODE_COOL, | ||
| HVAC_MODE_DRY, | ||
| HVAC_MODE_FAN_ONLY, | ||
| HVAC_MODE_HEAT, | ||
| HVAC_MODE_OFF, | ||
| PRESET_AWAY, | ||
| PRESET_NONE, | ||
| SWING_OFF, | ||
| SWING_ON, | ||
| ClimateEntityFeature, | ||
| HVACAction, | ||
| HVACMode, | ||
| ) | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import ( | ||
|
|
@@ -43,7 +41,6 @@ | |
| PRECISION_HALVES, | ||
| PRECISION_TENTHS, | ||
| PRECISION_WHOLE, | ||
| STATE_ON, | ||
| ) | ||
| from homeassistant.core import HomeAssistant, callback | ||
| import homeassistant.helpers.config_validation as cv | ||
|
|
@@ -272,12 +269,12 @@ def valid_preset_mode_configuration(config): | |
| vol.Optional( | ||
| CONF_MODE_LIST, | ||
| default=[ | ||
| HVAC_MODE_AUTO, | ||
| HVAC_MODE_OFF, | ||
| HVAC_MODE_COOL, | ||
| HVAC_MODE_HEAT, | ||
| HVAC_MODE_DRY, | ||
| HVAC_MODE_FAN_ONLY, | ||
| HVACMode.AUTO, | ||
| HVACMode.OFF, | ||
| HVACMode.COOL, | ||
| HVACMode.HEAT, | ||
| HVACMode.DRY, | ||
| HVACMode.FAN_ONLY, | ||
| ], | ||
| ): cv.ensure_list, | ||
| vol.Optional(CONF_MODE_STATE_TEMPLATE): cv.template, | ||
|
|
@@ -309,7 +306,7 @@ def valid_preset_mode_configuration(config): | |
| vol.Optional(CONF_SWING_MODE_COMMAND_TEMPLATE): cv.template, | ||
| vol.Optional(CONF_SWING_MODE_COMMAND_TOPIC): mqtt.valid_publish_topic, | ||
| vol.Optional( | ||
| CONF_SWING_MODE_LIST, default=[STATE_ON, HVAC_MODE_OFF] | ||
| CONF_SWING_MODE_LIST, default=[SWING_ON, SWING_OFF] | ||
| ): cv.ensure_list, | ||
| vol.Optional(CONF_SWING_MODE_STATE_TEMPLATE): cv.template, | ||
| vol.Optional(CONF_SWING_MODE_STATE_TOPIC): mqtt.valid_subscribe_topic, | ||
|
|
@@ -460,9 +457,9 @@ def _setup_from_config(self, config): | |
| if self._topic[CONF_FAN_MODE_STATE_TOPIC] is None: | ||
| self._current_fan_mode = FAN_LOW | ||
| if self._topic[CONF_SWING_MODE_STATE_TOPIC] is None: | ||
| self._current_swing_mode = HVAC_MODE_OFF | ||
| self._current_swing_mode = SWING_OFF | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was a bug also... |
||
| if self._topic[CONF_MODE_STATE_TOPIC] is None: | ||
| self._current_operation = HVAC_MODE_OFF | ||
| self._current_operation = HVACMode.OFF | ||
| self._feature_preset_mode = CONF_PRESET_MODE_COMMAND_TOPIC in config | ||
| if self._feature_preset_mode: | ||
| self._preset_modes = config[CONF_PRESET_MODES_LIST] | ||
|
|
@@ -773,17 +770,17 @@ def target_temperature_high(self): | |
| return self._target_temp_high | ||
|
|
||
| @property | ||
| def hvac_action(self): | ||
| def hvac_action(self) -> HVACAction | None: | ||
| """Return the current running hvac operation if supported.""" | ||
| return self._action | ||
|
|
||
| @property | ||
| def hvac_mode(self): | ||
| def hvac_mode(self) -> HVACMode: | ||
| """Return current operation ie. heat, cool, idle.""" | ||
| return self._current_operation | ||
|
|
||
| @property | ||
| def hvac_modes(self): | ||
| def hvac_modes(self) -> list[HVACMode]: | ||
| """Return the list of available operation modes.""" | ||
| return self._config[CONF_MODE_LIST] | ||
|
|
||
|
|
@@ -859,7 +856,7 @@ async def _set_temperature( | |
| setattr(self, attr, temp) | ||
|
|
||
| # CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9 | ||
| if self._send_if_off or self._current_operation != HVAC_MODE_OFF: | ||
| if self._send_if_off or self._current_operation != HVACMode.OFF: | ||
| payload = self._command_templates[cmnd_template](temp) | ||
| await self._publish(cmnd_topic, payload) | ||
|
|
||
|
|
@@ -899,7 +896,7 @@ async def async_set_temperature(self, **kwargs): | |
| async def async_set_swing_mode(self, swing_mode): | ||
| """Set new swing mode.""" | ||
| # CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9 | ||
| if self._send_if_off or self._current_operation != HVAC_MODE_OFF: | ||
| if self._send_if_off or self._current_operation != HVACMode.OFF: | ||
| payload = self._command_templates[CONF_SWING_MODE_COMMAND_TEMPLATE]( | ||
| swing_mode | ||
| ) | ||
|
|
@@ -912,7 +909,7 @@ async def async_set_swing_mode(self, swing_mode): | |
| async def async_set_fan_mode(self, fan_mode): | ||
| """Set new target temperature.""" | ||
| # CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9 | ||
| if self._send_if_off or self._current_operation != HVAC_MODE_OFF: | ||
| if self._send_if_off or self._current_operation != HVACMode.OFF: | ||
| payload = self._command_templates[CONF_FAN_MODE_COMMAND_TEMPLATE](fan_mode) | ||
| await self._publish(CONF_FAN_MODE_COMMAND_TOPIC, payload) | ||
|
|
||
|
|
@@ -922,7 +919,7 @@ async def async_set_fan_mode(self, fan_mode): | |
|
|
||
| async def async_set_hvac_mode(self, hvac_mode) -> None: | ||
| """Set new operation mode.""" | ||
| if hvac_mode == HVAC_MODE_OFF: | ||
| if hvac_mode == HVACMode.OFF: | ||
| await self._publish( | ||
| CONF_POWER_COMMAND_TOPIC, self._config[CONF_PAYLOAD_OFF] | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was a bug...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like it. And the underlying strings are "on"/"off" anyway in both cases, so this change should make no difference.