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
8 changes: 6 additions & 2 deletions homeassistant/components/imou/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .const import PTZ_MOVE_DURATION_MS, imou_device_identifier
from .const import DOMAIN, PTZ_MOVE_DURATION_MS, imou_device_identifier
from .coordinator import ImouConfigEntry, ImouDataUpdateCoordinator
from .entity import ImouEntity

Expand Down Expand Up @@ -110,4 +110,8 @@ async def async_press(self) -> None:
duration,
)
except ImouException as e:
raise HomeAssistantError(str(e)) from e
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="press_button_failed",
translation_placeholders={"error": e.message},
) from e
14 changes: 11 additions & 3 deletions homeassistant/components/imou/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .const import PARAM_HEADER_DETECT, imou_device_identifier
from .const import DOMAIN, PARAM_HEADER_DETECT, imou_device_identifier
from .coordinator import ImouConfigEntry, ImouDataUpdateCoordinator
from .entity import ImouEntity

Expand Down Expand Up @@ -98,7 +98,11 @@ async def stream_source(self) -> str | None:
PYIMOUAPI_LIVE_PROTOCOL,
)
except ImouException as err:
raise HomeAssistantError(str(err)) from err
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="get_stream_failed",
translation_placeholders={"error": err.message},
) from err

@override
async def async_camera_image(
Expand All @@ -111,7 +115,11 @@ async def async_camera_image(
PYIMOUAPI_SNAPSHOT_WAIT_SECONDS,
)
except ImouException as err:
raise HomeAssistantError(str(err)) from err
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="get_image_failed",
translation_placeholders={"error": err.message},
) from err

@property
@override
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/imou/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ async def async_select_option(self, option: str) -> None:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="select_option_failed",
translation_placeholders={"error": e.message},
) from e
await self.coordinator.async_request_refresh()
14 changes: 13 additions & 1 deletion homeassistant/components/imou/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,20 @@
}
},
"exceptions": {
"get_image_failed": {
"message": "Could not get a snapshot from Imou: {error}"
},
"get_stream_failed": {
"message": "Could not get the live stream URL from Imou: {error}"
},
"press_button_failed": {
"message": "Imou rejected the button press: {error}"
},
"select_option_failed": {
"message": "Error communicating with the Imou API"
"message": "Imou rejected the new option: {error}"
},
"switch_operation_failed": {
"message": "Imou rejected the switch change: {error}"
}
},
"selector": {
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/imou/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .const import (
DOMAIN,
PARAM_AB_ALARM_SOUND,
PARAM_AUDIO_ENCODE_CONTROL,
PARAM_CLOSE_CAMERA,
Expand Down Expand Up @@ -131,5 +132,9 @@ async def _async_switch_operation(self, enable: bool) -> None:
enable,
)
except ImouException as e:
raise HomeAssistantError(str(e)) from e
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="switch_operation_failed",
translation_placeholders={"error": e.message},
) from e
await self.coordinator.async_request_refresh()
2 changes: 1 addition & 1 deletion homeassistant/components/lyngdorf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"iot_class": "local_push",
"loggers": ["lyngdorf", "async_upnp_client"],
"quality_scale": "silver",
"requirements": ["lyngdorf==1.4.8"],
"requirements": ["lyngdorf==1.4.9"],
"ssdp": [
{
"deviceType": "urn:schemas-upnp-org:device:MediaRenderer:2",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/plugwise/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"loggers": ["plugwise"],
"quality_scale": "platinum",
"requirements": ["plugwise==1.14.5"],
"requirements": ["plugwise==1.14.6"],
"zeroconf": ["_plugwise._tcp.local."]
}
10 changes: 5 additions & 5 deletions homeassistant/components/switchbot_cloud/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ class SwitchbotCloudDeviceConfig:
True, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR)
),
"Curtain": SwitchbotCloudDeviceConfig(
False, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
True, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
),
"Curtain3": SwitchbotCloudDeviceConfig(
False, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
True, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
),
"Roller Shade": SwitchbotCloudDeviceConfig(
False, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
True, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
),
"Blind Tilt": SwitchbotCloudDeviceConfig(
False, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
True, entity_config=(Platform.SENSOR, Platform.BINARY_SENSOR, Platform.COVER)
),
"Garage Door Opener": SwitchbotCloudDeviceConfig(
False, entity_config=(Platform.BINARY_SENSOR, Platform.COVER)
True, entity_config=(Platform.BINARY_SENSOR, Platform.COVER)
),
}
4 changes: 2 additions & 2 deletions requirements_all.txt

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

