Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
siemon-geeroms authored Dec 2, 2024
2 parents f66daf9 + 8d14930 commit 10a84f7
Show file tree
Hide file tree
Showing 112 changed files with 1,011 additions and 803 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
wheels-key: ${{ secrets.WHEELS_KEY }}
env-file: true
apk: "libffi-dev;openssl-dev;yaml-dev;nasm;zlib-dev"
skip-binary: aiohttp;multidict;yarl
skip-binary: aiohttp;multidict;propcache;yarl;SQLAlchemy
constraints: "homeassistant/package_constraints.txt"
requirements-diff: "requirements_diff.txt"
requirements: "requirements.txt"
Expand Down
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
},
"problemMatcher": []
},
{
"label": "Pre-commit",
"type": "shell",
"command": "pre-commit run --show-diff-on-failure",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Pylint",
"type": "shell",
Expand Down
44 changes: 44 additions & 0 deletions homeassistant/components/autarco/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

from collections.abc import Mapping
from typing import Any

from autarco import Autarco, AutarcoAuthenticationError, AutarcoConnectionError
Expand All @@ -20,6 +21,12 @@
}
)

STEP_REAUTH_SCHEMA = vol.Schema(
{
vol.Required(CONF_PASSWORD): str,
}
)


class AutarcoConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Autarco."""
Expand Down Expand Up @@ -55,3 +62,40 @@ async def async_step_user(
errors=errors,
data_schema=DATA_SCHEMA,
)

async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle re-authentication request from Autarco."""
return await self.async_step_reauth_confirm()

