-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add melcloud AtaDevice vane control #32672
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
Changes from all commits
5967abb
1c95165
8435ffd
269e4e8
ac98ebe
8bd50ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| PROPERTY_ZONE_2_OPERATION_MODE, | ||
| Zone, | ||
| ) | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.climate import ClimateDevice | ||
| from homeassistant.components.climate.const import ( | ||
|
|
@@ -27,11 +28,23 @@ | |
| ) | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.const import TEMP_CELSIUS | ||
| from homeassistant.helpers import config_validation as cv, entity_platform | ||
| from homeassistant.helpers.typing import HomeAssistantType | ||
| from homeassistant.util.temperature import convert as convert_temperature | ||
|
|
||
| from . import MelCloudDevice | ||
| from .const import ATTR_STATUS, DOMAIN, TEMP_UNIT_LOOKUP | ||
| from .const import ( | ||
| ATTR_STATUS, | ||
| ATTR_VANE_HORIZONTAL, | ||
| ATTR_VANE_HORIZONTAL_POSITIONS, | ||
| ATTR_VANE_VERTICAL, | ||
| ATTR_VANE_VERTICAL_POSITIONS, | ||
| CONF_POSITION, | ||
| DOMAIN, | ||
| SERVICE_SET_VANE_HORIZONTAL, | ||
| SERVICE_SET_VANE_VERTICAL, | ||
| TEMP_UNIT_LOOKUP, | ||
| ) | ||
|
|
||
| SCAN_INTERVAL = timedelta(seconds=60) | ||
|
|
||
|
|
@@ -73,6 +86,18 @@ async def async_setup_entry( | |
| True, | ||
| ) | ||
|
|
||
| platform = entity_platform.current_platform.get() | ||
| platform.async_register_entity_service( | ||
| SERVICE_SET_VANE_HORIZONTAL, | ||
| {vol.Required(CONF_POSITION): cv.string}, | ||
| "async_set_vane_horizontal", | ||
| ) | ||
| platform.async_register_entity_service( | ||
| SERVICE_SET_VANE_VERTICAL, | ||
| {vol.Required(CONF_POSITION): cv.string}, | ||
| "async_set_vane_vertical", | ||
| ) | ||
|
|
||
|
|
||
| class MelCloudClimate(ClimateDevice): | ||
| """Base climate device.""" | ||
|
|
@@ -116,6 +141,30 @@ def name(self): | |
| """Return the display name of this entity.""" | ||
| return self._name | ||
|
|
||
| @property | ||
| def device_state_attributes(self) -> Optional[Dict[str, Any]]: | ||
| """Return the optional state attributes with device specific additions.""" | ||
| attr = {} | ||
|
|
||
| vane_horizontal = self._device.vane_horizontal | ||
| if vane_horizontal: | ||
| attr.update( | ||
| { | ||
| ATTR_VANE_HORIZONTAL: vane_horizontal, | ||
| ATTR_VANE_HORIZONTAL_POSITIONS: self._device.vane_horizontal_positions, | ||
| } | ||
| ) | ||
|
|
||
| vane_vertical = self._device.vane_vertical | ||
| if vane_horizontal: | ||
|
Member
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. Is the vertical vane dependent on the horizontal vane?
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. Aww.. That requires another PR to fix.
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. There you go: #33580 |
||
| attr.update( | ||
| { | ||
| ATTR_VANE_VERTICAL: vane_vertical, | ||
| ATTR_VANE_VERTICAL_POSITIONS: self._device.vane_vertical_positions, | ||
| } | ||
| ) | ||
| return attr | ||
|
|
||
| @property | ||
| def temperature_unit(self) -> str: | ||
| """Return the unit of measurement used by the platform.""" | ||
|
|
@@ -181,6 +230,22 @@ def fan_modes(self) -> Optional[List[str]]: | |
| """Return the list of available fan modes.""" | ||
| return self._device.fan_speeds | ||
|
|
||
| async def async_set_vane_horizontal(self, position: str) -> None: | ||
| """Set horizontal vane position.""" | ||
| if position not in self._device.vane_horizontal_positions: | ||
| raise ValueError( | ||
| f"Invalid horizontal vane position {position}. Valid positions: [{self._device.vane_horizontal_positions}]." | ||
| ) | ||
| await self._device.set({ata.PROPERTY_VANE_HORIZONTAL: position}) | ||
|
|
||
| async def async_set_vane_vertical(self, position: str) -> None: | ||
| """Set vertical vane position.""" | ||
| if position not in self._device.vane_vertical_positions: | ||
| raise ValueError( | ||
| f"Invalid vertical vane position {position}. Valid positions: [{self._device.vane_vertical_positions}]." | ||
| ) | ||
| await self._device.set({ata.PROPERTY_VANE_VERTICAL: position}) | ||
|
|
||
| @property | ||
| def supported_features(self) -> int: | ||
| """Return the list of supported features.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| set_vane_horizontal: | ||
| description: Sets horizontal vane position. | ||
| fields: | ||
| entity_id: | ||
| description: Name of the target entity | ||
| example: "climate.ac_1" | ||
| position: | ||
| description: > | ||
| Horizontal vane position. Possible options can be found in the | ||
| vane_horizontal_positions state attribute. | ||
| example: "auto" | ||
|
|
||
| set_vane_vertical: | ||
| description: Sets vertical vane position. | ||
| fields: | ||
| entity_id: | ||
| description: Name of the target entity | ||
| example: "climate.ac_1" | ||
| position: | ||
| description: > | ||
| Vertical vane position. Possible options can be found in the | ||
| vane_vertical_positions state attribute. | ||
| example: "auto" |
Uh oh!
There was an error while loading. Please reload this page.