4 changes: 2 additions & 2 deletions tests/components/august/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ async def test_device_remove_devices(

device_entry = device_registry.async_get(entity.device_id)
client = await hass_ws_client(hass)
response = await client.remove_device(device_entry.id, config_entry.entry_id)
response = await client.remove_device(device_entry.id)
assert not response["success"]

dead_device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "remove-device-id")},
)
response = await client.remove_device(dead_device_entry.id, config_entry.entry_id)
response = await client.remove_device(dead_device_entry.id)
assert response["success"]


Expand Down
8 changes: 4 additions & 4 deletions tests/components/bond/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,28 +360,28 @@ async def test_device_remove_devices(

device_entry = device_registry.async_get(entity.device_id)
client = await hass_ws_client(hass)
response = await client.remove_device(device_entry.id, config_entry.entry_id)
response = await client.remove_device(device_entry.id)
assert not response["success"]

dead_device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "test-hub-id", "remove-device-id")},
)
response = await client.remove_device(dead_device_entry.id, config_entry.entry_id)
response = await client.remove_device(dead_device_entry.id)
assert response["success"]

dead_device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "wrong-hub-id", "test-device-id")},
)
response = await client.remove_device(dead_device_entry.id, config_entry.entry_id)
response = await client.remove_device(dead_device_entry.id)
assert response["success"]

hub_device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "test-hub-id")},
)
response = await client.remove_device(hub_device_entry.id, config_entry.entry_id)
response = await client.remove_device(hub_device_entry.id)
assert not response["success"]


