-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'home-assistant:dev' into lektrico2
- Loading branch information
Showing
37 changed files
with
1,039 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Creates a select entity for the headlight of the mower.""" | ||
|
||
import logging | ||
|
||
from aioautomower.exceptions import ApiException | ||
from aioautomower.model import HeadlightModes | ||
|
||
from homeassistant.components.select import SelectEntity | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import EntityCategory | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.exceptions import HomeAssistantError | ||
from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
|
||
from .const import DOMAIN | ||
from .coordinator import AutomowerDataUpdateCoordinator | ||
from .entity import AutomowerControlEntity | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
HEADLIGHT_MODES: list = [ | ||
HeadlightModes.ALWAYS_OFF.lower(), | ||
HeadlightModes.ALWAYS_ON.lower(), | ||
HeadlightModes.EVENING_AND_NIGHT.lower(), | ||
HeadlightModes.EVENING_ONLY.lower(), | ||
] | ||
|
||
|
||
async def async_setup_entry( | ||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback | ||
) -> None: | ||
"""Set up select platform.""" | ||
coordinator: AutomowerDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] | ||
async_add_entities( | ||
AutomowerSelectEntity(mower_id, coordinator) | ||
for mower_id in coordinator.data | ||
if coordinator.data[mower_id].capabilities.headlights | ||
) | ||
|
||
|
||
class AutomowerSelectEntity(AutomowerControlEntity, SelectEntity): | ||
"""Defining the headlight mode entity.""" | ||
|
||
_attr_options = HEADLIGHT_MODES | ||
_attr_entity_category = EntityCategory.CONFIG | ||
_attr_translation_key = "headlight_mode" | ||
|
||
def __init__( | ||
self, | ||
mower_id: str, | ||
coordinator: AutomowerDataUpdateCoordinator, | ||
) -> None: | ||
"""Set up select platform.""" | ||
super().__init__(mower_id, coordinator) | ||
self._attr_unique_id = f"{mower_id}_headlight_mode" | ||
|
||
@property | ||
def current_option(self) -> str: | ||
"""Return the current option for the entity.""" | ||
return self.mower_attributes.headlight.mode.lower() | ||
|
||
async def async_select_option(self, option: str) -> None: | ||
"""Change the selected option.""" | ||
try: | ||
await self.coordinator.api.set_headlight_mode(self.mower_id, option.upper()) | ||
except ApiException as exception: | ||
raise HomeAssistantError( | ||
f"Command couldn't be sent to the command queue: {exception}" | ||
) from exception |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"issues": { | ||
"deprecated_yaml": { | ||
"title": "The {integration_title} YAML configuration is being removed", | ||
"description": "Configuring {integration_title} using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically as a regular dashboard.\n\nRemove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue." | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.