Compare commits

..

2 Commits

Author SHA1 Message Date
Manu
8c0f3014f7 Fix secure URLs for promotional game media in Xbox integration (#158162) 2025-12-07 11:34:18 +01:00
Josef Zweck
bb3cd3ebd3 Bump pylamarzocco to 2.2.3 (#158104) 2025-12-07 08:57:02 +01:00
8 changed files with 36 additions and 60 deletions

View File

@@ -37,5 +37,5 @@
"iot_class": "cloud_push",
"loggers": ["pylamarzocco"],
"quality_scale": "platinum",
"requirements": ["pylamarzocco==2.2.2"]
"requirements": ["pylamarzocco==2.2.3"]
}

View File

@@ -246,8 +246,6 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
device_name: str = ""
wifi_networks: list[dict[str, Any]] = []
selected_ssid: str = ""
ble_scan_error: str = ""
provision_error: str = ""
_provision_task: asyncio.Task | None = None
_provision_result: ConfigFlowResult | None = None
disable_ap_after_provision: bool = True
@@ -744,12 +742,11 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
try:
self.wifi_networks = await async_scan_wifi_networks(self.ble_device)
except (DeviceConnectionError, RpcCallError) as err:
LOGGER.debug("Failed to scan WiFi networks via BLE: %r", err)
LOGGER.debug("Failed to scan WiFi networks via BLE: %s", err)
# "Writing is not permitted" error means device rejects BLE writes
# and BLE provisioning is disabled - user must use Shelly app
if "not permitted" in str(err):
return self.async_abort(reason="ble_not_permitted")
self.ble_scan_error = repr(err)
return await self.async_step_wifi_scan_failed()
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception during WiFi scan")
@@ -794,13 +791,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
# User wants to retry - go back to wifi_scan
return await self.async_step_wifi_scan()
return self.async_show_form(
step_id="wifi_scan_failed",
description_placeholders={
"name": self.context["title_placeholders"]["name"],
"error": self.ble_scan_error,
},
)
return self.async_show_form(step_id="wifi_scan_failed")
@asynccontextmanager
async def _async_provision_context(
@@ -885,9 +876,8 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
try:
await async_provision_wifi(self.ble_device, self.selected_ssid, password)
except (DeviceConnectionError, RpcCallError) as err:
LOGGER.debug("Failed to provision WiFi via BLE: %r", err)
LOGGER.debug("Failed to provision WiFi via BLE: %s", err)
# BLE connection/communication failed - allow retry from network selection
self.provision_error = repr(err)
return None
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception during WiFi provisioning")
@@ -935,7 +925,6 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
else:
LOGGER.debug("BLE fallback also failed - provisioning unsuccessful")
# Store failure info and return None - provision_done will handle redirect
self.provision_error = "Device not found after provisioning"
return None
else:
state.host, state.port = result
@@ -1046,11 +1035,7 @@ class ShellyConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_show_form(
step_id="provision_failed",
description_placeholders={
"name": self.context["title_placeholders"]["name"],
"ssid": self.selected_ssid,
"error": self.provision_error,
},
description_placeholders={"ssid": self.selected_ssid},
)
async def async_step_provision_done(

View File

@@ -57,7 +57,7 @@
}
},
"provision_failed": {
"description": "{name} did not connect to {ssid}: {error}. This may be due to an incorrect password or the network being out of range. Would you like to try again?"
"description": "The device did not connect to {ssid}. This may be due to an incorrect password or the network being out of range. Would you like to try again?"
},
"reauth_confirm": {
"data": {
@@ -112,7 +112,7 @@
"description": "Select a WiFi network and enter the password to provision the device."
},
"wifi_scan_failed": {
"description": "Failed to scan for WiFi networks on {name} via Bluetooth: {error}. The device may be out of range or Bluetooth connection failed. Would you like to try again?"
"description": "Failed to scan for WiFi networks via Bluetooth. The device may be out of range or Bluetooth connection failed. Would you like to try again?"
}
}
},

View File