Expand Down
3 changes: 1 addition & 2 deletions tests/components/cast/test_media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ async def test_device_registry(
chromecast, _ = await async_setup_media_player_cast(hass, info)
chromecast.cast_type = pychromecast.const.CAST_TYPE_CHROMECAST
_, conn_status_cb, _ = get_status_callbacks(chromecast)
cast_entry = hass.config_entries.async_entries("cast")[0]

connection_status = MagicMock()
connection_status.status = "CONNECTED"
Expand All @@ -845,7 +844,7 @@ async def test_device_registry(
chromecast.disconnect.assert_not_called()

client = await hass_ws_client(hass)
response = await client.remove_device(device_entry.id, cast_entry.entry_id)
response = await client.remove_device(device_entry.id)
assert response["success"]

await hass.async_block_till_done()
Expand Down
4 changes: 2 additions & 2 deletions tests/components/coolmaster/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def test_registry_cleanup(
# Try to remove "L1.100" - fails since it is live
device = device_registry.async_get_device_by_identifier((DOMAIN, live_id), entry_id)
assert device is not None
response = await client.remove_device(device.id, entry_id)
response = await client.remove_device(device.id)
assert not response["success"]
assert (
len(dr.async_entries_for_config_entry(device_registry, entry_id))
Expand All @@ -76,7 +76,7 @@ async def test_registry_cleanup(
# Try to remove "L2.200" - succeeds since it is dead
device = device_registry.async_get_device_by_identifier((DOMAIN, dead_id), entry_id)
assert device is not None
response = await client.remove_device(device.id, entry_id)
response = await client.remove_device(device.id)
assert response["success"]
assert (
len(dr.async_entries_for_config_entry(device_registry, entry_id)) == unit_count
Expand Down
2 changes: 1 addition & 1 deletion tests/components/devolo_home_control/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def test_remove_device(
assert device_entry

client = await hass_ws_client(hass)
response = await client.remove_device(device_entry.id, entry.entry_id)
response = await client.remove_device(device_entry.id)
assert response["success"]
assert (
device_registry.async_get_device_by_identifier(
Expand Down
8 changes: 2 additions & 6 deletions tests/components/eheimdigital/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,13 @@ async def test_remove_device(
hass_client = await hass_ws_client(hass)

# Do not allow to delete a connected device
response = await hass_client.remove_device(
device_entry.id, mock_config_entry.entry_id
)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

eheimdigital_hub_mock.return_value.devices = {}

# Allow to delete a not connected device
response = await hass_client.remove_device(
device_entry.id, mock_config_entry.entry_id
)
response = await hass_client.remove_device(device_entry.id)
assert response["success"]


Expand Down
16 changes: 8 additions & 8 deletions tests/components/enphase_envoy/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,37 +441,37 @@ async def test_remove_config_entry_device(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "delete_this_device")},
)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert response["success"]

# inverters are not allowed to be removed
entity = entity_registry.entities["sensor.inverter_1"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

# envoy itself is not allowed to be removed
entity = entity_registry.entities["sensor.envoy_1234_current_power_production"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

# encharge can not be removed
entity = entity_registry.entities["sensor.encharge_123456_power"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

# enpower can not be removed
entity = entity_registry.entities["sensor.enpower_654321_temperature"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

# relays can be removed
entity = entity_registry.entities["switch.nc1_fixture"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert response["success"]


Expand Down Expand Up @@ -526,13 +526,13 @@ async def test_remove_config_entry_device_acb(
# the ACB aggregate device can not be removed
entity = entity_registry.entities["sensor.acb_1234_power"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]

# an individual AC Battery device can not be removed
entity = entity_registry.entities["sensor.ac_battery_121000000001_state_of_charge"]
device_entry = device_registry.async_get(entity.device_id)
response = await hass_client.remove_device(device_entry.id, config_entry.entry_id)
response = await hass_client.remove_device(device_entry.id)
assert not response["success"]


Expand Down
4 changes: 2 additions & 2 deletions tests/components/fjaraskupan/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ async def test_remove_device(
assert device_entry

client = await hass_ws_client(hass)
response = await client.remove_device(device_entry.id, config_entry.entry_id)
response = await client.remove_device(device_entry.id)
assert not response["success"]

await hass.async_block_till_done()
assert device_registry.async_get(device_entry.id)

with patch_discovered_devices([]):
response = await client.remove_device(device_entry.id, config_entry.entry_id)
response = await client.remove_device(device_entry.id)
assert response["success"]

await hass.async_block_till_done()
Expand Down
4 changes: 2 additions & 2 deletions tests/components/fritzbox/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ async def test_remove_device(

# try to delete good_device
ws_client = await hass_ws_client(hass)
response = await ws_client.remove_device(good_device.id, entry.entry_id)
response = await ws_client.remove_device(good_device.id)
assert not response["success"]
assert response["error"]["code"] == "home_assistant_error"
await hass.async_block_till_done()

# try to delete orphan_device
ws_client = await hass_ws_client(hass)
response = await ws_client.remove_device(orphan_device.id, entry.entry_id)
response = await ws_client.remove_device(orphan_device.id)
assert response["success"]
await hass.async_block_till_done()

Expand Down
2 changes: 1 addition & 1 deletion tests/components/fronius/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def test_device_remove_devices(
(DOMAIN, "12345678"), config_entry.entry_id
)
client = await hass_ws_client(hass)
response = await client.remove_device(inverter_1.id, config_entry.entry_id)
response = await client.remove_device(inverter_1.id)
assert response["success"]

assert not device_registry.async_get_device_by_identifier(
Expand Down
2 changes: 1 addition & 1 deletion tests/components/heos/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async def test_remove_config_entry_device(
)

ws_client = await hass_ws_client(hass)
response = await ws_client.remove_device(device_entry.id, config_entry.entry_id)
response = await ws_client.remove_device(device_entry.id)
assert response["success"] == expected_result


Expand Down
Loading
Loading