async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle re-authentication confirmation."""
errors = {}

reauth_entry = self._get_reauth_entry()
if user_input is not None:
client = Autarco(
email=reauth_entry.data[CONF_EMAIL],
password=user_input[CONF_PASSWORD],
session=async_get_clientsession(self.hass),
)
try:
await client.get_account()
except AutarcoAuthenticationError:
errors["base"] = "invalid_auth"
except AutarcoConnectionError:
errors["base"] = "cannot_connect"
else:
return self.async_update_reload_and_abort(
reauth_entry,
data_updates=user_input,
)
return self.async_show_form(
step_id="reauth_confirm",
description_placeholders={"email": reauth_entry.data[CONF_EMAIL]},
data_schema=STEP_REAUTH_SCHEMA,
errors=errors,
)
8 changes: 6 additions & 2 deletions homeassistant/components/autarco/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from autarco import (
AccountSite,
Autarco,
AutarcoAuthenticationError,
AutarcoConnectionError,
Battery,
Inverter,
Expand All @@ -16,6 +17,7 @@

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .const import DOMAIN, LOGGER, SCAN_INTERVAL
Expand Down Expand Up @@ -60,8 +62,10 @@ async def _async_update_data(self) -> AutarcoData:
inverters = await self.client.get_inverters(self.account_site.public_key)
if site.has_battery:
battery = await self.client.get_battery(self.account_site.public_key)
except AutarcoConnectionError as error:
raise UpdateFailed(error) from error
except AutarcoAuthenticationError as err:
raise ConfigEntryAuthFailed(err) from err
except AutarcoConnectionError as err:
raise UpdateFailed(err) from err
return AutarcoData(
solar=solar,
inverters=inverters,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/autarco/quality_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ rules:
This integration only polls data using a coordinator.
Since the integration is read-only and poll-only (only provide sensor
data), there is no need to implement parallel updates.
reauthentication-flow: todo
reauthentication-flow: done
test-coverage: done

# Gold
Expand Down
15 changes: 13 additions & 2 deletions homeassistant/components/autarco/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"config": {
"step": {
"user": {
"description": "Connect to your Autarco account to get information about your solar panels.",
"description": "Connect to your Autarco account, to get information about your sites.",
"data": {
"email": "[%key:common::config_flow::data::email%]",
"password": "[%key:common::config_flow::data::password%]"
Expand All @@ -11,14 +11,25 @@
"email": "The email address of your Autarco account.",
"password": "The password of your Autarco account."
}
},
"reauth_confirm": {
"title": "[%key:common::config_flow::title::reauth%]",
"description": "The password for {email} is no longer valid.",
"data": {
"password": "[%key:common::config_flow::data::password%]"
},
"data_description": {
"password": "[%key:component::autarco::config::step::user::data_description::password%]"
}
}
},
"error": {
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
}
},
"entity": {
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/bmw_connected_drive/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
if TYPE_CHECKING:
from .coordinator import BMWDataUpdateCoordinator

PARALLEL_UPDATES = 1

_LOGGER = logging.getLogger(__name__)


Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/bmw_connected_drive/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
from .coordinator import BMWDataUpdateCoordinator
from .entity import BMWBaseEntity

PARALLEL_UPDATES = 1

DOOR_LOCK_STATE = "door_lock_state"

_LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bmw_connected_drive/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/bmw_connected_drive",
"iot_class": "cloud_polling",
"loggers": ["bimmer_connected"],
"requirements": ["bimmer-connected[china]==0.17.0"]
"requirements": ["bimmer-connected[china]==0.17.2"]
}
2 changes: 2 additions & 0 deletions homeassistant/components/bmw_connected_drive/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from . import DOMAIN, BMWConfigEntry

PARALLEL_UPDATES = 1

ATTR_LOCATION_ATTRIBUTES = ["street", "city", "postal_code", "country"]

POI_SCHEMA = vol.Schema(
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/bmw_connected_drive/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from .coordinator import BMWDataUpdateCoordinator
from .entity import BMWBaseEntity

PARALLEL_UPDATES = 1

_LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/bmw_connected_drive/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .coordinator import BMWDataUpdateCoordinator
from .entity import BMWBaseEntity

PARALLEL_UPDATES = 1

_LOGGER = logging.getLogger(__name__)


Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/bmw_connected_drive/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from .coordinator import BMWDataUpdateCoordinator
from .entity import BMWBaseEntity

PARALLEL_UPDATES = 1

_LOGGER = logging.getLogger(__name__)


Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/cloud/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
},
"services": {
"remote_connect": {
"name": "Remote connect",
"description": "Makes the instance UI accessible from outside of the local network by using Home Assistant Cloud."
"name": "Enable remote access",
"description": "Makes the instance UI accessible from outside of the local network by enabling your Home Assistant Cloud connection."
},
"remote_disconnect": {
"name": "Remote disconnect",
"description": "Disconnects the Home Assistant UI from the Home Assistant Cloud. You will no longer be able to access your Home Assistant instance from outside your local network."
"name": "Disable remote access",
"description": "Disconnects the instance UI from Home Assistant Cloud. This disables access to it from outside your local network."
}
}
}
6 changes: 2 additions & 4 deletions homeassistant/components/conversation/default_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

REGEX_TYPE = type(re.compile(""))
TRIGGER_CALLBACK_TYPE = Callable[
[str, RecognizeResult, str | None], Awaitable[str | None]
[ConversationInput, RecognizeResult], Awaitable[str | None]
]
METADATA_CUSTOM_SENTENCE = "hass_custom_sentence"
METADATA_CUSTOM_FILE = "hass_custom_file"
Expand Down Expand Up @@ -1286,9 +1286,7 @@ async def _handle_trigger_result(

# Gather callback responses in parallel
trigger_callbacks = [
self._trigger_sentences[trigger_id].callback(
user_input.text, trigger_result, user_input.device_id
)
self._trigger_sentences[trigger_id].callback(user_input, trigger_result)
for trigger_id, trigger_result in result.matched_triggers.items()
]

Expand Down
11 changes: 11 additions & 0 deletions homeassistant/components/conversation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ class ConversationInput:
agent_id: str | None = None
"""Agent to use for processing."""

def as_dict(self) -> dict[str, Any]:
"""Return input as a dict."""
return {
"text": self.text,
"context": self.context.as_dict(),
"conversation_id": self.conversation_id,
"device_id": self.device_id,
"language": self.language,
"agent_id": self.agent_id,
}


@dataclass(slots=True)
class ConversationResult:
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/conversation/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from homeassistant.helpers.typing import UNDEFINED, ConfigType

from .const import DATA_DEFAULT_ENTITY, DOMAIN
from .models import ConversationInput


def has_no_punctuation(value: list[str]) -> list[str]:
Expand Down Expand Up @@ -62,7 +63,7 @@ async def async_attach_trigger(
job = HassJob(action)

async def call_action(
sentence: str, result: RecognizeResult, device_id: str | None
user_input: ConversationInput, result: RecognizeResult
) -> str | None:
"""Call action with right context."""

Expand All @@ -83,12 +84,13 @@ async def call_action(
trigger_input: dict[str, Any] = { # Satisfy type checker
**trigger_data,
"platform": DOMAIN,
"sentence": sentence,
"sentence": user_input.text,
"details": details,
"slots": { # direct access to values
entity_name: entity["value"] for entity_name, entity in details.items()
},
"device_id": device_id,
"device_id": user_input.device_id,
"user_input": user_input.as_dict(),
}

# Wait for the automation to complete
Expand Down
24 changes: 12 additions & 12 deletions homeassistant/components/fan/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@
"services": {
"set_preset_mode": {
"name": "Set preset mode",
"description": "Sets preset mode.",
"description": "Sets preset fan mode.",
"fields": {
"preset_mode": {
"name": "Preset mode",
"description": "Preset mode."
"description": "Preset fan mode."
}
}
},
"set_percentage": {
"name": "Set speed",
"description": "Sets the fan speed.",
"description": "Sets the speed of a fan.",
"fields": {
"percentage": {
"name": "Percentage",
Expand Down Expand Up @@ -94,45 +94,45 @@
},
"oscillate": {
"name": "Oscillate",
"description": "Controls oscillatation of the fan.",
"description": "Controls the oscillation of a fan.",
"fields": {
"oscillating": {
"name": "Oscillating",
"description": "Turn on/off oscillation."
"description": "Turns oscillation on/off."
}
}
},
"toggle": {
"name": "[%key:common::action::toggle%]",
"description": "Toggles the fan on/off."
"description": "Toggles a fan on/off."
},
"set_direction": {
"name": "Set direction",
"description": "Sets the fan rotation direction.",
"description": "Sets a fan's rotation direction.",
"fields": {
"direction": {
"name": "Direction",
"description": "Direction to rotate."
"description": "Direction of the fan rotation."
}
}
},
"increase_speed": {
"name": "Increase speed",
"description": "Increases the speed of the fan.",
"description": "Increases the speed of a fan.",
"fields": {
"percentage_step": {
"name": "Increment",
"description": "Increases the speed by a percentage step."
"description": "Percentage step by which the speed should be increased."
}
}
},
"decrease_speed": {
"name": "Decrease speed",
"description": "Decreases the speed of the fan.",
"description": "Decreases the speed of a fan.",
"fields": {
"percentage_step": {
"name": "Decrement",
"description": "Decreases the speed by a percentage step."
"description": "Percentage step by which the speed should be decreased."
}
}
}
Expand Down
Loading

0 comments on commit 10a84f7

Please sign in to comment.