Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion homeassistant/components/conversation/chat_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ async def async_update_llm_data(
llm_context = llm.LLMContext(
platform=conversing_domain,
context=user_input.context,
user_prompt=user_input.text,
language=user_input.language,
assistant=DOMAIN,
device_id=user_input.device_id,
Expand Down
145 changes: 72 additions & 73 deletions homeassistant/components/google_photos/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,86 +78,85 @@ def _read_file_contents(
return results


@callback
def async_setup_services(hass: HomeAssistant) -> None:
"""Register Google Photos services."""

async def async_handle_upload(call: ServiceCall) -> ServiceResponse:
"""Generate content from text and optionally images."""
config_entry: GooglePhotosConfigEntry | None = (
hass.config_entries.async_get_entry(call.data[CONF_CONFIG_ENTRY_ID])
async def _async_handle_upload(call: ServiceCall) -> ServiceResponse:
"""Generate content from text and optionally images."""
config_entry: GooglePhotosConfigEntry | None = (
call.hass.config_entries.async_get_entry(call.data[CONF_CONFIG_ENTRY_ID])
)
if not config_entry:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="integration_not_found",
translation_placeholders={"target": DOMAIN},
)
if not config_entry:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="integration_not_found",
translation_placeholders={"target": DOMAIN},
)
scopes = config_entry.data["token"]["scope"].split(" ")
if UPLOAD_SCOPE not in scopes:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="missing_upload_permission",
translation_placeholders={"target": DOMAIN},
)
coordinator = config_entry.runtime_data
client_api = coordinator.client
upload_tasks = []
file_results = await hass.async_add_executor_job(
_read_file_contents, hass, call.data[CONF_FILENAME]
scopes = config_entry.data["token"]["scope"].split(" ")
if UPLOAD_SCOPE not in scopes:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="missing_upload_permission",
translation_placeholders={"target": DOMAIN},
)
coordinator = config_entry.runtime_data
client_api = coordinator.client
upload_tasks = []
file_results = await call.hass.async_add_executor_job(
_read_file_contents, call.hass, call.data[CONF_FILENAME]
)

album = call.data[CONF_ALBUM]
try:
album_id = await coordinator.get_or_create_album(album)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="create_album_error",
translation_placeholders={"message": str(err)},
) from err

for mime_type, content in file_results:
upload_tasks.append(client_api.upload_content(content, mime_type))
try:
upload_results = await asyncio.gather(*upload_tasks)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="upload_error",
translation_placeholders={"message": str(err)},
) from err
try:
upload_result = await client_api.create_media_items(
[
NewMediaItem(
SimpleMediaItem(upload_token=upload_result.upload_token)
)
for upload_result in upload_results
],
album_id=album_id,
)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="api_error",
translation_placeholders={"message": str(err)},
) from err
if call.return_response:
return {
"media_items": [
{"media_item_id": item_result.media_item.id}
for item_result in upload_result.new_media_item_results
if item_result.media_item and item_result.media_item.id
],
"album_id": album_id,
}
return None
album = call.data[CONF_ALBUM]
try:
album_id = await coordinator.get_or_create_album(album)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="create_album_error",
translation_placeholders={"message": str(err)},
) from err

for mime_type, content in file_results:
upload_tasks.append(client_api.upload_content(content, mime_type))
try:
upload_results = await asyncio.gather(*upload_tasks)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="upload_error",
translation_placeholders={"message": str(err)},
) from err
try:
upload_result = await client_api.create_media_items(
[
NewMediaItem(SimpleMediaItem(upload_token=upload_result.upload_token))
for upload_result in upload_results
],
album_id=album_id,
)
except GooglePhotosApiError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="api_error",
translation_placeholders={"message": str(err)},
) from err
if call.return_response:
return {
"media_items": [
{"media_item_id": item_result.media_item.id}
for item_result in upload_result.new_media_item_results
if item_result.media_item and item_result.media_item.id
],
"album_id": album_id,
}
return None


@callback
def async_setup_services(hass: HomeAssistant) -> None:
"""Register Google Photos services."""