@@ -630,7 +630,7 @@ class XboxSource(MediaSource):
title=image.type,
can_play=True,
can_expand=False,
thumbnail=image.url,
thumbnail=to_https(image.url),
)
for image in game.images
]

2
requirements_all.txt generated
View File

@@ -2154,7 +2154,7 @@ pykwb==0.0.8
pylacrosse==0.4
# homeassistant.components.lamarzocco
pylamarzocco==2.2.2
pylamarzocco==2.2.3
# homeassistant.components.lastfm
pylast==5.1.0

View File

@@ -1813,7 +1813,7 @@ pykrakenapi==0.1.8
pykulersky==0.5.8
# homeassistant.components.lamarzocco
pylamarzocco==2.2.2
pylamarzocco==2.2.3
# homeassistant.components.lastfm
pylast==5.1.0

View File

@@ -3654,7 +3654,7 @@ async def test_bluetooth_wifi_scan_failure(
# Confirm and trigger wifi scan that fails
with patch(
"homeassistant.components.shelly.config_flow.async_scan_wifi_networks",
side_effect=DeviceConnectionError("Connection timed out"),
side_effect=DeviceConnectionError,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@@ -3663,10 +3663,6 @@ async def test_bluetooth_wifi_scan_failure(
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "wifi_scan_failed"
assert result["description_placeholders"] == {
"name": "ShellyPlus2PM-C049EF8873E8",
"error": "DeviceConnectionError('Connection timed out')",
}
# Test retry and complete flow
with patch(
@@ -3859,7 +3855,7 @@ async def test_bluetooth_wifi_provision_failure(
with (
patch(
"homeassistant.components.shelly.config_flow.async_provision_wifi",
side_effect=DeviceConnectionError("BLE connection lost"),
side_effect=DeviceConnectionError,
),
patch(
"homeassistant.components.shelly.config_flow.async_lookup_device_by_name",
@@ -3880,11 +3876,6 @@ async def test_bluetooth_wifi_provision_failure(
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "provision_failed"
assert result["description_placeholders"] == {
"name": "ShellyPlus2PM-C049EF8873E8",
"ssid": "MyNetwork",
"error": "DeviceConnectionError('BLE connection lost')",
}
# Test retry - go back to wifi scan and complete successfully
with patch(

View File

@@ -259,7 +259,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/0',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.35725.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c4bf34f8-ad40-4af3-914e-a85e75a76bed',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.35725.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c4bf34f8-ad40-4af3-914e-a85e75a76bed',
'title': 'Screenshot',
}),
dict({
@@ -270,7 +270,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/1',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.64736.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6491fb2f-52e7-4129-bcbd-d23a67117ae0',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.64736.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6491fb2f-52e7-4129-bcbd-d23a67117ae0',
'title': 'BrandedKeyArt',
}),
dict({
@@ -281,7 +281,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/2',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e',
'title': 'TitledHeroArt',
}),
dict({
@@ -292,7 +292,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/3',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.22570.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.bf29284d-808a-4e4a-beaa-6621c9898d0e',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.22570.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.bf29284d-808a-4e4a-beaa-6621c9898d0e',
'title': 'Poster',
}),
dict({
@@ -303,7 +303,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/4',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e',
'title': 'SuperHeroArt',
}),
dict({
@@ -314,7 +314,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/5',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261',
'title': 'BoxArt',
}),
dict({
@@ -325,7 +325,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/6',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.35072.13670972585585116.70570f0d-17aa-4f97-b692-5412fa183673.25a97451-9369-4f6b-b66b-3427913235eb',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.35072.13670972585585116.70570f0d-17aa-4f97-b692-5412fa183673.25a97451-9369-4f6b-b66b-3427913235eb',
'title': 'Logo',
}),
dict({
@@ -336,7 +336,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/7',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261',
'title': 'FeaturePromotionalSquareArt',
}),
dict({
@@ -347,7 +347,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/8',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.38628.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c2a205af-5146-405b-b2b7-56845351f1f3',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.38628.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c2a205af-5146-405b-b2b7-56845351f1f3',
'title': 'Screenshot',
}),
dict({
@@ -358,7 +358,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/9',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.22150.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b147895c-e947-424d-a731-faefc8c9906a',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.22150.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b147895c-e947-424d-a731-faefc8c9906a',
'title': 'Screenshot',
}),
dict({
@@ -369,7 +369,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/10',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.37559.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.479d2dc1-db2d-4ffa-8c54-a2bebb093ec6',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.37559.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.479d2dc1-db2d-4ffa-8c54-a2bebb093ec6',
'title': 'Screenshot',
}),
dict({
@@ -380,7 +380,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/11',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.32737.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6a16ae3e-2918-46e9-90d9-232c79cb9d9d',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.32737.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6a16ae3e-2918-46e9-90d9-232c79cb9d9d',
'title': 'Screenshot',
}),
dict({
@@ -391,7 +391,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/12',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.57046.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.0c0dd072-aa27-4e83-9010-474dfbb42277',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.57046.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.0c0dd072-aa27-4e83-9010-474dfbb42277',
'title': 'Screenshot',
}),
dict({
@@ -402,7 +402,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/13',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.19315.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6293a7b7-07ca-4df0-9eea-6018285a0a8d',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.19315.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6293a7b7-07ca-4df0-9eea-6018285a0a8d',
'title': 'Screenshot',
}),
dict({
@@ -413,7 +413,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/14',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.23374.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.66498a73-52f5-4247-a1e2-d3c84b9b315d',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.23374.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.66498a73-52f5-4247-a1e2-d3c84b9b315d',
'title': 'Screenshot',
}),
dict({
@@ -424,7 +424,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/15',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.64646.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.83182b76-4294-496d-90a7-f4e31e7aa80a',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.64646.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.83182b76-4294-496d-90a7-f4e31e7aa80a',
'title': 'Screenshot',
}),
dict({
@@ -435,7 +435,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/16',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.24470.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.72d2abc3-aa69-4aeb-960b-6f6d25f498e4',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.24470.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.72d2abc3-aa69-4aeb-960b-6f6d25f498e4',
'title': 'Screenshot',
}),
dict({
@@ -446,7 +446,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/17',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.15604.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.27cee011-660b-49a4-bd33-38db6fff5226',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.15604.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.27cee011-660b-49a4-bd33-38db6fff5226',
'title': 'Screenshot',
}),
dict({
@@ -457,7 +457,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/18',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.39987.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.be285efe-78f8-4984-9d28-9159881bacd4',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.39987.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.be285efe-78f8-4984-9d28-9159881bacd4',
'title': 'Screenshot',
}),
dict({
@@ -468,7 +468,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/19',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.38206.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.2409803d-7378-4a69-a10b-1574ac42b98b',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.38206.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.2409803d-7378-4a69-a10b-1574ac42b98b',
'title': 'Screenshot',
}),
dict({
@@ -479,7 +479,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/20',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.14938.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ef6ee72c-4beb-45ec-bd10-6235bd6a7c7f',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.14938.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ef6ee72c-4beb-45ec-bd10-6235bd6a7c7f',
'title': 'Screenshot',
}),
dict({
@@ -490,7 +490,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/21',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.12835.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6165ee24-df01-44f5-80fe-7411f9366d1c',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.12835.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6165ee24-df01-44f5-80fe-7411f9366d1c',
'title': 'Screenshot',
}),
dict({
@@ -501,7 +501,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/22',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.40786.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b7607a0d-0101-4864-9bf8-ad889f820489',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.40786.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b7607a0d-0101-4864-9bf8-ad889f820489',
'title': 'Screenshot',
}),
dict({
@@ -512,7 +512,7 @@
'media_class': <MediaClass.VIDEO: 'video'>,
'media_content_id': 'media-source://xbox/271958441785640/1297287135/game_media/23',
'media_content_type': <MediaClass.VIDEO: 'video'>,
'thumbnail': 'http://store-images.s-microsoft.com/image/apps.55686.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ecbb0e91-36a9-4f76-ab1e-5a5de009840e',
'thumbnail': 'https://store-images.s-microsoft.com/image/apps.55686.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ecbb0e91-36a9-4f76-ab1e-5a5de009840e',
'title': 'Screenshot',
}),
]),