mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Remove deprecated ring.update
action (#125762)
This commit is contained in:
parent
344e43a94a
commit
bbdc036c3e
@ -11,14 +11,13 @@ from ring_doorbell import Auth, Ring, RingDevices
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import APPLICATION_NAME, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import (
|
||||
device_registry as dr,
|
||||
entity_registry as er,
|
||||
instance_id,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
|
||||
from .const import CONF_LISTEN_CREDENTIALS, DOMAIN, PLATFORMS
|
||||
from .coordinator import RingDataCoordinator, RingListenCoordinator
|
||||
@ -103,30 +102,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: RingConfigEntry) -> bool
|
||||
if hass.services.has_service(DOMAIN, "update"):
|
||||
return True
|
||||
|
||||
async def async_refresh_all(_: ServiceCall) -> None:
|
||||
"""Refresh all ring data."""
|
||||
_LOGGER.warning(
|
||||
"Detected use of service 'ring.update'. "
|
||||
"This is deprecated and will stop working in Home Assistant 2024.10. "
|
||||
"Use 'homeassistant.update_entity' instead which updates all ring entities",
|
||||
)
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_service_ring_update",
|
||||
breaks_in_ha_version="2024.10.0",
|
||||
is_fixable=True,
|
||||
is_persistent=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_service_ring_update",
|
||||
)
|
||||
for loaded_entry in hass.config_entries.async_loaded_entries(DOMAIN):
|
||||
await loaded_entry.runtime_data.devices_coordinator.async_refresh()
|
||||
|
||||
# register service
|
||||
hass.services.async_register(DOMAIN, "update", async_refresh_all)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
update:
|
@ -98,24 +98,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"update": {
|
||||
"name": "Update",
|
||||
"description": "Updates the data we have for all your ring devices."
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_service_ring_update": {
|
||||
"title": "Detected use of deprecated action `ring.update`",
|
||||
"fix_flow": {
|
||||
"step": {
|
||||
"confirm": {
|
||||
"title": "[%key:component::ring::issues::deprecated_service_ring_update::title%]",
|
||||
"description": "Use `homeassistant.update_entity` instead which will update all ring entities.\n\nPlease replace uses of this action and adjust your automations and scripts and select **submit** to close this issue."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated_entity": {
|
||||
"title": "Detected deprecated `{platform}` entity usage",
|
||||
"description": "We detected that entity `{entity}` is being used in `{info}`\n\nWe have created a new `{new_platform}` entity and you should migrate `{info}` to use this new entity.\n\nWhen you are done migrating `{info}` and are ready to have the deprecated `{entity}` entity removed, disable the entity and restart Home Assistant."
|
||||
|
@ -138,25 +138,6 @@ async def test_camera_motion_detection_not_supported(
|
||||
)
|
||||
|
||||
|
||||
async def test_updates_work(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the update service works correctly."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
state = hass.states.get("camera.internal")
|
||||
assert state.attributes.get("motion_detection") is True
|
||||
|
||||
internal_camera_mock = mock_ring_devices.get_device(345678)
|
||||
internal_camera_mock.motion_detection = False
|
||||
|
||||
await hass.services.async_call("ring", "update", {}, blocking=True)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("camera.internal")
|
||||
assert state.attributes.get("motion_detection") is not True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.components.ring.coordinator import RingEventListener
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import CONF_TOKEN, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .device_mocks import FRONT_DOOR_DEVICE_ID
|
||||
@ -233,33 +233,6 @@ async def test_error_on_device_update(
|
||||
assert hass.config_entries.async_get_entry(mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_issue_deprecated_service_ring_update(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mock_ring_client,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the issue is raised on deprecated service ring.update."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.services.async_call(DOMAIN, "update", {}, blocking=True)
|
||||
|
||||
issue = issue_registry.async_get_issue("ring", "deprecated_service_ring_update")
|
||||
assert issue
|
||||
assert issue.issue_domain == "ring"
|
||||
assert issue.issue_id == "deprecated_service_ring_update"
|
||||
assert issue.translation_key == "deprecated_service_ring_update"
|
||||
|
||||
assert (
|
||||
"Detected use of service 'ring.update'. "
|
||||
"This is deprecated and will stop working in Home Assistant 2024.10. "
|
||||
"Use 'homeassistant.update_entity' instead which updates all ring entities"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("domain", "old_unique_id"),
|
||||
[
|
||||
|
@ -65,25 +65,6 @@ async def test_light_can_be_turned_on(hass: HomeAssistant, mock_ring_client) ->
|
||||
assert state.state == "on"
|
||||
|
||||
|
||||
async def test_updates_work(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the update service works correctly."""
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
state = hass.states.get("light.front_light")
|
||||
assert state.state == "off"
|
||||
|
||||
front_light_mock = mock_ring_devices.get_device(765432)
|
||||
front_light_mock.lights = "on"
|
||||
|
||||
await hass.services.async_call("ring", "update", {}, blocking=True)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("light.front_light")
|
||||
assert state.state == "on"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
|
@ -4,11 +4,10 @@ import pytest
|
||||
import ring_doorbell
|
||||
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import setup_platform
|
||||
|
||||
@ -66,31 +65,6 @@ async def test_siren_can_be_turned_on(hass: HomeAssistant, mock_ring_client) ->
|
||||
assert state.state == "on"
|
||||
|
||||
|
||||
async def test_updates_work(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the update service works correctly."""
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
state = hass.states.get("switch.front_siren")
|
||||
assert state.state == "off"
|
||||
|
||||
front_siren_mock = mock_ring_devices.get_device(765432)
|
||||
front_siren_mock.siren = 20
|
||||
|
||||
await async_setup_component(hass, "homeassistant", {})
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
"update_entity",
|
||||
{ATTR_ENTITY_ID: ["switch.front_siren"]},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("switch.front_siren")
|
||||
assert state.state == "on"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user