hass.services.async_register(
DOMAIN,
UPLOAD_SERVICE,
async_handle_upload,
_async_handle_upload,
schema=UPLOAD_SERVICE_SCHEMA,
supports_response=SupportsResponse.OPTIONAL,
)
1 change: 0 additions & 1 deletion homeassistant/components/mcp_server/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ async def get(self, request: web.Request) -> web.StreamResponse:
context = llm.LLMContext(
platform=DOMAIN,
context=self.context(request),
user_prompt=None,
language="*",
assistant=conversation.DOMAIN,
device_id=None,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nextbus/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/nextbus",
"iot_class": "cloud_polling",
"loggers": ["py_nextbus"],
"requirements": ["py-nextbusnext==2.2.0"]
"requirements": ["py-nextbusnext==2.3.0"]
}
3 changes: 3 additions & 0 deletions homeassistant/components/reolink/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
"ai_animal_sensitivity": {
"default": "mdi:paw"
},
"cry_sensitivity": {
"default": "mdi:emoticon-cry-outline"
},
"crossline_sensitivity": {
"default": "mdi:fence"
},
Expand Down
12 changes: 12 additions & 0 deletions homeassistant/components/reolink/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ class ReolinkChimeNumberEntityDescription(
value=lambda api, ch: api.ai_sensitivity(ch, "dog_cat"),
method=lambda api, ch, value: api.set_ai_sensitivity(ch, int(value), "dog_cat"),
),
ReolinkNumberEntityDescription(
key="cry_sensitivity",
cmd_key="299",
translation_key="cry_sensitivity",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=1,
native_max_value=5,
supported=lambda api, ch: api.supported(ch, "ai_cry"),
value=lambda api, ch: api.baichuan.cry_sensitivity(ch),
method=lambda api, ch, value: api.baichuan.set_cry_detection(ch, int(value)),
),
ReolinkNumberEntityDescription(
key="ai_face_delay",
cmd_key="GetAiAlarm",
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/reolink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@
"ai_animal_sensitivity": {
"name": "AI animal sensitivity"
},
"cry_sensitivity": {
"name": "Baby cry sensitivity"
},
"crossline_sensitivity": {
"name": "AI crossline {zone_name} sensitivity"
},
Expand Down
12 changes: 10 additions & 2 deletions homeassistant/helpers/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,19 @@ class LLMContext:
"""Tool input to be processed."""

platform: str
"""Integration that is handling the LLM request."""

context: Context | None
user_prompt: str | None
"""Context of the LLM request."""

language: str | None
"""Language of the LLM request."""

assistant: str | None
"""Assistant domain that is handling the LLM request."""

device_id: str | None
"""Device that is making the request."""


@dataclass(slots=True)
Expand Down Expand Up @@ -302,7 +310,7 @@ async def async_call(
platform=llm_context.platform,
intent_type=self.name,
slots=slots,
text_input=llm_context.user_prompt,
text_input=None,
context=llm_context.context,
language=llm_context.language,
assistant=llm_context.assistant,
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def run(args: list[str]) -> int:

config_dir = extract_config_dir()

loop = asyncio.get_event_loop()

if not is_virtual_env():
loop.run_until_complete(async_mount_local_lib_path(config_dir))
asyncio.run(async_mount_local_lib_path(config_dir))

_pip_kwargs = pip_kwargs(config_dir)

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions tests/components/anthropic/test_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ def completion_result(*args, messages, **kwargs):
llm.LLMContext(
platform="anthropic",
context=context,
user_prompt="Please call the test function",
language="en",
assistant="conversation",
device_id=None,
Expand Down Expand Up @@ -510,7 +509,6 @@ def completion_result(*args, messages, **kwargs):
llm.LLMContext(
platform="anthropic",
context=context,
user_prompt="Please call the test function",
language="en",
assistant="conversation",
device_id=None,
Expand Down
1 change: 0 additions & 1 deletion tests/components/mcp/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def create_llm_context() -> llm.LLMContext:
return llm.LLMContext(
platform="test_platform",
context=Context(),
user_prompt="test_text",
language="*",
assistant="conversation",
device_id=None,
Expand Down
2 changes: 0 additions & 2 deletions tests/components/ollama/test_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def completion_result(*args, messages, **kwargs):
llm.LLMContext(
platform="ollama",
context=context,
user_prompt="Please call the test function",
language="en",
assistant="conversation",
device_id=None,
Expand Down Expand Up @@ -369,7 +368,6 @@ def completion_result(*args, messages, **kwargs):
llm.LLMContext(
platform="ollama",
context=context,
user_prompt="Please call the test function",
language="en",
assistant="conversation",
device_id=None,
Expand Down
4 changes: 4 additions & 0 deletions tests/components/reolink/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
'0': 1,
'null': 1,
}),
'299': dict({
'0': 1,
'null': 1,
}),
'DingDongOpt': dict({
'0': 2,
'null': 2,
Expand Down
Loading
Loading