init home-assistant
This commit is contained in:
1
home-assistant/tests/components/ring/__init__.py
Normal file
1
home-assistant/tests/components/ring/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Tests for the ring component."""
|
||||
37
home-assistant/tests/components/ring/common.py
Normal file
37
home-assistant/tests/components/ring/common.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Common methods used across the tests for ring devices."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.automation import DOMAIN as AUTOMATION_DOMAIN
|
||||
from homeassistant.components.ring import DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def setup_platform(hass: HomeAssistant, platform: Platform) -> None:
|
||||
"""Set up the ring platform and prerequisites."""
|
||||
if not hass.config_entries.async_has_entries(DOMAIN):
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN, data={"username": "foo", "token": {}}
|
||||
).add_to_hass(hass)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [platform]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
|
||||
async def setup_automation(hass: HomeAssistant, alias: str, entity_id: str) -> None:
|
||||
"""Set up an automation for tests."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
AUTOMATION_DOMAIN,
|
||||
{
|
||||
AUTOMATION_DOMAIN: {
|
||||
"alias": alias,
|
||||
"trigger": {"platform": "state", "entity_id": entity_id, "to": "on"},
|
||||
"action": {"action": "notify.notify", "metadata": {}, "data": {}},
|
||||
}
|
||||
},
|
||||
)
|
||||
154
home-assistant/tests/components/ring/conftest.py
Normal file
154
home-assistant/tests/components/ring/conftest.py
Normal file
@@ -0,0 +1,154 @@
|
||||
"""Configuration for Ring tests."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from itertools import chain
|
||||
from unittest.mock import AsyncMock, Mock, create_autospec, patch
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
|
||||
from homeassistant.components.ring import DOMAIN
|
||||
from homeassistant.components.ring.const import CONF_CONFIG_ENTRY_MINOR_VERSION
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .device_mocks import get_devices_data, get_mock_devices
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.light.conftest import mock_light_profiles # noqa: F401
|
||||
|
||||
MOCK_HARDWARE_ID = "foo-bar"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Override async_setup_entry."""
|
||||
with patch(
|
||||
"homeassistant.components.ring.async_setup_entry", return_value=True
|
||||
) as mock_setup_entry:
|
||||
yield mock_setup_entry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_ring_init_auth_class():
|
||||
"""Mock ring_doorbell.Auth in init and return the mock class."""
|
||||
with patch("homeassistant.components.ring.Auth", autospec=True) as mock_ring_auth:
|
||||
mock_ring_auth.return_value.async_fetch_token.return_value = {
|
||||
"access_token": "mock-token"
|
||||
}
|
||||
yield mock_ring_auth
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_ring_auth():
|
||||
"""Mock ring_doorbell.Auth."""
|
||||
with patch(
|
||||
"homeassistant.components.ring.config_flow.Auth", autospec=True
|
||||
) as mock_ring_auth:
|
||||
mock_ring_auth.return_value.async_fetch_token.return_value = {
|
||||
"access_token": "mock-token"
|
||||
}
|
||||
yield mock_ring_auth.return_value
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_ring_devices():
|
||||
"""Mock Ring devices."""
|
||||
|
||||
devices = get_mock_devices()
|
||||
device_list = list(chain.from_iterable(devices.values()))
|
||||
|
||||
def filter_devices(device_api_ai: int, device_family: set | None = None):
|
||||
return next(
|
||||
iter(
|
||||
[
|
||||
device
|
||||
for device in device_list
|
||||
if device.id == device_api_ai
|
||||
and (not device_family or device.family in device_family)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
class FakeRingDevices:
|
||||
"""Class fakes the RingDevices class."""
|
||||
|
||||
all_devices = device_list
|
||||
video_devices = (
|
||||
devices["stickup_cams"]
|
||||
+ devices["doorbots"]
|
||||
+ devices["authorized_doorbots"]
|
||||
)
|
||||
stickup_cams = devices["stickup_cams"]
|
||||
other = devices["other"]
|
||||
chimes = devices["chimes"]
|
||||
|
||||
def get_device(self, id):
|
||||
return filter_devices(id)
|
||||
|
||||
def get_video_device(self, id):
|
||||
return filter_devices(
|
||||
id, {"stickup_cams", "doorbots", "authorized_doorbots"}
|
||||
)
|
||||
|
||||
def get_stickup_cam(self, id):
|
||||
return filter_devices(id, {"stickup_cams"})
|
||||
|
||||
def get_other(self, id):
|
||||
return filter_devices(id, {"other"})
|
||||
|
||||
return FakeRingDevices()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_ring_client(mock_ring_auth, mock_ring_devices):
|
||||
"""Mock ring client api."""
|
||||
mock_client = create_autospec(ring_doorbell.Ring)
|
||||
mock_client.return_value.devices_data = get_devices_data()
|
||||
mock_client.return_value.devices.return_value = mock_ring_devices
|
||||
mock_client.return_value.active_alerts.return_value = []
|
||||
|
||||
with patch("homeassistant.components.ring.Ring", new=mock_client):
|
||||
yield mock_client.return_value
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
"""Mock ConfigEntry."""
|
||||
return MockConfigEntry(
|
||||
title="Ring",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
"token": {"access_token": "mock-token"},
|
||||
},
|
||||
unique_id="foo@bar.com",
|
||||
version=1,
|
||||
minor_version=CONF_CONFIG_ENTRY_MINOR_VERSION,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def mock_added_config_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_ring_auth: Mock,
|
||||
mock_ring_client: Mock,
|
||||
) -> MockConfigEntry:
|
||||
"""Mock ConfigEntry that's been added to HA."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
return mock_config_entry
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_ring_event_listener_class():
|
||||
"""Fixture to mock the ring event listener."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ring.coordinator.RingEventListener", autospec=True
|
||||
) as mock_ring_listener:
|
||||
mock_ring_listener.return_value.started = True
|
||||
yield mock_ring_listener
|
||||
208
home-assistant/tests/components/ring/device_mocks.py
Normal file
208
home-assistant/tests/components/ring/device_mocks.py
Normal file
@@ -0,0 +1,208 @@
|
||||
"""Module for ring device mocks.
|
||||
|
||||
Creates a MagicMock for all device families, i.e. chimes, doorbells, stickup_cams and other.
|
||||
|
||||
Each device entry in the devices.json will have a MagicMock instead of the RingObject.
|
||||
|
||||
Mocks the api calls on the devices such as history() and health().
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
from ring_doorbell import (
|
||||
RingCapability,
|
||||
RingChime,
|
||||
RingDoorBell,
|
||||
RingOther,
|
||||
RingStickUpCam,
|
||||
)
|
||||
from ring_doorbell.const import DOORBELL_EXISTING_TYPE
|
||||
|
||||
from homeassistant.components.ring.const import DOMAIN
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import load_json_value_fixture
|
||||
|
||||
DEVICES_FIXTURE = load_json_value_fixture("devices.json", DOMAIN)
|
||||
DOORBOT_HISTORY = load_json_value_fixture("doorbot_history.json", DOMAIN)
|
||||
INTERCOM_HISTORY = load_json_value_fixture("intercom_history.json", DOMAIN)
|
||||
DOORBOT_HEALTH = load_json_value_fixture("doorbot_health_attrs.json", DOMAIN)
|
||||
CHIME_HEALTH = load_json_value_fixture("chime_health_attrs.json", DOMAIN)
|
||||
|
||||
FRONT_DOOR_DEVICE_ID = 987654
|
||||
INGRESS_DEVICE_ID = 185036587
|
||||
FRONT_DEVICE_ID = 765432
|
||||
INTERNAL_DEVICE_ID = 345678
|
||||
DOWNSTAIRS_DEVICE_ID = 123456
|
||||
|
||||
|
||||
def get_mock_devices():
|
||||
"""Return list of mock devices keyed by device_type."""
|
||||
devices = {}
|
||||
for device_family, device_class in DEVICE_TYPES.items():
|
||||
devices[device_family] = [
|
||||
_mocked_ring_device(
|
||||
device, device_family, device_class, DEVICE_CAPABILITIES[device_class]
|
||||
)
|
||||
for device in DEVICES_FIXTURE[device_family]
|
||||
]
|
||||
return devices
|
||||
|
||||
|
||||
def get_devices_data():
|
||||
"""Return devices raw json used by the diagnostics module."""
|
||||
return {
|
||||
device_type: {obj["id"]: obj for obj in devices}
|
||||
for device_type, devices in DEVICES_FIXTURE.items()
|
||||
}
|
||||
|
||||
|
||||
DEVICE_TYPES = {
|
||||
"doorbots": RingDoorBell,
|
||||
"authorized_doorbots": RingDoorBell,
|
||||
"stickup_cams": RingStickUpCam,
|
||||
"chimes": RingChime,
|
||||
"other": RingOther,
|
||||
}
|
||||
|
||||
DEVICE_CAPABILITIES = {
|
||||
RingDoorBell: [
|
||||
RingCapability.BATTERY,
|
||||
RingCapability.VOLUME,
|
||||
RingCapability.MOTION_DETECTION,
|
||||
RingCapability.VIDEO,
|
||||
RingCapability.DING,
|
||||
RingCapability.HISTORY,
|
||||
],
|
||||
RingStickUpCam: [
|
||||
RingCapability.BATTERY,
|
||||
RingCapability.VOLUME,
|
||||
RingCapability.MOTION_DETECTION,
|
||||
RingCapability.VIDEO,
|
||||
RingCapability.HISTORY,
|
||||
RingCapability.SIREN,
|
||||
RingCapability.LIGHT,
|
||||
],
|
||||
RingChime: [RingCapability.VOLUME],
|
||||
RingOther: [RingCapability.OPEN, RingCapability.HISTORY, RingCapability.DING],
|
||||
}
|
||||
|
||||
|
||||
def _mocked_ring_device(device_dict, device_family, device_class, capabilities):
|
||||
"""Return a mocked device."""
|
||||
mock_device = MagicMock(spec=device_class, name=f"Mocked {device_family!s}")
|
||||
|
||||
def has_capability(capability):
|
||||
return (
|
||||
capability in capabilities
|
||||
if isinstance(capability, RingCapability)
|
||||
else RingCapability.from_name(capability) in capabilities
|
||||
)
|
||||
|
||||
def update_health_data(fixture):
|
||||
mock_device.configure_mock(
|
||||
wifi_signal_category=fixture["device_health"].get("latest_signal_category"),
|
||||
wifi_signal_strength=fixture["device_health"].get("latest_signal_strength"),
|
||||
)
|
||||
|
||||
def update_history_data(fixture):
|
||||
for entry in fixture: # Mimic the api date parsing
|
||||
if isinstance(entry["created_at"], str):
|
||||
dt_at = datetime.strptime(entry["created_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
entry["created_at"] = dt_util.as_utc(dt_at)
|
||||
mock_device.configure_mock(last_history=fixture) # Set last_history
|
||||
return fixture
|
||||
|
||||
# Configure the device attributes
|
||||
mock_device.configure_mock(**device_dict)
|
||||
|
||||
# Configure the Properties on the device
|
||||
mock_device.configure_mock(
|
||||
model=device_family,
|
||||
device_api_id=device_dict["id"],
|
||||
name=device_dict["description"],
|
||||
wifi_signal_category=None,
|
||||
wifi_signal_strength=None,
|
||||
family=device_family,
|
||||
)
|
||||
|
||||
# Configure common methods
|
||||
mock_device.has_capability.side_effect = has_capability
|
||||
mock_device.async_update_health_data.side_effect = lambda: update_health_data(
|
||||
DOORBOT_HEALTH if device_family != "chimes" else CHIME_HEALTH
|
||||
)
|
||||
# Configure methods based on capability
|
||||
if has_capability(RingCapability.HISTORY):
|
||||
mock_device.configure_mock(last_history=[])
|
||||
mock_device.async_history.side_effect = lambda *_, **__: update_history_data(
|
||||
DOORBOT_HISTORY if device_family != "other" else INTERCOM_HISTORY
|
||||
)
|
||||
|
||||
if has_capability(RingCapability.VIDEO):
|
||||
mock_device.async_recording_url = AsyncMock(return_value="http://dummy.url")
|
||||
|
||||
if has_capability(RingCapability.MOTION_DETECTION):
|
||||
mock_device.configure_mock(
|
||||
motion_detection=device_dict["settings"].get("motion_detection_enabled"),
|
||||
)
|
||||
mock_device.async_set_motion_detection.side_effect = (
|
||||
lambda i: mock_device.configure_mock(motion_detection=i)
|
||||
)
|
||||
|
||||
if has_capability(RingCapability.LIGHT):
|
||||
mock_device.configure_mock(lights=device_dict.get("led_status"))
|
||||
|
||||
if has_capability(RingCapability.VOLUME):
|
||||
mock_device.configure_mock(
|
||||
volume=device_dict["settings"].get(
|
||||
"doorbell_volume", device_dict["settings"].get("volume")
|
||||
)
|
||||
)
|
||||
mock_device.async_set_volume.side_effect = lambda i: mock_device.configure_mock(
|
||||
volume=i
|
||||
)
|
||||
|
||||
if has_capability(RingCapability.SIREN):
|
||||
mock_device.configure_mock(
|
||||
siren=device_dict["siren_status"].get("seconds_remaining")
|
||||
)
|
||||
mock_device.async_set_siren.side_effect = lambda i: mock_device.configure_mock(
|
||||
siren=i
|
||||
)
|
||||
|
||||
if has_capability(RingCapability.BATTERY):
|
||||
mock_device.configure_mock(
|
||||
battery_life=min(
|
||||
100, device_dict.get("battery_life", device_dict.get("battery_life2"))
|
||||
)
|
||||
)
|
||||
|
||||
if device_family == "doorbots":
|
||||
mock_device.configure_mock(
|
||||
existing_doorbell_type=DOORBELL_EXISTING_TYPE[
|
||||
device_dict["settings"]["chime_settings"].get("type", 2)
|
||||
]
|
||||
)
|
||||
mock_device.configure_mock(
|
||||
existing_doorbell_type_enabled=device_dict["settings"][
|
||||
"chime_settings"
|
||||
].get("enable", False)
|
||||
)
|
||||
mock_device.async_set_existing_doorbell_type_enabled.side_effect = (
|
||||
lambda i: mock_device.configure_mock(existing_doorbell_type_enabled=i)
|
||||
)
|
||||
|
||||
if device_family == "other":
|
||||
for prop in ("doorbell_volume", "mic_volume", "voice_volume"):
|
||||
mock_device.configure_mock(
|
||||
**{
|
||||
prop: device_dict["settings"].get(prop),
|
||||
f"async_set_{prop}.side_effect": partial(
|
||||
setattr, mock_device, prop
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
return mock_device
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"device_health": {
|
||||
"average_signal_category": "good",
|
||||
"average_signal_strength": -39,
|
||||
"battery_percentage": 100,
|
||||
"battery_percentage_category": null,
|
||||
"battery_voltage": null,
|
||||
"battery_voltage_category": null,
|
||||
"firmware": "1.2.3",
|
||||
"firmware_out_of_date": false,
|
||||
"id": 999999,
|
||||
"latest_signal_category": "good",
|
||||
"latest_signal_strength": -39,
|
||||
"updated_at": "2017-09-30T07:05:03Z",
|
||||
"wifi_is_ring_network": false,
|
||||
"wifi_name": "ring_mock_wifi"
|
||||
}
|
||||
}
|
||||
469
home-assistant/tests/components/ring/fixtures/devices.json
Normal file
469
home-assistant/tests/components/ring/fixtures/devices.json
Normal file
@@ -0,0 +1,469 @@
|
||||
{
|
||||
"authorized_doorbots": [],
|
||||
"chimes": [
|
||||
{
|
||||
"address": "123 Main St",
|
||||
"alerts": { "connection": "online" },
|
||||
"description": "Downstairs",
|
||||
"device_id": "abcdef123456",
|
||||
"do_not_disturb": { "seconds_left": 0 },
|
||||
"features": { "ringtones_enabled": true },
|
||||
"firmware_version": "1.2.3",
|
||||
"id": 123456,
|
||||
"kind": "chime",
|
||||
"latitude": 12.0,
|
||||
"longitude": -70.12345,
|
||||
"owned": true,
|
||||
"owner": {
|
||||
"email": "foo@bar.org",
|
||||
"first_name": "Marcelo",
|
||||
"id": 999999,
|
||||
"last_name": "Assistant"
|
||||
},
|
||||
"settings": {
|
||||
"ding_audio_id": null,
|
||||
"ding_audio_user_id": null,
|
||||
"motion_audio_id": null,
|
||||
"motion_audio_user_id": null,
|
||||
"volume": 2
|
||||
},
|
||||
"time_zone": "America/New_York"
|
||||
}
|
||||
],
|
||||
"doorbots": [
|
||||
{
|
||||
"address": "123 Main St",
|
||||
"alerts": { "connection": "online" },
|
||||
"battery_life": 4081,
|
||||
"description": "Front Door",
|
||||
"device_id": "aacdef987654",
|
||||
"external_connection": false,
|
||||
"features": {
|
||||
"advanced_motion_enabled": false,
|
||||
"motion_message_enabled": false,
|
||||
"motions_enabled": true,
|
||||
"people_only_enabled": false,
|
||||
"shadow_correction_enabled": false,
|
||||
"show_recordings": true
|
||||
},
|
||||
"firmware_version": "1.4.26",
|
||||
"id": 987654,
|
||||
"kind": "lpd_v1",
|
||||
"latitude": 12.0,
|
||||
"longitude": -70.12345,
|
||||
"motion_snooze": null,
|
||||
"owned": true,
|
||||
"owner": {
|
||||
"email": "foo@bar.org",
|
||||
"first_name": "Home",
|
||||
"id": 999999,
|
||||
"last_name": "Assistant"
|
||||
},
|
||||
"settings": {
|
||||
"chime_settings": {
|
||||
"duration": 3,
|
||||
"enable": true,
|
||||
"type": 0
|
||||
},
|
||||
"doorbell_volume": 1,
|
||||
"enable_vod": true,
|
||||
"live_view_preset_profile": "highest",
|
||||
"live_view_presets": ["low", "middle", "high", "highest"],
|
||||
"motion_detection_enabled": true,
|
||||
"motion_announcement": false,
|
||||
"motion_snooze_preset_profile": "low",
|
||||
"motion_snooze_presets": ["null", "low", "medium", "high"]
|
||||
},
|
||||
"subscribed": true,
|
||||
"subscribed_motions": true,
|
||||
"time_zone": "America/New_York"
|
||||
}
|
||||
],
|
||||
"stickup_cams": [
|
||||
{
|
||||
"address": "123 Main St",
|
||||
"alerts": { "connection": "online" },
|
||||
"battery_life": 80,
|
||||
"description": "Front",
|
||||
"device_id": "aacdef765432",
|
||||
"external_connection": false,
|
||||
"features": {
|
||||
"advanced_motion_enabled": false,
|
||||
"motion_message_enabled": false,
|
||||
"motions_enabled": true,
|
||||
"night_vision_enabled": false,
|
||||
"people_only_enabled": false,
|
||||
"shadow_correction_enabled": false,
|
||||
"show_recordings": true
|
||||
},
|
||||
"firmware_version": "1.9.3",
|
||||
"id": 765432,
|
||||
"kind": "hp_cam_v1",
|
||||
"latitude": 12.0,
|
||||
"led_status": "off",
|
||||
"location_id": null,
|
||||
"longitude": -70.12345,
|
||||
"motion_snooze": { "scheduled": true },
|
||||
"night_mode_status": "false",
|
||||
"owned": true,
|
||||
"owner": {
|
||||
"email": "foo@bar.org",
|
||||
"first_name": "Foo",
|
||||
"id": 999999,
|
||||
"last_name": "Bar"
|
||||
},
|
||||
"ring_cam_light_installed": "false",
|
||||
"ring_id": null,
|
||||
"settings": {
|
||||
"chime_settings": {
|
||||
"duration": 10,
|
||||
"enable": true,
|
||||
"type": 0
|
||||
},
|
||||
"doorbell_volume": 11,
|
||||
"enable_vod": true,
|
||||
"floodlight_settings": {
|
||||
"duration": 30,
|
||||
"priority": 0
|
||||
},
|
||||
"light_schedule_settings": {
|
||||
"end_hour": 0,
|
||||
"end_minute": 0,
|
||||
"start_hour": 0,
|
||||
"start_minute": 0
|
||||
},
|
||||
"live_view_preset_profile": "highest",
|
||||
"live_view_presets": ["low", "middle", "high", "highest"],
|
||||
"motion_detection_enabled": false,
|
||||
"motion_announcement": false,
|
||||
"motion_snooze_preset_profile": "low",
|
||||
"motion_snooze_presets": ["none", "low", "medium", "high"],
|
||||
"motion_zones": {
|
||||
"active_motion_filter": 1,
|
||||
"advanced_object_settings": {
|
||||
"human_detection_confidence": {
|
||||
"day": 0.7,
|
||||
"night": 0.7
|
||||
},
|
||||
"motion_zone_overlap": {
|
||||
"day": 0.1,
|
||||
"night": 0.2
|
||||
},
|
||||
"object_size_maximum": {
|
||||
"day": 0.8,
|
||||
"night": 0.8
|
||||
},
|
||||
"object_size_minimum": {
|
||||
"day": 0.03,
|
||||
"night": 0.05
|
||||
},
|
||||
"object_time_overlap": {
|
||||
"day": 0.1,
|
||||
"night": 0.6
|
||||
}
|
||||
},
|
||||
"enable_audio": false,
|
||||
"pir_settings": {
|
||||
"sensitivity1": 1,
|
||||
"sensitivity2": 1,
|
||||
"sensitivity3": 1,
|
||||
"zone_mask": 6
|
||||
},
|
||||
"sensitivity": 5,
|
||||
"zone1": {
|
||||
"name": "Zone 1",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
},
|
||||
"zone2": {
|
||||
"name": "Zone 2",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
},
|
||||
"zone3": {
|
||||
"name": "Zone 3",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
}
|
||||
},
|
||||
"pir_motion_zones": [0, 1, 1],
|
||||
"pir_settings": {
|
||||
"sensitivity1": 1,
|
||||
"sensitivity2": 1,
|
||||
"sensitivity3": 1,
|
||||
"zone_mask": 6
|
||||
},
|
||||
"stream_setting": 0,
|
||||
"video_settings": {
|
||||
"ae_level": 0,
|
||||
"birton": null,
|
||||
"brightness": 0,
|
||||
"contrast": 64,
|
||||
"saturation": 80
|
||||
}
|
||||
},
|
||||
"siren_status": { "seconds_remaining": 0 },
|
||||
"stolen": false,
|
||||
"subscribed": true,
|
||||
"subscribed_motions": true,
|
||||
"time_zone": "America/New_York"
|
||||
},
|
||||
{
|
||||
"address": "123 Main St",
|
||||
"alerts": { "connection": "online" },
|
||||
"battery_life": 80,
|
||||
"description": "Internal",
|
||||
"device_id": "aacdef345678",
|
||||
"external_connection": false,
|
||||
"features": {
|
||||
"advanced_motion_enabled": false,
|
||||
"motion_message_enabled": false,
|
||||
"motions_enabled": true,
|
||||
"night_vision_enabled": false,
|
||||
"people_only_enabled": false,
|
||||
"shadow_correction_enabled": false,
|
||||
"show_recordings": true
|
||||
},
|
||||
"firmware_version": "1.9.3",
|
||||
"id": 345678,
|
||||
"kind": "hp_cam_v1",
|
||||
"latitude": 12.0,
|
||||
"led_status": "on",
|
||||
"location_id": null,
|
||||
"longitude": -70.12345,
|
||||
"motion_snooze": { "scheduled": true },
|
||||
"night_mode_status": "false",
|
||||
"owned": true,
|
||||
"owner": {
|
||||
"email": "foo@bar.org",
|
||||
"first_name": "Foo",
|
||||
"id": 999999,
|
||||
"last_name": "Bar"
|
||||
},
|
||||
"ring_cam_light_installed": "false",
|
||||
"ring_id": null,
|
||||
"settings": {
|
||||
"chime_settings": {
|
||||
"duration": 10,
|
||||
"enable": true,
|
||||
"type": 0
|
||||
},
|
||||
"doorbell_volume": 11,
|
||||
"enable_vod": true,
|
||||
"floodlight_settings": {
|
||||
"duration": 30,
|
||||
"priority": 0
|
||||
},
|
||||
"light_schedule_settings": {
|
||||
"end_hour": 0,
|
||||
"end_minute": 0,
|
||||
"start_hour": 0,
|
||||
"start_minute": 0
|
||||
},
|
||||
"live_view_preset_profile": "highest",
|
||||
"live_view_presets": ["low", "middle", "high", "highest"],
|
||||
"motion_detection_enabled": true,
|
||||
"motion_announcement": false,
|
||||
"motion_snooze_preset_profile": "low",
|
||||
"motion_snooze_presets": ["none", "low", "medium", "high"],
|
||||
"motion_zones": {
|
||||
"active_motion_filter": 1,
|
||||
"advanced_object_settings": {
|
||||
"human_detection_confidence": {
|
||||
"day": 0.7,
|
||||
"night": 0.7
|
||||
},
|
||||
"motion_zone_overlap": {
|
||||
"day": 0.1,
|
||||
"night": 0.2
|
||||
},
|
||||
"object_size_maximum": {
|
||||
"day": 0.8,
|
||||
"night": 0.8
|
||||
},
|
||||
"object_size_minimum": {
|
||||
"day": 0.03,
|
||||
"night": 0.05
|
||||
},
|
||||
"object_time_overlap": {
|
||||
"day": 0.1,
|
||||
"night": 0.6
|
||||
}
|
||||
},
|
||||
"enable_audio": false,
|
||||
"pir_settings": {
|
||||
"sensitivity1": 1,
|
||||
"sensitivity2": 1,
|
||||
"sensitivity3": 1,
|
||||
"zone_mask": 6
|
||||
},
|
||||
"sensitivity": 5,
|
||||
"zone1": {
|
||||
"name": "Zone 1",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
},
|
||||
"zone2": {
|
||||
"name": "Zone 2",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
},
|
||||
"zone3": {
|
||||
"name": "Zone 3",
|
||||
"state": 2,
|
||||
"vertex1": { "x": 0.0, "y": 0.0 },
|
||||
"vertex2": { "x": 0.0, "y": 0.0 },
|
||||
"vertex3": { "x": 0.0, "y": 0.0 },
|
||||
"vertex4": { "x": 0.0, "y": 0.0 },
|
||||
"vertex5": { "x": 0.0, "y": 0.0 },
|
||||
"vertex6": { "x": 0.0, "y": 0.0 },
|
||||
"vertex7": { "x": 0.0, "y": 0.0 },
|
||||
"vertex8": { "x": 0.0, "y": 0.0 }
|
||||
}
|
||||
},
|
||||
"pir_motion_zones": [0, 1, 1],
|
||||
"pir_settings": {
|
||||
"sensitivity1": 1,
|
||||
"sensitivity2": 1,
|
||||
"sensitivity3": 1,
|
||||
"zone_mask": 6
|
||||
},
|
||||
"stream_setting": 0,
|
||||
"video_settings": {
|
||||
"ae_level": 0,
|
||||
"birton": null,
|
||||
"brightness": 0,
|
||||
"contrast": 64,
|
||||
"saturation": 80
|
||||
}
|
||||
},
|
||||
"siren_status": { "seconds_remaining": 30 },
|
||||
"stolen": false,
|
||||
"subscribed": true,
|
||||
"subscribed_motions": true,
|
||||
"time_zone": "America/New_York"
|
||||
}
|
||||
],
|
||||
"other": [
|
||||
{
|
||||
"id": 185036587,
|
||||
"kind": "intercom_handset_audio",
|
||||
"description": "Ingress",
|
||||
"location_id": "mock-location-id",
|
||||
"schema_id": null,
|
||||
"is_sidewalk_gateway": false,
|
||||
"created_at": "2023-12-01T18:05:25Z",
|
||||
"deactivated_at": null,
|
||||
"owner": {
|
||||
"id": 762490876,
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"email": ""
|
||||
},
|
||||
"device_id": "abcdef185036587",
|
||||
"time_zone": "Europe/Rome",
|
||||
"firmware_version": "Up to Date",
|
||||
"owned": true,
|
||||
"ring_net_id": null,
|
||||
"settings": {
|
||||
"features_confirmed": 5,
|
||||
"show_recordings": true,
|
||||
"recording_ttl": 180,
|
||||
"recording_enabled": false,
|
||||
"keep_alive": null,
|
||||
"keep_alive_auto": 45.0,
|
||||
"doorbell_volume": 8,
|
||||
"enable_chime": 1,
|
||||
"theft_alarm_enable": 0,
|
||||
"use_cached_domain": 1,
|
||||
"use_server_ip": 0,
|
||||
"server_domain": "fw.ring.com",
|
||||
"server_ip": null,
|
||||
"enable_log": 1,
|
||||
"forced_keep_alive": null,
|
||||
"mic_volume": 11,
|
||||
"chime_settings": {
|
||||
"enable": true,
|
||||
"type": 2,
|
||||
"duration": 10
|
||||
},
|
||||
"intercom_settings": {
|
||||
"ring_to_open": false,
|
||||
"predecessor": "{\"make\":\"Comelit\",\"model\":\"2738W\",\"wires\":2}",
|
||||
"config": "{\"intercom_type\": 2, \"number_of_wires\": 2, \"autounlock_enabled\": false, \"speaker_gain\": [-49, -35, -25, -21, -16, -9, -6, -3, 0, 3, 6, 9], \"digital\": {\"audio_amp\": 0, \"chg_en\": false, \"fast_chg\": false, \"bypass\": false, \"idle_lvl\": 32, \"ext_audio\": false, \"ext_audio_term\": 0, \"off_hk_tm\": 0, \"unlk_ka\": false, \"unlock\": {\"cap_tm\": 1000, \"rpl_tm\": 1500, \"gain\": 1000, \"cmp_thr\": 4000, \"lvl\": 25000, \"thr\": 30, \"thr2\": 0, \"offln\": false, \"ac\": true, \"bias\": \"h\", \"tx_pin\": \"TXD2\", \"ack\": 0, \"prot\": \"Comelit_SB2\", \"ask\": {\"f\": 25000, \"b\": 333}}, \"ring\": {\"cap_tm\": 40, \"rpl_tm\": 200, \"gain\": 2000, \"cmp_thr\": 4500, \"lvl\": 28000, \"thr\": 30, \"thr2\": 0, \"offln\": false, \"ac\": true, \"bias\": \"m\", \"tx_pin\": \"TXD2\", \"ack\": 0, \"prot\": \"Comelit_SB2\", \"ask\": {\"f\": 25000, \"b\": 333}}, \"hook_off\": {\"cap_tm\": 1000, \"rpl_tm\": 1500, \"gain\": 1000, \"cmp_thr\": 4000, \"lvl\": 25000, \"thr\": 30, \"thr2\": 0, \"offln\": false, \"ac\": true, \"bias\": \"h\", \"tx_pin\": \"TXD2\", \"ack\": 0, \"prot\": \"Comelit_SB2\", \"ask\": {\"f\": 25000, \"b\": 333}}, \"hook_on\": {\"cap_tm\": 1000, \"rpl_tm\": 1500, \"gain\": 1000, \"cmp_thr\": 4000, \"lvl\": 25000, \"thr\": 30, \"thr2\": 0, \"offln\": false, \"ac\": true, \"bias\": \"h\", \"tx_pin\": \"TXD2\", \"ack\": 0, \"prot\": \"Comelit_SB2\", \"ask\": {\"f\": 25000, \"b\": 333}}}}",
|
||||
"intercom_type": "DF",
|
||||
"replication": 1,
|
||||
"unlock_mode": 0
|
||||
},
|
||||
"voice_volume": 11
|
||||
},
|
||||
"alerts": {
|
||||
"connection": "online",
|
||||
"ota_status": "timeout"
|
||||
},
|
||||
"function": {
|
||||
"name": null
|
||||
},
|
||||
"subscribed": false,
|
||||
"battery_life": "52",
|
||||
"features": {
|
||||
"cfes_eligible": false,
|
||||
"motion_zone_recommendation": false,
|
||||
"motions_enabled": true,
|
||||
"show_recordings": true,
|
||||
"show_vod_settings": true,
|
||||
"rich_notifications_eligible": false,
|
||||
"show_offline_motion_events": false,
|
||||
"sheila_camera_eligible": null,
|
||||
"sheila_camera_processing_eligible": null,
|
||||
"dynamic_network_switching_eligible": false,
|
||||
"chime_auto_detect_capable": false,
|
||||
"missing_key_delivery_address": false,
|
||||
"show_24x7_lite": false,
|
||||
"recording_24x7_eligible": null
|
||||
},
|
||||
"metadata": {
|
||||
"ethernet": false,
|
||||
"legacy_fw_migrated": true,
|
||||
"imported_from_amazon": false,
|
||||
"is_sidewalk_gateway": false,
|
||||
"key_access_point_associated": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
[
|
||||
{
|
||||
"audio_jitter_buffer_ms": 0,
|
||||
"device_kind": "lpd_v1",
|
||||
"doorbot_description": "Front Door",
|
||||
"doorbot_id": 987652,
|
||||
"expires_in": 180,
|
||||
"id": 123456789,
|
||||
"id_str": "123456789",
|
||||
"kind": "ding",
|
||||
"motion": false,
|
||||
"now": 1490949469.5498993,
|
||||
"optimization_level": 1,
|
||||
"protocol": "sip",
|
||||
"sip_ding_id": "123456789",
|
||||
"sip_endpoints": null,
|
||||
"sip_from": "sip:abc123@ring.com",
|
||||
"sip_server_ip": "192.168.0.1",
|
||||
"sip_server_port": "15063",
|
||||
"sip_server_tls": "false",
|
||||
"sip_session_id": "28qdvjh-2043",
|
||||
"sip_to": "sip:28qdvjh-2043@192.168.0.1:15063;transport=tcp",
|
||||
"sip_token": "adecc24a428ed704b2d80adb621b5775755915529639e",
|
||||
"snapshot_url": "",
|
||||
"state": "ringing",
|
||||
"video_jitter_buffer_ms": 0
|
||||
},
|
||||
{
|
||||
"kind": "motion",
|
||||
"doorbot_id": 987654,
|
||||
"state": "ringing",
|
||||
"now": 1490949469.5498993,
|
||||
"expires_in": 180
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"device_health": {
|
||||
"average_signal_category": "good",
|
||||
"average_signal_strength": -39,
|
||||
"battery_percentage": 100,
|
||||
"battery_percentage_category": null,
|
||||
"battery_voltage": null,
|
||||
"battery_voltage_category": null,
|
||||
"firmware": "1.9.2",
|
||||
"firmware_out_of_date": false,
|
||||
"id": 987652,
|
||||
"latest_signal_category": "good",
|
||||
"latest_signal_strength": -58,
|
||||
"updated_at": "2017-09-30T07:05:03Z",
|
||||
"wifi_is_ring_network": false,
|
||||
"wifi_name": "ring_mock_wifi"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"answered": false,
|
||||
"created_at": "2018-03-05T15:03:40.000Z",
|
||||
"events": [],
|
||||
"favorite": false,
|
||||
"id": 987654321,
|
||||
"kind": "ding",
|
||||
"recording": { "status": "ready" },
|
||||
"snapshot_url": ""
|
||||
},
|
||||
{
|
||||
"answered": false,
|
||||
"created_at": "2017-03-05T15:03:40.000Z",
|
||||
"events": [],
|
||||
"favorite": false,
|
||||
"id": 987654321,
|
||||
"kind": "motion",
|
||||
"recording": { "status": "ready" },
|
||||
"snapshot_url": ""
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,116 @@
|
||||
[
|
||||
{
|
||||
"id": 7330963245622279024,
|
||||
"created_at": "2024-02-02T11:21:24.000Z",
|
||||
"answered": false,
|
||||
"events": [],
|
||||
"kind": "ding",
|
||||
"favorite": false,
|
||||
"snapshot_url": "",
|
||||
"recording": {
|
||||
"status": "ready"
|
||||
},
|
||||
"duration": 40.0,
|
||||
"cv_properties": {
|
||||
"person_detected": null,
|
||||
"stream_broken": false,
|
||||
"detection_type": null,
|
||||
"cv_triggers": null,
|
||||
"detection_types": null,
|
||||
"security_alerts": null
|
||||
},
|
||||
"properties": {
|
||||
"is_alexa": false,
|
||||
"is_sidewalk": false,
|
||||
"is_autoreply": false
|
||||
},
|
||||
"doorbot": {
|
||||
"id": 185036587,
|
||||
"description": "Ingresso",
|
||||
"type": "intercom_handset_audio"
|
||||
},
|
||||
"device_placement": null,
|
||||
"geolocation": null,
|
||||
"last_location": null,
|
||||
"siren": null,
|
||||
"is_e2ee": false,
|
||||
"had_subscription": false,
|
||||
"owner_id": "762490876"
|
||||
},
|
||||
{
|
||||
"id": 7323267080901445808,
|
||||
"created_at": "2024-01-12T17:36:28.000Z",
|
||||
"answered": true,
|
||||
"events": [],
|
||||
"kind": "on_demand",
|
||||
"favorite": false,
|
||||
"snapshot_url": "",
|
||||
"recording": {
|
||||
"status": "ready"
|
||||
},
|
||||
"duration": 13.0,
|
||||
"cv_properties": {
|
||||
"person_detected": null,
|
||||
"stream_broken": false,
|
||||
"detection_type": null,
|
||||
"cv_triggers": null,
|
||||
"detection_types": null,
|
||||
"security_alerts": null
|
||||
},
|
||||
"properties": {
|
||||
"is_alexa": false,
|
||||
"is_sidewalk": false,
|
||||
"is_autoreply": false
|
||||
},
|
||||
"doorbot": {
|
||||
"id": 185036587,
|
||||
"description": "Ingresso",
|
||||
"type": "intercom_handset_audio"
|
||||
},
|
||||
"device_placement": null,
|
||||
"geolocation": null,
|
||||
"last_location": null,
|
||||
"siren": null,
|
||||
"is_e2ee": false,
|
||||
"had_subscription": false,
|
||||
"owner_id": "762490876"
|
||||
},
|
||||
{
|
||||
"id": 7307399027047288688,
|
||||
"created_at": "2023-12-01T18:44:28.000Z",
|
||||
"answered": true,
|
||||
"events": [],
|
||||
"kind": "on_demand",
|
||||
"favorite": false,
|
||||
"snapshot_url": "",
|
||||
"recording": {
|
||||
"status": "ready"
|
||||
},
|
||||
"duration": 43.0,
|
||||
"cv_properties": {
|
||||
"person_detected": null,
|
||||
"stream_broken": false,
|
||||
"detection_type": null,
|
||||
"cv_triggers": null,
|
||||
"detection_types": null,
|
||||
"security_alerts": null
|
||||
},
|
||||
"properties": {
|
||||
"is_alexa": false,
|
||||
"is_sidewalk": false,
|
||||
"is_autoreply": false
|
||||
},
|
||||
"doorbot": {
|
||||
"id": 185036587,
|
||||
"description": "Ingresso",
|
||||
"type": "intercom_handset_audio"
|
||||
},
|
||||
"device_placement": null,
|
||||
"geolocation": null,
|
||||
"last_location": null,
|
||||
"siren": null,
|
||||
"is_e2ee": false,
|
||||
"had_subscription": false,
|
||||
"owner_id": "762490876"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,241 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[binary_sensor.front_door_ding-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'binary_sensor.front_door_ding',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.OCCUPANCY: 'occupancy'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Ding',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ding',
|
||||
'unique_id': '987654-ding',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.front_door_ding-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'occupancy',
|
||||
'friendly_name': 'Front Door Ding',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.front_door_ding',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.front_door_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'binary_sensor.front_door_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '987654-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.front_door_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'friendly_name': 'Front Door Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.front_door_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.front_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'binary_sensor.front_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '765432-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.front_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'friendly_name': 'Front Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.front_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.ingress_ding-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'binary_sensor.ingress_ding',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.OCCUPANCY: 'occupancy'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Ding',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ding',
|
||||
'unique_id': '185036587-ding',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.ingress_ding-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'occupancy',
|
||||
'friendly_name': 'Ingress Ding',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.ingress_ding',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.internal_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'binary_sensor.internal_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '345678-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[binary_sensor.internal_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'friendly_name': 'Internal Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.internal_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
@@ -0,0 +1,48 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[button.ingress_open_door-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'button',
|
||||
'entity_category': None,
|
||||
'entity_id': 'button.ingress_open_door',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Open door',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'open_door',
|
||||
'unique_id': '185036587-open_door',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[button.ingress_open_door-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Ingress Open door',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'button.ingress_open_door',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
318
home-assistant/tests/components/ring/snapshots/test_camera.ambr
Normal file
318
home-assistant/tests/components/ring/snapshots/test_camera.ambr
Normal file
@@ -0,0 +1,318 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[camera.front_door_last_recording-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.front_door_last_recording',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Last recording',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'last_recording',
|
||||
'unique_id': '987654-last_recording',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_door_last_recording-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.front_door_last_recording?token=1caab5c3b3',
|
||||
'friendly_name': 'Front Door Last recording',
|
||||
'last_video_id': None,
|
||||
'motion_detection': True,
|
||||
'supported_features': <CameraEntityFeature: 0>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.front_door_last_recording',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_door_live_view-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.front_door_live_view',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Live view',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'translation_key': 'live_view',
|
||||
'unique_id': '987654-live_view',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_door_live_view-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.front_door_live_view?token=1caab5c3b3',
|
||||
'friendly_name': 'Front Door Live view',
|
||||
'frontend_stream_type': <StreamType.WEB_RTC: 'web_rtc'>,
|
||||
'last_video_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.front_door_live_view',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_last_recording-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.front_last_recording',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Last recording',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'last_recording',
|
||||
'unique_id': '765432-last_recording',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_last_recording-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.front_last_recording?token=1caab5c3b3',
|
||||
'friendly_name': 'Front Last recording',
|
||||
'last_video_id': None,
|
||||
'supported_features': <CameraEntityFeature: 0>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.front_last_recording',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_live_view-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.front_live_view',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Live view',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'translation_key': 'live_view',
|
||||
'unique_id': '765432-live_view',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.front_live_view-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.front_live_view?token=1caab5c3b3',
|
||||
'friendly_name': 'Front Live view',
|
||||
'frontend_stream_type': <StreamType.WEB_RTC: 'web_rtc'>,
|
||||
'last_video_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.front_live_view',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.internal_last_recording-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.internal_last_recording',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Last recording',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'last_recording',
|
||||
'unique_id': '345678-last_recording',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.internal_last_recording-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.internal_last_recording?token=1caab5c3b3',
|
||||
'friendly_name': 'Internal Last recording',
|
||||
'last_video_id': None,
|
||||
'motion_detection': True,
|
||||
'supported_features': <CameraEntityFeature: 0>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.internal_last_recording',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.internal_live_view-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'camera',
|
||||
'entity_category': None,
|
||||
'entity_id': 'camera.internal_live_view',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Live view',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'translation_key': 'live_view',
|
||||
'unique_id': '345678-live_view',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[camera.internal_live_view-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'access_token': '1caab5c3b3',
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'entity_picture': '/api/camera_proxy/camera.internal_live_view?token=1caab5c3b3',
|
||||
'friendly_name': 'Internal Live view',
|
||||
'frontend_stream_type': <StreamType.WEB_RTC: 'web_rtc'>,
|
||||
'last_video_id': None,
|
||||
'supported_features': <CameraEntityFeature: 2>,
|
||||
'video_url': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'camera.internal_live_view',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'idle',
|
||||
})
|
||||
# ---
|
||||
@@ -0,0 +1,667 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'device_data': list([
|
||||
dict({
|
||||
'address': '**REDACTED**',
|
||||
'alerts': dict({
|
||||
'connection': 'online',
|
||||
}),
|
||||
'description': '**REDACTED**',
|
||||
'device_id': '**REDACTED**',
|
||||
'do_not_disturb': dict({
|
||||
'seconds_left': 0,
|
||||
}),
|
||||
'features': dict({
|
||||
'ringtones_enabled': True,
|
||||
}),
|
||||
'firmware_version': '1.2.3',
|
||||
'id': '**REDACTED**',
|
||||
'kind': 'chime',
|
||||
'latitude': '**REDACTED**',
|
||||
'longitude': '**REDACTED**',
|
||||
'owned': True,
|
||||
'owner': dict({
|
||||
'email': '**REDACTED**',
|
||||
'first_name': '**REDACTED**',
|
||||
'id': '**REDACTED**',
|
||||
'last_name': '**REDACTED**',
|
||||
}),
|
||||
'settings': dict({
|
||||
'ding_audio_id': None,
|
||||
'ding_audio_user_id': None,
|
||||
'motion_audio_id': None,
|
||||
'motion_audio_user_id': None,
|
||||
'volume': 2,
|
||||
}),
|
||||
'time_zone': 'America/New_York',
|
||||
}),
|
||||
dict({
|
||||
'address': '**REDACTED**',
|
||||
'alerts': dict({
|
||||
'connection': 'online',
|
||||
}),
|
||||
'battery_life': 4081,
|
||||
'description': '**REDACTED**',
|
||||
'device_id': '**REDACTED**',
|
||||
'external_connection': False,
|
||||
'features': dict({
|
||||
'advanced_motion_enabled': False,
|
||||
'motion_message_enabled': False,
|
||||
'motions_enabled': True,
|
||||
'people_only_enabled': False,
|
||||
'shadow_correction_enabled': False,
|
||||
'show_recordings': True,
|
||||
}),
|
||||
'firmware_version': '1.4.26',
|
||||
'id': '**REDACTED**',
|
||||
'kind': 'lpd_v1',
|
||||
'latitude': '**REDACTED**',
|
||||
'longitude': '**REDACTED**',
|
||||
'motion_snooze': None,
|
||||
'owned': True,
|
||||
'owner': dict({
|
||||
'email': '**REDACTED**',
|
||||
'first_name': '**REDACTED**',
|
||||
'id': '**REDACTED**',
|
||||
'last_name': '**REDACTED**',
|
||||
}),
|
||||
'settings': dict({
|
||||
'chime_settings': dict({
|
||||
'duration': 3,
|
||||
'enable': True,
|
||||
'type': 0,
|
||||
}),
|
||||
'doorbell_volume': 1,
|
||||
'enable_vod': True,
|
||||
'live_view_preset_profile': 'highest',
|
||||
'live_view_presets': list([
|
||||
'low',
|
||||
'middle',
|
||||
'high',
|
||||
'highest',
|
||||
]),
|
||||
'motion_announcement': False,
|
||||
'motion_detection_enabled': True,
|
||||
'motion_snooze_preset_profile': 'low',
|
||||
'motion_snooze_presets': list([
|
||||
'null',
|
||||
'low',
|
||||
'medium',
|
||||
'high',
|
||||
]),
|
||||
}),
|
||||
'subscribed': True,
|
||||
'subscribed_motions': True,
|
||||
'time_zone': 'America/New_York',
|
||||
}),
|
||||
dict({
|
||||
'address': '**REDACTED**',
|
||||
'alerts': dict({
|
||||
'connection': 'online',
|
||||
}),
|
||||
'battery_life': 80,
|
||||
'description': '**REDACTED**',
|
||||
'device_id': '**REDACTED**',
|
||||
'external_connection': False,
|
||||
'features': dict({
|
||||
'advanced_motion_enabled': False,
|
||||
'motion_message_enabled': False,
|
||||
'motions_enabled': True,
|
||||
'night_vision_enabled': False,
|
||||
'people_only_enabled': False,
|
||||
'shadow_correction_enabled': False,
|
||||
'show_recordings': True,
|
||||
}),
|
||||
'firmware_version': '1.9.3',
|
||||
'id': '**REDACTED**',
|
||||
'kind': 'hp_cam_v1',
|
||||
'latitude': '**REDACTED**',
|
||||
'led_status': 'off',
|
||||
'location_id': None,
|
||||
'longitude': '**REDACTED**',
|
||||
'motion_snooze': dict({
|
||||
'scheduled': True,
|
||||
}),
|
||||
'night_mode_status': 'false',
|
||||
'owned': True,
|
||||
'owner': dict({
|
||||
'email': '**REDACTED**',
|
||||
'first_name': '**REDACTED**',
|
||||
'id': '**REDACTED**',
|
||||
'last_name': '**REDACTED**',
|
||||
}),
|
||||
'ring_cam_light_installed': 'false',
|
||||
'ring_id': None,
|
||||
'settings': dict({
|
||||
'chime_settings': dict({
|
||||
'duration': 10,
|
||||
'enable': True,
|
||||
'type': 0,
|
||||
}),
|
||||
'doorbell_volume': 11,
|
||||
'enable_vod': True,
|
||||
'floodlight_settings': dict({
|
||||
'duration': 30,
|
||||
'priority': 0,
|
||||
}),
|
||||
'light_schedule_settings': dict({
|
||||
'end_hour': 0,
|
||||
'end_minute': 0,
|
||||
'start_hour': 0,
|
||||
'start_minute': 0,
|
||||
}),
|
||||
'live_view_preset_profile': 'highest',
|
||||
'live_view_presets': list([
|
||||
'low',
|
||||
'middle',
|
||||
'high',
|
||||
'highest',
|
||||
]),
|
||||
'motion_announcement': False,
|
||||
'motion_detection_enabled': False,
|
||||
'motion_snooze_preset_profile': 'low',
|
||||
'motion_snooze_presets': list([
|
||||
'none',
|
||||
'low',
|
||||
'medium',
|
||||
'high',
|
||||
]),
|
||||
'motion_zones': dict({
|
||||
'active_motion_filter': 1,
|
||||
'advanced_object_settings': dict({
|
||||
'human_detection_confidence': dict({
|
||||
'day': 0.7,
|
||||
'night': 0.7,
|
||||
}),
|
||||
'motion_zone_overlap': dict({
|
||||
'day': 0.1,
|
||||
'night': 0.2,
|
||||
}),
|
||||
'object_size_maximum': dict({
|
||||
'day': 0.8,
|
||||
'night': 0.8,
|
||||
}),
|
||||
'object_size_minimum': dict({
|
||||
'day': 0.03,
|
||||
'night': 0.05,
|
||||
}),
|
||||
'object_time_overlap': dict({
|
||||
'day': 0.1,
|
||||
'night': 0.6,
|
||||
}),
|
||||
}),
|
||||
'enable_audio': False,
|
||||
'pir_settings': dict({
|
||||
'sensitivity1': 1,
|
||||
'sensitivity2': 1,
|
||||
'sensitivity3': 1,
|
||||
'zone_mask': 6,
|
||||
}),
|
||||
'sensitivity': 5,
|
||||
'zone1': dict({
|
||||
'name': 'Zone 1',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
'zone2': dict({
|
||||
'name': 'Zone 2',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
'zone3': dict({
|
||||
'name': 'Zone 3',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'pir_motion_zones': list([
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
]),
|
||||
'pir_settings': dict({
|
||||
'sensitivity1': 1,
|
||||
'sensitivity2': 1,
|
||||
'sensitivity3': 1,
|
||||
'zone_mask': 6,
|
||||
}),
|
||||
'stream_setting': 0,
|
||||
'video_settings': dict({
|
||||
'ae_level': 0,
|
||||
'birton': None,
|
||||
'brightness': 0,
|
||||
'contrast': 64,
|
||||
'saturation': 80,
|
||||
}),
|
||||
}),
|
||||
'siren_status': dict({
|
||||
'seconds_remaining': 0,
|
||||
}),
|
||||
'stolen': False,
|
||||
'subscribed': True,
|
||||
'subscribed_motions': True,
|
||||
'time_zone': 'America/New_York',
|
||||
}),
|
||||
dict({
|
||||
'address': '**REDACTED**',
|
||||
'alerts': dict({
|
||||
'connection': 'online',
|
||||
}),
|
||||
'battery_life': 80,
|
||||
'description': '**REDACTED**',
|
||||
'device_id': '**REDACTED**',
|
||||
'external_connection': False,
|
||||
'features': dict({
|
||||
'advanced_motion_enabled': False,
|
||||
'motion_message_enabled': False,
|
||||
'motions_enabled': True,
|
||||
'night_vision_enabled': False,
|
||||
'people_only_enabled': False,
|
||||
'shadow_correction_enabled': False,
|
||||
'show_recordings': True,
|
||||
}),
|
||||
'firmware_version': '1.9.3',
|
||||
'id': '**REDACTED**',
|
||||
'kind': 'hp_cam_v1',
|
||||
'latitude': '**REDACTED**',
|
||||
'led_status': 'on',
|
||||
'location_id': None,
|
||||
'longitude': '**REDACTED**',
|
||||
'motion_snooze': dict({
|
||||
'scheduled': True,
|
||||
}),
|
||||
'night_mode_status': 'false',
|
||||
'owned': True,
|
||||
'owner': dict({
|
||||
'email': '**REDACTED**',
|
||||
'first_name': '**REDACTED**',
|
||||
'id': '**REDACTED**',
|
||||
'last_name': '**REDACTED**',
|
||||
}),
|
||||
'ring_cam_light_installed': 'false',
|
||||
'ring_id': None,
|
||||
'settings': dict({
|
||||
'chime_settings': dict({
|
||||
'duration': 10,
|
||||
'enable': True,
|
||||
'type': 0,
|
||||
}),
|
||||
'doorbell_volume': 11,
|
||||
'enable_vod': True,
|
||||
'floodlight_settings': dict({
|
||||
'duration': 30,
|
||||
'priority': 0,
|
||||
}),
|
||||
'light_schedule_settings': dict({
|
||||
'end_hour': 0,
|
||||
'end_minute': 0,
|
||||
'start_hour': 0,
|
||||
'start_minute': 0,
|
||||
}),
|
||||
'live_view_preset_profile': 'highest',
|
||||
'live_view_presets': list([
|
||||
'low',
|
||||
'middle',
|
||||
'high',
|
||||
'highest',
|
||||
]),
|
||||
'motion_announcement': False,
|
||||
'motion_detection_enabled': True,
|
||||
'motion_snooze_preset_profile': 'low',
|
||||
'motion_snooze_presets': list([
|
||||
'none',
|
||||
'low',
|
||||
'medium',
|
||||
'high',
|
||||
]),
|
||||
'motion_zones': dict({
|
||||
'active_motion_filter': 1,
|
||||
'advanced_object_settings': dict({
|
||||
'human_detection_confidence': dict({
|
||||
'day': 0.7,
|
||||
'night': 0.7,
|
||||
}),
|
||||
'motion_zone_overlap': dict({
|
||||
'day': 0.1,
|
||||
'night': 0.2,
|
||||
}),
|
||||
'object_size_maximum': dict({
|
||||
'day': 0.8,
|
||||
'night': 0.8,
|
||||
}),
|
||||
'object_size_minimum': dict({
|
||||
'day': 0.03,
|
||||
'night': 0.05,
|
||||
}),
|
||||
'object_time_overlap': dict({
|
||||
'day': 0.1,
|
||||
'night': 0.6,
|
||||
}),
|
||||
}),
|
||||
'enable_audio': False,
|
||||
'pir_settings': dict({
|
||||
'sensitivity1': 1,
|
||||
'sensitivity2': 1,
|
||||
'sensitivity3': 1,
|
||||
'zone_mask': 6,
|
||||
}),
|
||||
'sensitivity': 5,
|
||||
'zone1': dict({
|
||||
'name': 'Zone 1',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
'zone2': dict({
|
||||
'name': 'Zone 2',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
'zone3': dict({
|
||||
'name': 'Zone 3',
|
||||
'state': 2,
|
||||
'vertex1': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex2': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex3': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex4': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex5': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex6': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex7': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
'vertex8': dict({
|
||||
'x': 0.0,
|
||||
'y': 0.0,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'pir_motion_zones': list([
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
]),
|
||||
'pir_settings': dict({
|
||||
'sensitivity1': 1,
|
||||
'sensitivity2': 1,
|
||||
'sensitivity3': 1,
|
||||
'zone_mask': 6,
|
||||
}),
|
||||
'stream_setting': 0,
|
||||
'video_settings': dict({
|
||||
'ae_level': 0,
|
||||
'birton': None,
|
||||
'brightness': 0,
|
||||
'contrast': 64,
|
||||
'saturation': 80,
|
||||
}),
|
||||
}),
|
||||
'siren_status': dict({
|
||||
'seconds_remaining': 30,
|
||||
}),
|
||||
'stolen': False,
|
||||
'subscribed': True,
|
||||
'subscribed_motions': True,
|
||||
'time_zone': 'America/New_York',
|
||||
}),
|
||||
dict({
|
||||
'alerts': dict({
|
||||
'connection': 'online',
|
||||
'ota_status': 'timeout',
|
||||
}),
|
||||
'battery_life': '52',
|
||||
'created_at': '2023-12-01T18:05:25Z',
|
||||
'deactivated_at': None,
|
||||
'description': '**REDACTED**',
|
||||
'device_id': '**REDACTED**',
|
||||
'features': dict({
|
||||
'cfes_eligible': False,
|
||||
'chime_auto_detect_capable': False,
|
||||
'dynamic_network_switching_eligible': False,
|
||||
'missing_key_delivery_address': False,
|
||||
'motion_zone_recommendation': False,
|
||||
'motions_enabled': True,
|
||||
'recording_24x7_eligible': None,
|
||||
'rich_notifications_eligible': False,
|
||||
'sheila_camera_eligible': None,
|
||||
'sheila_camera_processing_eligible': None,
|
||||
'show_24x7_lite': False,
|
||||
'show_offline_motion_events': False,
|
||||
'show_recordings': True,
|
||||
'show_vod_settings': True,
|
||||
}),
|
||||
'firmware_version': 'Up to Date',
|
||||
'function': dict({
|
||||
'name': None,
|
||||
}),
|
||||
'id': '**REDACTED**',
|
||||
'is_sidewalk_gateway': False,
|
||||
'kind': 'intercom_handset_audio',
|
||||
'location_id': '**REDACTED**',
|
||||
'metadata': dict({
|
||||
'ethernet': False,
|
||||
'imported_from_amazon': False,
|
||||
'is_sidewalk_gateway': False,
|
||||
'key_access_point_associated': True,
|
||||
'legacy_fw_migrated': True,
|
||||
}),
|
||||
'owned': True,
|
||||
'owner': dict({
|
||||
'email': '',
|
||||
'first_name': '',
|
||||
'id': '**REDACTED**',
|
||||
'last_name': '',
|
||||
}),
|
||||
'ring_net_id': None,
|
||||
'schema_id': None,
|
||||
'settings': dict({
|
||||
'chime_settings': dict({
|
||||
'duration': 10,
|
||||
'enable': True,
|
||||
'type': 2,
|
||||
}),
|
||||
'doorbell_volume': 8,
|
||||
'enable_chime': 1,
|
||||
'enable_log': 1,
|
||||
'features_confirmed': 5,
|
||||
'forced_keep_alive': None,
|
||||
'intercom_settings': dict({
|
||||
'config': '{"intercom_type": 2, "number_of_wires": 2, "autounlock_enabled": false, "speaker_gain": [-49, -35, -25, -21, -16, -9, -6, -3, 0, 3, 6, 9], "digital": {"audio_amp": 0, "chg_en": false, "fast_chg": false, "bypass": false, "idle_lvl": 32, "ext_audio": false, "ext_audio_term": 0, "off_hk_tm": 0, "unlk_ka": false, "unlock": {"cap_tm": 1000, "rpl_tm": 1500, "gain": 1000, "cmp_thr": 4000, "lvl": 25000, "thr": 30, "thr2": 0, "offln": false, "ac": true, "bias": "h", "tx_pin": "TXD2", "ack": 0, "prot": "Comelit_SB2", "ask": {"f": 25000, "b": 333}}, "ring": {"cap_tm": 40, "rpl_tm": 200, "gain": 2000, "cmp_thr": 4500, "lvl": 28000, "thr": 30, "thr2": 0, "offln": false, "ac": true, "bias": "m", "tx_pin": "TXD2", "ack": 0, "prot": "Comelit_SB2", "ask": {"f": 25000, "b": 333}}, "hook_off": {"cap_tm": 1000, "rpl_tm": 1500, "gain": 1000, "cmp_thr": 4000, "lvl": 25000, "thr": 30, "thr2": 0, "offln": false, "ac": true, "bias": "h", "tx_pin": "TXD2", "ack": 0, "prot": "Comelit_SB2", "ask": {"f": 25000, "b": 333}}, "hook_on": {"cap_tm": 1000, "rpl_tm": 1500, "gain": 1000, "cmp_thr": 4000, "lvl": 25000, "thr": 30, "thr2": 0, "offln": false, "ac": true, "bias": "h", "tx_pin": "TXD2", "ack": 0, "prot": "Comelit_SB2", "ask": {"f": 25000, "b": 333}}}}',
|
||||
'intercom_type': 'DF',
|
||||
'predecessor': '{"make":"Comelit","model":"2738W","wires":2}',
|
||||
'replication': 1,
|
||||
'ring_to_open': False,
|
||||
'unlock_mode': 0,
|
||||
}),
|
||||
'keep_alive': None,
|
||||
'keep_alive_auto': 45.0,
|
||||
'mic_volume': 11,
|
||||
'recording_enabled': False,
|
||||
'recording_ttl': 180,
|
||||
'server_domain': 'fw.ring.com',
|
||||
'server_ip': None,
|
||||
'show_recordings': True,
|
||||
'theft_alarm_enable': 0,
|
||||
'use_cached_domain': 1,
|
||||
'use_server_ip': 0,
|
||||
'voice_volume': 11,
|
||||
}),
|
||||
'subscribed': False,
|
||||
'time_zone': 'Europe/Rome',
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
337
home-assistant/tests/components/ring/snapshots/test_event.ambr
Normal file
337
home-assistant/tests/components/ring/snapshots/test_event.ambr
Normal file
@@ -0,0 +1,337 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[event.front_door_ding-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'ding',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.front_door_ding',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.DOORBELL: 'doorbell'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Ding',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ding',
|
||||
'unique_id': '987654-ding',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.front_door_ding-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'doorbell',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'ding',
|
||||
]),
|
||||
'friendly_name': 'Front Door Ding',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.front_door_ding',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.front_door_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.front_door_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '987654-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.front_door_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
'friendly_name': 'Front Door Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.front_door_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.front_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.front_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '765432-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.front_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
'friendly_name': 'Front Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.front_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.ingress_ding-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'ding',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.ingress_ding',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.DOORBELL: 'doorbell'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Ding',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ding',
|
||||
'unique_id': '185036587-ding',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.ingress_ding-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'doorbell',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'ding',
|
||||
]),
|
||||
'friendly_name': 'Ingress Ding',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.ingress_ding',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.ingress_intercom_unlock-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'intercom_unlock',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.ingress_intercom_unlock',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.BUTTON: 'button'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Intercom unlock',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'intercom_unlock',
|
||||
'unique_id': '185036587-intercom_unlock',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.ingress_intercom_unlock-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'button',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'intercom_unlock',
|
||||
]),
|
||||
'friendly_name': 'Ingress Intercom unlock',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.ingress_intercom_unlock',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.internal_motion-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.internal_motion',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <EventDeviceClass.MOTION: 'motion'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion',
|
||||
'unique_id': '345678-motion',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[event.internal_motion-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'device_class': 'motion',
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'motion',
|
||||
]),
|
||||
'friendly_name': 'Internal Motion',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.internal_motion',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
113
home-assistant/tests/components/ring/snapshots/test_light.ambr
Normal file
113
home-assistant/tests/components/ring/snapshots/test_light.ambr
Normal file
@@ -0,0 +1,113 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[light.front_light-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'supported_color_modes': list([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'light',
|
||||
'entity_category': None,
|
||||
'entity_id': 'light.front_light',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Light',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'light',
|
||||
'unique_id': '765432',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[light.front_light-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'color_mode': None,
|
||||
'friendly_name': 'Front Light',
|
||||
'supported_color_modes': list([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
'supported_features': <LightEntityFeature: 0>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'light.front_light',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[light.internal_light-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'supported_color_modes': list([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'light',
|
||||
'entity_category': None,
|
||||
'entity_id': 'light.internal_light',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Light',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'light',
|
||||
'unique_id': '345678',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[light.internal_light-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'color_mode': <ColorMode.ONOFF: 'onoff'>,
|
||||
'friendly_name': 'Internal Light',
|
||||
'supported_color_modes': list([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
'supported_features': <LightEntityFeature: 0>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'light.internal_light',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
393
home-assistant/tests/components/ring/snapshots/test_number.ambr
Normal file
393
home-assistant/tests/components/ring/snapshots/test_number.ambr
Normal file
@@ -0,0 +1,393 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[number.downstairs_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.downstairs_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'volume',
|
||||
'unique_id': '123456-volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.downstairs_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Downstairs Volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.downstairs_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '2.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.front_door_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.front_door_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'volume',
|
||||
'unique_id': '987654-volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.front_door_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Door Volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.front_door_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '1.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.front_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.front_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'volume',
|
||||
'unique_id': '765432-volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.front_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.front_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '11.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_doorbell_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 8,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.ingress_doorbell_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Doorbell volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'doorbell_volume',
|
||||
'unique_id': '185036587-doorbell_volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_doorbell_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Ingress Doorbell volume',
|
||||
'max': 8,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.ingress_doorbell_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '8.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_mic_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.ingress_mic_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Mic volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'mic_volume',
|
||||
'unique_id': '185036587-mic_volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_mic_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Ingress Mic volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.ingress_mic_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '11.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_voice_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.ingress_voice_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Voice volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'voice_volume',
|
||||
'unique_id': '185036587-voice_volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.ingress_voice_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Ingress Voice volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.ingress_voice_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '11.0',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.internal_volume-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.internal_volume',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Volume',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'volume',
|
||||
'unique_id': '345678-volume',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[number.internal_volume-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Internal Volume',
|
||||
'max': 11,
|
||||
'min': 0,
|
||||
'mode': <NumberMode.SLIDER: 'slider'>,
|
||||
'step': 1,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.internal_volume',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '11.0',
|
||||
})
|
||||
# ---
|
||||
1116
home-assistant/tests/components/ring/snapshots/test_sensor.ambr
Normal file
1116
home-assistant/tests/components/ring/snapshots/test_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
154
home-assistant/tests/components/ring/snapshots/test_siren.ambr
Normal file
154
home-assistant/tests/components/ring/snapshots/test_siren.ambr
Normal file
@@ -0,0 +1,154 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[siren.downstairs_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'available_tones': list([
|
||||
'ding',
|
||||
'motion',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'siren',
|
||||
'entity_category': None,
|
||||
'entity_id': 'siren.downstairs_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <SirenEntityFeature: 5>,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '123456-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.downstairs_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'available_tones': list([
|
||||
'ding',
|
||||
'motion',
|
||||
]),
|
||||
'friendly_name': 'Downstairs Siren',
|
||||
'supported_features': <SirenEntityFeature: 5>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'siren.downstairs_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.front_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'siren',
|
||||
'entity_category': None,
|
||||
'entity_id': 'siren.front_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <SirenEntityFeature: 3>,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '765432',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.front_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Siren',
|
||||
'supported_features': <SirenEntityFeature: 3>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'siren.front_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.internal_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'siren',
|
||||
'entity_category': None,
|
||||
'entity_id': 'siren.internal_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <SirenEntityFeature: 3>,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '345678',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.internal_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Internal Siren',
|
||||
'supported_features': <SirenEntityFeature: 3>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'siren.internal_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
283
home-assistant/tests/components/ring/snapshots/test_switch.ambr
Normal file
283
home-assistant/tests/components/ring/snapshots/test_switch.ambr
Normal file
@@ -0,0 +1,283 @@
|
||||
# serializer version: 1
|
||||
# name: test_states[switch.front_door_in_home_chime-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.front_door_in_home_chime',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'In-home chime',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'in_home_chime',
|
||||
'unique_id': '987654-in_home_chime',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_door_in_home_chime-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Door In-home chime',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.front_door_in_home_chime',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_door_motion_detection-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.front_door_motion_detection',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion detection',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion_detection',
|
||||
'unique_id': '987654-motion_detection',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_door_motion_detection-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Door Motion detection',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.front_door_motion_detection',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_motion_detection-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.front_motion_detection',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion detection',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion_detection',
|
||||
'unique_id': '765432-motion_detection',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_motion_detection-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Motion detection',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.front_motion_detection',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.front_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '765432-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Siren',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.front_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_motion_detection-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.internal_motion_detection',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Motion detection',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'motion_detection',
|
||||
'unique_id': '345678-motion_detection',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_motion_detection-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Internal Motion detection',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.internal_motion_detection',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.internal_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '345678-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Internal Siren',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.internal_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
243
home-assistant/tests/components/ring/test_binary_sensor.py
Normal file
243
home-assistant/tests/components/ring/test_binary_sensor.py
Normal file
@@ -0,0 +1,243 @@
|
||||
"""The tests for the Ring binary sensor platform."""
|
||||
|
||||
import time
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
from ring_doorbell import Ring
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.ring.binary_sensor import RingEvent
|
||||
from homeassistant.components.ring.const import DOMAIN
|
||||
from homeassistant.components.ring.coordinator import RingEventListener
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import MockConfigEntry, setup_automation, setup_platform
|
||||
from .device_mocks import (
|
||||
FRONT_DEVICE_ID,
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
INGRESS_DEVICE_ID,
|
||||
INTERNAL_DEVICE_ID,
|
||||
)
|
||||
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_deprecated_binary_sensor_entities(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
):
|
||||
"""Create the entity so it is not ignored by the deprecation check."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
def create_entry(device_name, device_id, key):
|
||||
unique_id = f"{device_id}-{key}"
|
||||
|
||||
entity_registry.async_get_or_create(
|
||||
domain=BINARY_SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id=f"{device_name}_{key}",
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
|
||||
create_entry("front", FRONT_DEVICE_ID, "motion")
|
||||
create_entry("front_door", FRONT_DOOR_DEVICE_ID, "motion")
|
||||
create_entry("internal", INTERNAL_DEVICE_ID, "motion")
|
||||
|
||||
create_entry("ingress", INGRESS_DEVICE_ID, "ding")
|
||||
create_entry("front_door", FRONT_DOOR_DEVICE_ID, "ding")
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
create_deprecated_binary_sensor_entities,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
await setup_platform(hass, Platform.BINARY_SENSOR)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_id", "device_name", "alert_kind", "device_class"),
|
||||
[
|
||||
pytest.param(
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
"front_door",
|
||||
"motion",
|
||||
"motion",
|
||||
id="front_door_motion",
|
||||
),
|
||||
pytest.param(
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
"front_door",
|
||||
"ding",
|
||||
"occupancy",
|
||||
id="front_door_ding",
|
||||
),
|
||||
pytest.param(
|
||||
INGRESS_DEVICE_ID, "ingress", "ding", "occupancy", id="ingress_ding"
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_binary_sensor(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
mock_ring_client: Ring,
|
||||
mock_ring_event_listener_class: RingEventListener,
|
||||
entity_registry: er.EntityRegistry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
device_id: int,
|
||||
device_name: str,
|
||||
alert_kind: str,
|
||||
device_class: str,
|
||||
) -> None:
|
||||
"""Test the Ring binary sensors."""
|
||||
# Create the entity so it is not ignored by the deprecation check
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
entity_id = f"binary_sensor.{device_name}_{alert_kind}"
|
||||
unique_id = f"{device_id}-{alert_kind}"
|
||||
|
||||
entity_registry.async_get_or_create(
|
||||
domain=BINARY_SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id=f"{device_name}_{alert_kind}",
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
on_event_cb = mock_ring_event_listener_class.return_value.add_notification_callback.call_args.args[
|
||||
0
|
||||
]
|
||||
|
||||
# Default state is set to off
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_OFF
|
||||
assert state.attributes["device_class"] == device_class
|
||||
|
||||
# A new alert sets to on
|
||||
event = RingEvent(
|
||||
1234546, device_id, "Foo", "Bar", time.time(), 180, kind=alert_kind, state=None
|
||||
)
|
||||
mock_ring_client.active_alerts.return_value = [event]
|
||||
on_event_cb(event)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
# Test that another event resets the expiry callback
|
||||
freezer.tick(60)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
event = RingEvent(
|
||||
1234546, device_id, "Foo", "Bar", time.time(), 180, kind=alert_kind, state=None
|
||||
)
|
||||
mock_ring_client.active_alerts.return_value = [event]
|
||||
on_event_cb(event)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
freezer.tick(120)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
# Test the second alert has expired
|
||||
freezer.tick(60)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_binary_sensor_not_exists_with_deprecation(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
mock_ring_client: Ring,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test the deprecated Ring binary sensors are deleted or raise issues."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
entity_id = "binary_sensor.front_door_motion"
|
||||
|
||||
assert not hass.states.get(entity_id)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
assert not entity_registry.async_get(entity_id)
|
||||
assert not er.async_entries_for_config_entry(
|
||||
entity_registry, mock_config_entry.entry_id
|
||||
)
|
||||
assert not hass.states.get(entity_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_disabled", "entity_has_automations"),
|
||||
[
|
||||
pytest.param(False, False, id="without-automations"),
|
||||
pytest.param(False, True, id="with-automations"),
|
||||
pytest.param(True, False, id="disabled"),
|
||||
],
|
||||
)
|
||||
async def test_binary_sensor_exists_with_deprecation(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
mock_ring_client: Ring,
|
||||
entity_registry: er.EntityRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
entity_disabled: bool,
|
||||
entity_has_automations: bool,
|
||||
) -> None:
|
||||
"""Test the deprecated Ring binary sensors are deleted or raise issues."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
entity_id = "binary_sensor.front_door_motion"
|
||||
unique_id = f"{FRONT_DOOR_DEVICE_ID}-motion"
|
||||
issue_id = f"deprecated_entity_{entity_id}_automation.test_automation"
|
||||
|
||||
if entity_has_automations:
|
||||
await setup_automation(hass, "test_automation", entity_id)
|
||||
|
||||
entity = entity_registry.async_get_or_create(
|
||||
domain=BINARY_SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id="front_door_motion",
|
||||
config_entry=mock_config_entry,
|
||||
disabled_by=er.RegistryEntryDisabler.USER if entity_disabled else None,
|
||||
)
|
||||
assert entity.entity_id == entity_id
|
||||
assert not hass.states.get(entity_id)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
entity = entity_registry.async_get(entity_id)
|
||||
# entity and state will be none if removed from registry
|
||||
assert (entity is None) == entity_disabled
|
||||
assert (hass.states.get(entity_id) is None) == entity_disabled
|
||||
|
||||
assert (
|
||||
issue_registry.async_get_issue(DOMAIN, issue_id) is not None
|
||||
) == entity_has_automations
|
||||
45
home-assistant/tests/components/ring/test_button.py
Normal file
45
home-assistant/tests/components/ring/test_button.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""The tests for the Ring button platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.BUTTON)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_button_opens_door(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
) -> None:
|
||||
"""Tests the door open button works correctly."""
|
||||
await setup_platform(hass, Platform.BUTTON)
|
||||
|
||||
mock_intercom = mock_ring_devices.get_device(185036587)
|
||||
mock_intercom.async_open_door.assert_not_called()
|
||||
|
||||
await hass.services.async_call(
|
||||
"button", "press", {"entity_id": "button.ingress_open_door"}, blocking=True
|
||||
)
|
||||
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
mock_intercom.async_open_door.assert_called_once()
|
||||
465
home-assistant/tests/components/ring/test_camera.py
Normal file
465
home-assistant/tests/components/ring/test_camera.py
Normal file
@@ -0,0 +1,465 @@
|
||||
"""The tests for the Ring switch platform."""
|
||||
|
||||
import logging
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
from aiohttp.test_utils import make_mocked_request
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from ring_doorbell.webrtcstream import RingWebRtcMessage
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.camera import (
|
||||
CameraEntityFeature,
|
||||
StreamType,
|
||||
async_get_image,
|
||||
async_get_mjpeg_stream,
|
||||
get_camera_from_entity_id,
|
||||
)
|
||||
from homeassistant.components.ring.camera import FORCE_REFRESH_INTERVAL
|
||||
from homeassistant.components.ring.const import SCAN_INTERVAL
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
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.util.aiohttp import MockStreamReader
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
from .device_mocks import FRONT_DEVICE_ID
|
||||
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
SMALLEST_VALID_JPEG = (
|
||||
"ffd8ffe000104a46494600010101004800480000ffdb00430003020202020203020202030303030406040404040408060"
|
||||
"6050609080a0a090809090a0c0f0c0a0b0e0b09090d110d0e0f101011100a0c12131210130f101010ffc9000b08000100"
|
||||
"0101011100ffcc000600101005ffda0008010100003f00d2cf20ffd9"
|
||||
)
|
||||
SMALLEST_VALID_JPEG_BYTES = bytes.fromhex(SMALLEST_VALID_JPEG)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
# Patch getrandbits so the access_token doesn't change on camera attributes
|
||||
with patch("random.SystemRandom.getrandbits", return_value=123123123123):
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_name", "expected_state", "friendly_name"),
|
||||
[
|
||||
("camera.internal_last_recording", True, "Internal Last recording"),
|
||||
("camera.front_last_recording", None, "Front Last recording"),
|
||||
],
|
||||
ids=["On", "Off"],
|
||||
)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_camera_motion_detection_state_reports_correctly(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
entity_name,
|
||||
expected_state,
|
||||
friendly_name,
|
||||
) -> None:
|
||||
"""Tests that the initial state of a device that should be off is correct."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
state = hass.states.get(entity_name)
|
||||
assert state.attributes.get("motion_detection") is expected_state
|
||||
assert state.attributes.get("friendly_name") == friendly_name
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_camera_motion_detection_can_be_turned_on_and_off(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
) -> None:
|
||||
"""Tests the siren turns on correctly."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state.attributes.get("motion_detection") is not True
|
||||
|
||||
await hass.services.async_call(
|
||||
"camera",
|
||||
"enable_motion_detection",
|
||||
{"entity_id": "camera.front_last_recording"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state.attributes.get("motion_detection") is True
|
||||
|
||||
await hass.services.async_call(
|
||||
"camera",
|
||||
"disable_motion_detection",
|
||||
{"entity_id": "camera.front_last_recording"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state.attributes.get("motion_detection") is None
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_camera_motion_detection_not_supported(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Tests the siren turns on correctly."""
|
||||
front_camera_mock = mock_ring_devices.get_device(765432)
|
||||
has_capability = front_camera_mock.has_capability.side_effect
|
||||
|
||||
def _has_capability(capability):
|
||||
if capability == "motion_detection":
|
||||
return False
|
||||
return has_capability(capability)
|
||||
|
||||
front_camera_mock.has_capability.side_effect = _has_capability
|
||||
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state.attributes.get("motion_detection") is None
|
||||
|
||||
await hass.services.async_call(
|
||||
"camera",
|
||||
"enable_motion_detection",
|
||||
{"entity_id": "camera.front_last_recording"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state.attributes.get("motion_detection") is None
|
||||
assert (
|
||||
"Entity camera.front_last_recording does not have motion detection capability"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, True),
|
||||
(ring_doorbell.RingTimeout, False),
|
||||
(ring_doorbell.RingError, False),
|
||||
],
|
||||
ids=["Authentication", "Timeout", "Other"],
|
||||
)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_motion_detection_errors_when_turned_on(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
exception_type,
|
||||
reauth_expected,
|
||||
) -> None:
|
||||
"""Tests the motion detection errors are handled correctly."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
config_entry = hass.config_entries.async_entries("ring")[0]
|
||||
|
||||
assert not any(config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
front_camera_mock = mock_ring_devices.get_device(765432)
|
||||
front_camera_mock.async_set_motion_detection.side_effect = exception_type
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
"camera",
|
||||
"enable_motion_detection",
|
||||
{"entity_id": "camera.front_last_recording"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
front_camera_mock.async_set_motion_detection.assert_called_once()
|
||||
assert (
|
||||
any(
|
||||
flow
|
||||
for flow in config_entry.async_get_active_flows(hass, {SOURCE_REAUTH})
|
||||
if flow["handler"] == "ring"
|
||||
)
|
||||
== reauth_expected
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_camera_handle_mjpeg_stream(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test camera returns handle mjpeg stream when available."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
front_camera_mock = mock_ring_devices.get_device(765432)
|
||||
front_camera_mock.async_recording_url.return_value = None
|
||||
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
assert state is not None
|
||||
|
||||
mock_request = make_mocked_request("GET", "/", headers={"token": "x"})
|
||||
|
||||
# history not updated yet
|
||||
front_camera_mock.async_history.assert_not_called()
|
||||
front_camera_mock.async_recording_url.assert_not_called()
|
||||
stream = await async_get_mjpeg_stream(
|
||||
hass, mock_request, "camera.front_last_recording"
|
||||
)
|
||||
assert stream is None
|
||||
|
||||
# Video url will be none so no stream
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
front_camera_mock.async_history.assert_called_once()
|
||||
front_camera_mock.async_recording_url.assert_called()
|
||||
|
||||
stream = await async_get_mjpeg_stream(
|
||||
hass, mock_request, "camera.front_last_recording"
|
||||
)
|
||||
assert stream is None
|
||||
|
||||
# Stop the history updating so we can update the values manually
|
||||
front_camera_mock.async_history = AsyncMock()
|
||||
front_camera_mock.last_history[0]["recording"]["status"] = "not ready"
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
front_camera_mock.async_recording_url.assert_called()
|
||||
stream = await async_get_mjpeg_stream(
|
||||
hass, mock_request, "camera.front_last_recording"
|
||||
)
|
||||
assert stream is None
|
||||
|
||||
# If the history id hasn't changed the camera will not check again for the video url
|
||||
# until the FORCE_REFRESH_INTERVAL has passed
|
||||
front_camera_mock.last_history[0]["recording"]["status"] = "ready"
|
||||
front_camera_mock.async_recording_url = AsyncMock(return_value="http://dummy.url")
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
front_camera_mock.async_recording_url.assert_not_called()
|
||||
|
||||
stream = await async_get_mjpeg_stream(
|
||||
hass, mock_request, "camera.front_last_recording"
|
||||
)
|
||||
assert stream is None
|
||||
|
||||
freezer.tick(FORCE_REFRESH_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
front_camera_mock.async_recording_url.assert_called()
|
||||
|
||||
# Now the stream should be returned
|
||||
stream_reader = MockStreamReader(SMALLEST_VALID_JPEG_BYTES)
|
||||
with patch("homeassistant.components.ring.camera.CameraMjpeg") as mock_camera:
|
||||
mock_camera.return_value.get_reader = AsyncMock(return_value=stream_reader)
|
||||
mock_camera.return_value.open_camera = AsyncMock()
|
||||
mock_camera.return_value.close = AsyncMock()
|
||||
|
||||
stream = await async_get_mjpeg_stream(
|
||||
hass, mock_request, "camera.front_last_recording"
|
||||
)
|
||||
assert stream is not None
|
||||
# Check the stream has been read
|
||||
assert not await stream_reader.read(-1)
|
||||
|
||||
|
||||
async def test_camera_image(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test camera will return still image when available."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
front_camera_mock = mock_ring_devices.get_device(765432)
|
||||
|
||||
state = hass.states.get("camera.front_live_view")
|
||||
assert state is not None
|
||||
|
||||
# history not updated yet
|
||||
front_camera_mock.async_history.assert_not_called()
|
||||
front_camera_mock.async_recording_url.assert_not_called()
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.ring.camera.ffmpeg.async_get_image",
|
||||
return_value=SMALLEST_VALID_JPEG_BYTES,
|
||||
),
|
||||
pytest.raises(HomeAssistantError),
|
||||
):
|
||||
image = await async_get_image(hass, "camera.front_live_view")
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
# history updated so image available
|
||||
front_camera_mock.async_history.assert_called_once()
|
||||
front_camera_mock.async_recording_url.assert_called_once()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ring.camera.ffmpeg.async_get_image",
|
||||
return_value=SMALLEST_VALID_JPEG_BYTES,
|
||||
):
|
||||
image = await async_get_image(hass, "camera.front_live_view")
|
||||
assert image.content == SMALLEST_VALID_JPEG_BYTES
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_camera_stream_attributes(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test stream attributes."""
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
|
||||
# Live view
|
||||
state = hass.states.get("camera.front_live_view")
|
||||
supported_features = state.attributes.get("supported_features")
|
||||
assert supported_features is CameraEntityFeature.STREAM
|
||||
camera = get_camera_from_entity_id(hass, "camera.front_live_view")
|
||||
assert camera.camera_capabilities.frontend_stream_types == {StreamType.WEB_RTC}
|
||||
|
||||
# Last recording
|
||||
state = hass.states.get("camera.front_last_recording")
|
||||
supported_features = state.attributes.get("supported_features")
|
||||
assert supported_features is CameraEntityFeature(0)
|
||||
camera = get_camera_from_entity_id(hass, "camera.front_last_recording")
|
||||
assert camera.camera_capabilities.frontend_stream_types == set()
|
||||
|
||||
|
||||
async def test_camera_webrtc(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_ring_devices,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test WebRTC interactions."""
|
||||
caplog.set_level(logging.ERROR)
|
||||
await setup_platform(hass, Platform.CAMERA)
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
# sdp offer
|
||||
await client.send_json_auto_id(
|
||||
{
|
||||
"type": "camera/webrtc/offer",
|
||||
"entity_id": "camera.front_live_view",
|
||||
"offer": "v=0\r\n",
|
||||
}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response
|
||||
assert response.get("success") is True
|
||||
subscription_id = response["id"]
|
||||
assert not caplog.text
|
||||
|
||||
front_camera_mock = mock_ring_devices.get_device(FRONT_DEVICE_ID)
|
||||
front_camera_mock.generate_async_webrtc_stream.assert_called_once()
|
||||
args = front_camera_mock.generate_async_webrtc_stream.call_args.args
|
||||
session_id = args[1]
|
||||
on_message = args[2]
|
||||
|
||||
# receive session
|
||||
response = await client.receive_json()
|
||||
event = response.get("event")
|
||||
assert event
|
||||
assert event.get("type") == "session"
|
||||
assert not caplog.text
|
||||
|
||||
# Ring candidate
|
||||
on_message(RingWebRtcMessage(candidate="candidate", sdp_m_line_index=1))
|
||||
response = await client.receive_json()
|
||||
event = response.get("event")
|
||||
assert event
|
||||
assert event.get("type") == "candidate"
|
||||
assert not caplog.text
|
||||
|
||||
# Error message
|
||||
on_message(RingWebRtcMessage(error_code=1, error_message="error"))
|
||||
response = await client.receive_json()
|
||||
event = response.get("event")
|
||||
assert event
|
||||
assert event.get("type") == "error"
|
||||
assert not caplog.text
|
||||
|
||||
# frontend candidate
|
||||
await client.send_json_auto_id(
|
||||
{
|
||||
"type": "camera/webrtc/candidate",
|
||||
"entity_id": "camera.front_live_view",
|
||||
"session_id": session_id,
|
||||
"candidate": {"candidate": "candidate", "sdpMLineIndex": 1},
|
||||
}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response
|
||||
assert response.get("success") is True
|
||||
assert not caplog.text
|
||||
front_camera_mock.on_webrtc_candidate.assert_called_once()
|
||||
|
||||
# Invalid frontend candidate
|
||||
await client.send_json_auto_id(
|
||||
{
|
||||
"type": "camera/webrtc/candidate",
|
||||
"entity_id": "camera.front_live_view",
|
||||
"session_id": session_id,
|
||||
"candidate": {"candidate": "candidate", "sdpMid": "1"},
|
||||
}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response
|
||||
assert response.get("success") is False
|
||||
assert response["error"]["code"] == "home_assistant_error"
|
||||
msg = "The sdp_m_line_index is required for ring webrtc streaming"
|
||||
assert msg in response["error"].get("message")
|
||||
assert msg in caplog.text
|
||||
front_camera_mock.on_webrtc_candidate.assert_called_once()
|
||||
|
||||
# Answer message
|
||||
caplog.clear()
|
||||
on_message(RingWebRtcMessage(answer="v=0\r\n"))
|
||||
response = await client.receive_json()
|
||||
event = response.get("event")
|
||||
assert event
|
||||
assert event.get("type") == "answer"
|
||||
assert not caplog.text
|
||||
|
||||
# Unsubscribe/Close session
|
||||
front_camera_mock.sync_close_webrtc_stream.assert_not_called()
|
||||
await client.send_json_auto_id(
|
||||
{
|
||||
"type": "unsubscribe_events",
|
||||
"subscription": subscription_id,
|
||||
}
|
||||
)
|
||||
|
||||
response = await client.receive_json()
|
||||
assert response
|
||||
assert response.get("success") is True
|
||||
front_camera_mock.sync_close_webrtc_stream.assert_called_once()
|
||||
409
home-assistant/tests/components/ring/test_config_flow.py
Normal file
409
home-assistant/tests/components/ring/test_config_flow.py
Normal file
@@ -0,0 +1,409 @@
|
||||
"""Test the Ring config flow."""
|
||||
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.ring import DOMAIN
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .conftest import MOCK_HARDWARE_ID
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_client: Mock,
|
||||
) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch("uuid.uuid4", return_value=MOCK_HARDWARE_ID):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"username": "hello@home-assistant.io", "password": "test-password"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "hello@home-assistant.io"
|
||||
assert result2["data"] == {
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: "hello@home-assistant.io",
|
||||
CONF_TOKEN: {"access_token": "mock-token"},
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "errors_msg"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, "invalid_auth"),
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
ids=["invalid-auth", "unknown-error"],
|
||||
)
|
||||
async def test_form_error(
|
||||
hass: HomeAssistant, mock_ring_auth: Mock, error_type, errors_msg
|
||||
) -> None:
|
||||
"""Test we handle invalid auth."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
mock_ring_auth.async_fetch_token.side_effect = error_type
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"username": "hello@home-assistant.io", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": errors_msg}
|
||||
|
||||
|
||||
async def test_form_2fa(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_auth: Mock,
|
||||
) -> None:
|
||||
"""Test form flow for 2fa."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_ring_auth.async_fetch_token.side_effect = ring_doorbell.Requires2FAError
|
||||
with patch("uuid.uuid4", return_value=MOCK_HARDWARE_ID):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
CONF_PASSWORD: "fake-password",
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "fake-password", None
|
||||
)
|
||||
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "2fa"
|
||||
mock_ring_auth.async_fetch_token.reset_mock(side_effect=True)
|
||||
mock_ring_auth.async_fetch_token.return_value = "new-foobar"
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={"2fa": "123456"},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "fake-password", "123456"
|
||||
)
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "foo@bar.com"
|
||||
assert result3["data"] == {
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
CONF_TOKEN: "new-foobar",
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_reauth(
|
||||
hass: HomeAssistant,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_auth: Mock,
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
mock_added_config_entry.async_start_reauth(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
[result] = flows
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
mock_ring_auth.async_fetch_token.side_effect = ring_doorbell.Requires2FAError
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_PASSWORD: "other_fake_password",
|
||||
},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "other_fake_password", None
|
||||
)
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "2fa"
|
||||
mock_ring_auth.async_fetch_token.reset_mock(side_effect=True)
|
||||
mock_ring_auth.async_fetch_token.return_value = "new-foobar"
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={"2fa": "123456"},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "other_fake_password", "123456"
|
||||
)
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "reauth_successful"
|
||||
assert mock_added_config_entry.data == {
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
CONF_TOKEN: "new-foobar",
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "errors_msg"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, "invalid_auth"),
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
ids=["invalid-auth", "unknown-error"],
|
||||
)
|
||||
async def test_reauth_error(
|
||||
hass: HomeAssistant,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_auth: Mock,
|
||||
error_type,
|
||||
errors_msg,
|
||||
) -> None:
|
||||
"""Test reauth flow."""
|
||||
mock_added_config_entry.async_start_reauth(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
[result] = flows
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
mock_ring_auth.async_fetch_token.side_effect = error_type
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_PASSWORD: "error_fake_password",
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "error_fake_password", None
|
||||
)
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": errors_msg}
|
||||
|
||||
# Now test reauth can go on to succeed
|
||||
mock_ring_auth.async_fetch_token.reset_mock(side_effect=True)
|
||||
mock_ring_auth.async_fetch_token.return_value = "new-foobar"
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={
|
||||
CONF_PASSWORD: "other_fake_password",
|
||||
},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_once_with(
|
||||
"foo@bar.com", "other_fake_password", None
|
||||
)
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "reauth_successful"
|
||||
assert mock_added_config_entry.data == {
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
CONF_TOKEN: "new-foobar",
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_account_configured(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_added_config_entry: Mock,
|
||||
) -> None:
|
||||
"""Test that user cannot configure the same account twice."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"username": "foo@bar.com", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_dhcp_discovery(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_client: Mock,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test discovery by dhcp."""
|
||||
mac_address = "1234567890abcd"
|
||||
hostname = "Ring-90abcd"
|
||||
ip_address = "127.0.0.1"
|
||||
username = "hello@home-assistant.io"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip=ip_address, macaddress=mac_address, hostname=hostname
|
||||
),
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "user"
|
||||
with patch("uuid.uuid4", return_value=MOCK_HARDWARE_ID):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"username": username, "password": "test-password"},
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "hello@home-assistant.io"
|
||||
assert result["data"] == {
|
||||
CONF_DEVICE_ID: MOCK_HARDWARE_ID,
|
||||
CONF_USERNAME: username,
|
||||
CONF_TOKEN: {"access_token": "mock-token"},
|
||||
}
|
||||
|
||||
config_entry = hass.config_entries.async_entry_for_domain_unique_id(
|
||||
DOMAIN, username
|
||||
)
|
||||
assert config_entry
|
||||
|
||||
# Create a device entry under the config entry just created
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
identifiers={(DOMAIN, mac_address)},
|
||||
)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip=ip_address, macaddress=mac_address, hostname=hostname
|
||||
),
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_reconfigure(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_client: Mock,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the reconfigure config flow."""
|
||||
|
||||
assert mock_added_config_entry.data[CONF_DEVICE_ID] == MOCK_HARDWARE_ID
|
||||
|
||||
result = await mock_added_config_entry.start_reconfigure_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reconfigure"
|
||||
|
||||
with patch("uuid.uuid4", return_value="new-hardware-id"):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"password": "test-password"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reconfigure_successful"
|
||||
assert mock_added_config_entry.data[CONF_DEVICE_ID] == "new-hardware-id"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "errors_msg"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, "invalid_auth"),
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
ids=["invalid-auth", "unknown-error"],
|
||||
)
|
||||
async def test_reconfigure_errors(
|
||||
hass: HomeAssistant,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_ring_auth: Mock,
|
||||
error_type,
|
||||
errors_msg,
|
||||
) -> None:
|
||||
"""Test errors during the reconfigure config flow."""
|
||||
result = await mock_added_config_entry.start_reconfigure_flow(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reconfigure"
|
||||
|
||||
mock_ring_auth.async_fetch_token.side_effect = error_type
|
||||
with patch("uuid.uuid4", return_value="new-hardware-id"):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_PASSWORD: "error_fake_password",
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
mock_ring_auth.async_fetch_token.assert_called_with(
|
||||
"foo@bar.com", "error_fake_password", None
|
||||
)
|
||||
mock_ring_auth.async_fetch_token.side_effect = ring_doorbell.Requires2FAError
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={
|
||||
CONF_PASSWORD: "other_fake_password",
|
||||
},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_with(
|
||||
"foo@bar.com", "other_fake_password", None
|
||||
)
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "2fa"
|
||||
|
||||
# Now test reconfigure can go on to succeed
|
||||
mock_ring_auth.async_fetch_token.reset_mock(side_effect=True)
|
||||
mock_ring_auth.async_fetch_token.return_value = "new-foobar"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
result3["flow_id"],
|
||||
user_input={"2fa": "123456"},
|
||||
)
|
||||
|
||||
mock_ring_auth.async_fetch_token.assert_called_with(
|
||||
"foo@bar.com", "other_fake_password", "123456"
|
||||
)
|
||||
|
||||
assert result4["type"] is FlowResultType.ABORT
|
||||
assert result4["reason"] == "reconfigure_successful"
|
||||
assert mock_added_config_entry.data == {
|
||||
CONF_DEVICE_ID: "new-hardware-id",
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
CONF_TOKEN: "new-foobar",
|
||||
}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
23
home-assistant/tests/components/ring/test_diagnostics.py
Normal file
23
home-assistant/tests/components/ring/test_diagnostics.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Test Ring diagnostics."""
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_ring_client,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test Ring diagnostics."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
diag = await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
|
||||
assert diag == snapshot
|
||||
98
home-assistant/tests/components/ring/test_event.py
Normal file
98
home-assistant/tests/components/ring/test_event.py
Normal file
@@ -0,0 +1,98 @@
|
||||
"""The tests for the Ring event platform."""
|
||||
|
||||
from datetime import datetime
|
||||
import time
|
||||
from unittest.mock import Mock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
from ring_doorbell import Ring
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.ring.binary_sensor import RingEvent
|
||||
from homeassistant.components.ring.coordinator import RingEventListener
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
from .device_mocks import FRONT_DOOR_DEVICE_ID, INGRESS_DEVICE_ID
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.EVENT)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_id", "device_name", "alert_kind", "device_class"),
|
||||
[
|
||||
pytest.param(
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
"front_door",
|
||||
"motion",
|
||||
"motion",
|
||||
id="front_door_motion",
|
||||
),
|
||||
pytest.param(
|
||||
FRONT_DOOR_DEVICE_ID, "front_door", "ding", "doorbell", id="front_door_ding"
|
||||
),
|
||||
pytest.param(
|
||||
INGRESS_DEVICE_ID, "ingress", "ding", "doorbell", id="ingress_ding"
|
||||
),
|
||||
pytest.param(
|
||||
INGRESS_DEVICE_ID,
|
||||
"ingress",
|
||||
"intercom_unlock",
|
||||
"button",
|
||||
id="ingress_unlock",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_event(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Ring,
|
||||
mock_ring_event_listener_class: RingEventListener,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
device_id: int,
|
||||
device_name: str,
|
||||
alert_kind: str,
|
||||
device_class: str,
|
||||
) -> None:
|
||||
"""Test the Ring event platforms."""
|
||||
|
||||
await setup_platform(hass, Platform.EVENT)
|
||||
|
||||
start_time_str = "2024-09-04T15:32:53.892+00:00"
|
||||
start_time = datetime.strptime(start_time_str, "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
freezer.move_to(start_time)
|
||||
on_event_cb = mock_ring_event_listener_class.return_value.add_notification_callback.call_args.args[
|
||||
0
|
||||
]
|
||||
|
||||
# Default state is unknown
|
||||
entity_id = f"event.{device_name}_{alert_kind}"
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == "unknown"
|
||||
assert state.attributes["device_class"] == device_class
|
||||
|
||||
# A new alert sets to on
|
||||
event = RingEvent(
|
||||
1234546, device_id, "Foo", "Bar", time.time(), 180, kind=alert_kind, state=None
|
||||
)
|
||||
mock_ring_client.active_alerts.return_value = [event]
|
||||
on_event_cb(event)
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == start_time_str
|
||||
495
home-assistant/tests/components/ring/test_init.py
Normal file
495
home-assistant/tests/components/ring/test_init.py
Normal file
@@ -0,0 +1,495 @@
|
||||
"""The tests for the Ring component."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
from ring_doorbell import AuthenticationError, Ring, RingError, RingTimeout
|
||||
|
||||
from homeassistant.components import ring
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.components.ring import DOMAIN
|
||||
from homeassistant.components.ring.const import (
|
||||
CONF_CONFIG_ENTRY_MINOR_VERSION,
|
||||
CONF_LISTEN_CREDENTIALS,
|
||||
SCAN_INTERVAL,
|
||||
)
|
||||
from homeassistant.components.ring.coordinator import RingEventListener
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_TOKEN, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .conftest import MOCK_HARDWARE_ID
|
||||
from .device_mocks import FRONT_DOOR_DEVICE_ID
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, mock_ring_client) -> None:
|
||||
"""Test the setup."""
|
||||
await async_setup_component(hass, ring.DOMAIN, {})
|
||||
|
||||
|
||||
async def test_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test setup entry."""
|
||||
assert mock_added_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_setup_entry_device_update(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_added_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test devices are updating after setup entry."""
|
||||
|
||||
front_door_doorbell = mock_ring_devices.get_device(987654)
|
||||
front_door_doorbell.async_history.assert_not_called()
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
front_door_doorbell.async_history.assert_called_once()
|
||||
|
||||
|
||||
async def test_auth_failed_on_setup(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test auth failure on setup entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
mock_ring_client.async_update_data.side_effect = AuthenticationError
|
||||
|
||||
assert not any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "log_msg"),
|
||||
[
|
||||
(
|
||||
RingTimeout,
|
||||
"Timeout communicating with API: ",
|
||||
),
|
||||
(
|
||||
RingError,
|
||||
"Error communicating with API: ",
|
||||
),
|
||||
],
|
||||
ids=["timeout-error", "other-error"],
|
||||
)
|
||||
async def test_error_on_setup(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
error_type,
|
||||
log_msg,
|
||||
) -> None:
|
||||
"""Test non-auth errors on setup entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
mock_ring_client.async_update_data.side_effect = error_type
|
||||
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
assert log_msg in caplog.text
|
||||
|
||||
|
||||
async def test_auth_failure_on_global_update(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test authentication failure on global data 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()
|
||||
assert not any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
mock_ring_client.async_update_devices.side_effect = AuthenticationError
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "Authentication failed while fetching devices data: " in caplog.text
|
||||
|
||||
assert any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
|
||||
async def test_auth_failure_on_device_update(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test authentication failure on device data 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()
|
||||
assert not any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
front_door_doorbell = mock_ring_devices.get_device(987654)
|
||||
front_door_doorbell.async_history.side_effect = AuthenticationError
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert "Authentication failed while fetching devices data: " in caplog.text
|
||||
|
||||
assert any(mock_config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "log_msg"),
|
||||
[
|
||||
(
|
||||
RingTimeout,
|
||||
"Error fetching devices data: Timeout communicating with API: ",
|
||||
),
|
||||
(
|
||||
RingError,
|
||||
"Error fetching devices data: Error communicating with API: ",
|
||||
),
|
||||
],
|
||||
ids=["timeout-error", "other-error"],
|
||||
)
|
||||
async def test_error_on_global_update(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
error_type,
|
||||
log_msg,
|
||||
) -> None:
|
||||
"""Test non-auth errors on global data 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()
|
||||
|
||||
mock_ring_client.async_update_devices.side_effect = error_type
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert log_msg in caplog.text
|
||||
|
||||
assert hass.config_entries.async_get_entry(mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("error_type", "log_msg"),
|
||||
[
|
||||
(
|
||||
RingTimeout,
|
||||
"Error fetching devices data: Timeout communicating with API for device Front: ",
|
||||
),
|
||||
(
|
||||
RingError,
|
||||
"Error fetching devices data: Error communicating with API for device Front: ",
|
||||
),
|
||||
],
|
||||
ids=["timeout-error", "other-error"],
|
||||
)
|
||||
async def test_error_on_device_update(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
error_type,
|
||||
log_msg,
|
||||
) -> None:
|
||||
"""Test non-auth errors on device 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()
|
||||
|
||||
front_door_doorbell = mock_ring_devices.get_device(765432)
|
||||
front_door_doorbell.async_history.side_effect = error_type
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert log_msg in caplog.text
|
||||
assert hass.config_entries.async_get_entry(mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("domain", "old_unique_id", "new_unique_id"),
|
||||
[
|
||||
pytest.param(LIGHT_DOMAIN, 123456, "123456", id="Light integer"),
|
||||
pytest.param(
|
||||
CAMERA_DOMAIN,
|
||||
654321,
|
||||
"654321-last_recording",
|
||||
id="Camera integer",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_update_unique_id(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mock_ring_client,
|
||||
domain: str,
|
||||
old_unique_id: int | str,
|
||||
new_unique_id: str,
|
||||
) -> None:
|
||||
"""Test unique_id update of integration."""
|
||||
entry = MockConfigEntry(
|
||||
title="Ring",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
"token": {"access_token": "mock-token"},
|
||||
},
|
||||
unique_id="foo@bar.com",
|
||||
minor_version=1,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
entity = entity_registry.async_get_or_create(
|
||||
domain=domain,
|
||||
platform=DOMAIN,
|
||||
unique_id=old_unique_id,
|
||||
config_entry=entry,
|
||||
)
|
||||
assert entity.unique_id == old_unique_id
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_migrated = entity_registry.async_get(entity.entity_id)
|
||||
assert entity_migrated
|
||||
assert entity_migrated.unique_id == new_unique_id
|
||||
assert (f"Fixing non string unique id {old_unique_id}") in caplog.text
|
||||
assert entry.minor_version == CONF_CONFIG_ENTRY_MINOR_VERSION
|
||||
|
||||
|
||||
async def test_update_unique_id_existing(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mock_ring_client,
|
||||
) -> None:
|
||||
"""Test unique_id update of integration."""
|
||||
old_unique_id = 123456
|
||||
entry = MockConfigEntry(
|
||||
title="Ring",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
"token": {"access_token": "mock-token"},
|
||||
},
|
||||
unique_id="foo@bar.com",
|
||||
minor_version=1,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
entity = entity_registry.async_get_or_create(
|
||||
domain=CAMERA_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=old_unique_id,
|
||||
config_entry=entry,
|
||||
)
|
||||
entity_existing = entity_registry.async_get_or_create(
|
||||
domain=CAMERA_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=str(old_unique_id),
|
||||
config_entry=entry,
|
||||
)
|
||||
assert entity.unique_id == old_unique_id
|
||||
assert entity_existing.unique_id == str(old_unique_id)
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_not_migrated = entity_registry.async_get(entity.entity_id)
|
||||
entity_existing = entity_registry.async_get(entity_existing.entity_id)
|
||||
assert entity_not_migrated
|
||||
assert entity_existing
|
||||
assert entity_not_migrated.unique_id == old_unique_id
|
||||
assert (
|
||||
f"Cannot migrate to unique_id '{old_unique_id}', "
|
||||
f"already exists for '{entity_existing.entity_id}', "
|
||||
"You may have to delete unavailable ring entities"
|
||||
) in caplog.text
|
||||
assert entry.minor_version == CONF_CONFIG_ENTRY_MINOR_VERSION
|
||||
|
||||
|
||||
async def test_update_unique_id_camera_update(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mock_ring_client,
|
||||
) -> None:
|
||||
"""Test camera unique id with no suffix is updated."""
|
||||
correct_unique_id = "123456-last_recording"
|
||||
entry = MockConfigEntry(
|
||||
title="Ring",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
"token": {"access_token": "mock-token"},
|
||||
},
|
||||
unique_id="foo@bar.com",
|
||||
minor_version=1,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
entity = entity_registry.async_get_or_create(
|
||||
domain=CAMERA_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id="123456",
|
||||
config_entry=entry,
|
||||
)
|
||||
assert entity.unique_id == "123456"
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_migrated = entity_registry.async_get(entity.entity_id)
|
||||
assert entity_migrated
|
||||
assert entity_migrated.unique_id == correct_unique_id
|
||||
assert entity.disabled is False
|
||||
assert "Fixing non string unique id" not in caplog.text
|
||||
assert entry.minor_version == CONF_CONFIG_ENTRY_MINOR_VERSION
|
||||
|
||||
|
||||
async def test_token_updated(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_ring_client,
|
||||
mock_ring_init_auth_class,
|
||||
) -> None:
|
||||
"""Test that the token value is updated in the config entry.
|
||||
|
||||
This simulates the api calling the callback.
|
||||
"""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
|
||||
assert mock_ring_init_auth_class.call_count == 1
|
||||
token_updater = mock_ring_init_auth_class.call_args.args[2]
|
||||
assert mock_config_entry.data[CONF_TOKEN] == {"access_token": "mock-token"}
|
||||
|
||||
mock_ring_client.async_update_devices.side_effect = lambda: token_updater(
|
||||
{"access_token": "new-mock-token"}
|
||||
)
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_config_entry.data[CONF_TOKEN] == {"access_token": "new-mock-token"}
|
||||
|
||||
|
||||
async def test_listen_token_updated(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_ring_client,
|
||||
mock_ring_event_listener_class,
|
||||
) -> None:
|
||||
"""Test that the listener token value is updated in the config entry.
|
||||
|
||||
This simulates the api calling the callback.
|
||||
"""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
|
||||
assert mock_ring_event_listener_class.call_count == 1
|
||||
token_updater = mock_ring_event_listener_class.call_args.args[2]
|
||||
|
||||
assert mock_config_entry.data.get(CONF_LISTEN_CREDENTIALS) is None
|
||||
token_updater({"listen_access_token": "mock-token"})
|
||||
assert mock_config_entry.data.get(CONF_LISTEN_CREDENTIALS) == {
|
||||
"listen_access_token": "mock-token"
|
||||
}
|
||||
|
||||
|
||||
async def test_no_listen_start(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_ring_event_listener_class: type[RingEventListener],
|
||||
mock_ring_client: Ring,
|
||||
) -> None:
|
||||
"""Test behaviour if listener doesn't start."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
version=1,
|
||||
data={"username": "foo", "token": {}},
|
||||
)
|
||||
# Create a binary sensor entity so it is not ignored by the deprecation check
|
||||
# and the listener will start
|
||||
entity_registry.async_get_or_create(
|
||||
domain=BINARY_SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=f"{FRONT_DOOR_DEVICE_ID}-motion",
|
||||
suggested_object_id=f"{FRONT_DOOR_DEVICE_ID}_motion",
|
||||
config_entry=mock_entry,
|
||||
)
|
||||
mock_ring_event_listener_class.do_not_start = True
|
||||
|
||||
mock_ring_event_listener_class.return_value.started = False
|
||||
|
||||
mock_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "Ring event listener failed to start after 10 seconds" in [
|
||||
record.message for record in caplog.records if record.levelname == "WARNING"
|
||||
]
|
||||
|
||||
|
||||
async def test_migrate_create_device_id(
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test migration creates new device id created."""
|
||||
entry = MockConfigEntry(
|
||||
title="Ring",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_USERNAME: "foo@bar.com",
|
||||
"token": {"access_token": "mock-token"},
|
||||
},
|
||||
unique_id="foo@bar.com",
|
||||
version=1,
|
||||
minor_version=1,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with patch("uuid.uuid4", return_value=MOCK_HARDWARE_ID):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.minor_version == CONF_CONFIG_ENTRY_MINOR_VERSION
|
||||
assert CONF_DEVICE_ID in entry.data
|
||||
assert entry.data[CONF_DEVICE_ID] == MOCK_HARDWARE_ID
|
||||
|
||||
assert "Migration to version 1.2 complete" in caplog.text
|
||||
110
home-assistant/tests/components/ring/test_light.py
Normal file
110
home-assistant/tests/components/ring/test_light.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""The tests for the Ring light platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_light_off_reports_correctly(
|
||||
hass: HomeAssistant, mock_ring_client
|
||||
) -> None:
|
||||
"""Tests that the initial state of a device that should be off is correct."""
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
|
||||
state = hass.states.get("light.front_light")
|
||||
assert state.state == "off"
|
||||
assert state.attributes.get("friendly_name") == "Front Light"
|
||||
|
||||
|
||||
async def test_light_on_reports_correctly(
|
||||
hass: HomeAssistant, mock_ring_client
|
||||
) -> None:
|
||||
"""Tests that the initial state of a device that should be on is correct."""
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
|
||||
state = hass.states.get("light.internal_light")
|
||||
assert state.state == "on"
|
||||
assert state.attributes.get("friendly_name") == "Internal Light"
|
||||
|
||||
|
||||
async def test_light_can_be_turned_on(hass: HomeAssistant, mock_ring_client) -> None:
|
||||
"""Tests the light turns on correctly."""
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
|
||||
state = hass.states.get("light.front_light")
|
||||
assert state.state == "off"
|
||||
|
||||
await hass.services.async_call(
|
||||
"light", "turn_on", {"entity_id": "light.front_light"}, 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"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, True),
|
||||
(ring_doorbell.RingTimeout, False),
|
||||
(ring_doorbell.RingError, False),
|
||||
],
|
||||
ids=["Authentication", "Timeout", "Other"],
|
||||
)
|
||||
async def test_light_errors_when_turned_on(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
exception_type,
|
||||
reauth_expected,
|
||||
) -> None:
|
||||
"""Tests the light turns on correctly."""
|
||||
await setup_platform(hass, Platform.LIGHT)
|
||||
config_entry = hass.config_entries.async_entries("ring")[0]
|
||||
|
||||
assert not any(config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
front_light_mock = mock_ring_devices.get_device(765432)
|
||||
front_light_mock.async_set_lights.side_effect = exception_type
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
"light", "turn_on", {"entity_id": "light.front_light"}, blocking=True
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
front_light_mock.async_set_lights.assert_called_once()
|
||||
|
||||
assert (
|
||||
any(
|
||||
flow
|
||||
for flow in config_entry.async_get_active_flows(hass, {SOURCE_REAUTH})
|
||||
if flow["handler"] == "ring"
|
||||
)
|
||||
== reauth_expected
|
||||
)
|
||||
95
home-assistant/tests/components/ring/test_number.py
Normal file
95
home-assistant/tests/components/ring/test_number.py
Normal file
@@ -0,0 +1,95 @@
|
||||
"""The tests for the Ring number platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.number import (
|
||||
ATTR_VALUE,
|
||||
DOMAIN as NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "unique_id"),
|
||||
[
|
||||
("number.downstairs_volume", "123456-volume"),
|
||||
("number.front_door_volume", "987654-volume"),
|
||||
("number.ingress_doorbell_volume", "185036587-doorbell_volume"),
|
||||
("number.ingress_mic_volume", "185036587-mic_volume"),
|
||||
("number.ingress_voice_volume", "185036587-voice_volume"),
|
||||
],
|
||||
)
|
||||
async def test_entity_registry(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_ring_client: Mock,
|
||||
entity_id: str,
|
||||
unique_id: str,
|
||||
) -> None:
|
||||
"""Tests that the devices are registered in the entity registry."""
|
||||
await setup_platform(hass, Platform.NUMBER)
|
||||
|
||||
entry = entity_registry.async_get(entity_id)
|
||||
assert entry is not None and entry.unique_id == unique_id
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.NUMBER)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "new_value"),
|
||||
[
|
||||
("number.downstairs_volume", "4.0"),
|
||||
("number.front_door_volume", "3.0"),
|
||||
("number.ingress_doorbell_volume", "7.0"),
|
||||
("number.ingress_mic_volume", "2.0"),
|
||||
("number.ingress_voice_volume", "5.0"),
|
||||
],
|
||||
)
|
||||
async def test_volume_can_be_changed(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
entity_id: str,
|
||||
new_value: str,
|
||||
) -> None:
|
||||
"""Tests the volume can be changed correctly."""
|
||||
await setup_platform(hass, Platform.NUMBER)
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
old_value = state.state
|
||||
|
||||
# otherwise this test would be pointless
|
||||
assert old_value != new_value
|
||||
|
||||
await hass.services.async_call(
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: new_value},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None and state.state == new_value
|
||||
230
home-assistant/tests/components/ring/test_sensor.py
Normal file
230
home-assistant/tests/components/ring/test_sensor.py
Normal file
@@ -0,0 +1,230 @@
|
||||
"""The tests for the Ring sensor platform."""
|
||||
|
||||
import logging
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
from ring_doorbell import Ring
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.ring.const import DOMAIN, SCAN_INTERVAL
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
from .device_mocks import (
|
||||
DOWNSTAIRS_DEVICE_ID,
|
||||
FRONT_DEVICE_ID,
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
INGRESS_DEVICE_ID,
|
||||
INTERNAL_DEVICE_ID,
|
||||
)
|
||||
|
||||
from tests.common import async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_deprecated_and_disabled_sensor_entities(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
):
|
||||
"""Create the entity so it is not ignored by the deprecation check."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
def create_entry(
|
||||
device_name,
|
||||
description,
|
||||
device_id,
|
||||
):
|
||||
unique_id = f"{device_id}-{description}"
|
||||
entity_registry.async_get_or_create(
|
||||
domain=SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id=f"{device_name}_{description}",
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
|
||||
# Deprecated
|
||||
create_entry("downstairs", "volume", DOWNSTAIRS_DEVICE_ID)
|
||||
create_entry("front_door", "volume", FRONT_DEVICE_ID)
|
||||
create_entry("ingress", "doorbell_volume", INGRESS_DEVICE_ID)
|
||||
create_entry("ingress", "mic_volume", INGRESS_DEVICE_ID)
|
||||
create_entry("ingress", "voice_volume", INGRESS_DEVICE_ID)
|
||||
|
||||
# Disabled
|
||||
for desc in ("wifi_signal_category", "wifi_signal_strength"):
|
||||
create_entry("downstairs", desc, DOWNSTAIRS_DEVICE_ID)
|
||||
create_entry("front", desc, FRONT_DEVICE_ID)
|
||||
create_entry("ingress", desc, INGRESS_DEVICE_ID)
|
||||
create_entry("front_door", desc, FRONT_DOOR_DEVICE_ID)
|
||||
create_entry("internal", desc, INTERNAL_DEVICE_ID)
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
create_deprecated_and_disabled_sensor_entities,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.SENSOR)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_id", "device_name", "sensor_name", "expected_value"),
|
||||
[
|
||||
(987654, "front_door", "wifi_signal_category", "good"),
|
||||
(987654, "front_door", "wifi_signal_strength", "-58"),
|
||||
(123456, "downstairs", "wifi_signal_category", "good"),
|
||||
(123456, "downstairs", "wifi_signal_strength", "-39"),
|
||||
(765432, "front", "wifi_signal_category", "good"),
|
||||
(765432, "front", "wifi_signal_strength", "-58"),
|
||||
],
|
||||
ids=[
|
||||
"doorbell-category",
|
||||
"doorbell-strength",
|
||||
"chime-category",
|
||||
"chime-strength",
|
||||
"stickup_cam-category",
|
||||
"stickup_cam-strength",
|
||||
],
|
||||
)
|
||||
async def test_health_sensor(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_id,
|
||||
device_name,
|
||||
sensor_name,
|
||||
expected_value,
|
||||
) -> None:
|
||||
"""Test the Ring health sensors."""
|
||||
entity_id = f"sensor.{device_name}_{sensor_name}"
|
||||
# Enable the sensor as the health sensors are disabled by default
|
||||
entity_entry = entity_registry.async_get_or_create(
|
||||
"sensor",
|
||||
"ring",
|
||||
f"{device_id}-{sensor_name}",
|
||||
suggested_object_id=f"{device_name}_{sensor_name}",
|
||||
disabled_by=None,
|
||||
)
|
||||
assert entity_entry.disabled is False
|
||||
assert entity_entry.entity_id == entity_id
|
||||
|
||||
await setup_platform(hass, "sensor")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
sensor_state = hass.states.get(entity_id)
|
||||
assert sensor_state is not None
|
||||
assert sensor_state.state == "unknown"
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
sensor_state = hass.states.get(entity_id)
|
||||
assert sensor_state is not None
|
||||
assert sensor_state.state == expected_value
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_id", "device_name", "sensor_name", "expected_value"),
|
||||
[
|
||||
(
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
"front_door",
|
||||
"last_motion",
|
||||
"2017-03-05T15:03:40+00:00",
|
||||
),
|
||||
(FRONT_DOOR_DEVICE_ID, "front_door", "last_ding", "2018-03-05T15:03:40+00:00"),
|
||||
(
|
||||
FRONT_DOOR_DEVICE_ID,
|
||||
"front_door",
|
||||
"last_activity",
|
||||
"2018-03-05T15:03:40+00:00",
|
||||
),
|
||||
(FRONT_DEVICE_ID, "front", "last_motion", "2017-03-05T15:03:40+00:00"),
|
||||
(INGRESS_DEVICE_ID, "ingress", "last_activity", "2024-02-02T11:21:24+00:00"),
|
||||
],
|
||||
ids=[
|
||||
"doorbell-motion",
|
||||
"doorbell-ding",
|
||||
"doorbell-activity",
|
||||
"stickup_cam-motion",
|
||||
"other-activity",
|
||||
],
|
||||
)
|
||||
async def test_history_sensor(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Ring,
|
||||
mock_config_entry: ConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
device_id: int,
|
||||
device_name: str,
|
||||
sensor_name: str,
|
||||
expected_value: str,
|
||||
) -> None:
|
||||
"""Test the Ring sensors."""
|
||||
# Create the entity so it is not ignored by the deprecation check
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
entity_id = f"sensor.{device_name}_{sensor_name}"
|
||||
unique_id = f"{device_id}-{sensor_name}"
|
||||
|
||||
entity_registry.async_get_or_create(
|
||||
domain=SENSOR_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id=f"{device_name}_{sensor_name}",
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [Platform.SENSOR]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
entity_id = f"sensor.{device_name}_{sensor_name}"
|
||||
sensor_state = hass.states.get(entity_id)
|
||||
assert sensor_state is not None
|
||||
assert sensor_state.state == "unknown"
|
||||
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
sensor_state = hass.states.get(entity_id)
|
||||
assert sensor_state is not None
|
||||
assert sensor_state.state == expected_value
|
||||
|
||||
|
||||
async def test_only_chime_devices(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Tests the update service works correctly if only chimes are returned."""
|
||||
await hass.config.async_set_time_zone("UTC")
|
||||
freezer.move_to("2021-01-09 12:00:00+00:00")
|
||||
|
||||
mock_ring_devices.all_devices = mock_ring_devices.chimes
|
||||
|
||||
await setup_platform(hass, Platform.SENSOR)
|
||||
await hass.async_block_till_done()
|
||||
caplog.set_level(logging.DEBUG)
|
||||
caplog.clear()
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "UnboundLocalError" not in caplog.text # For issue #109210
|
||||
235
home-assistant/tests/components/ring/test_siren.py
Normal file
235
home-assistant/tests/components/ring/test_siren.py
Normal file
@@ -0,0 +1,235 @@
|
||||
"""The tests for the Ring button platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.siren import DOMAIN as SIREN_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_entity_registry(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_ring_client,
|
||||
) -> None:
|
||||
"""Tests that the devices are registered in the entity registry."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
entry = entity_registry.async_get("siren.downstairs_siren")
|
||||
assert entry.unique_id == "123456-siren"
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_sirens_report_correctly(hass: HomeAssistant, mock_ring_client) -> None:
|
||||
"""Tests that the initial state of a device that should be on is correct."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
state = hass.states.get("siren.downstairs_siren")
|
||||
assert state.attributes.get("friendly_name") == "Downstairs Siren"
|
||||
assert state.state == "unknown"
|
||||
|
||||
|
||||
async def test_default_ding_chime_can_be_played(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the play chime request is sent correctly."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": "siren.downstairs_siren"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(123456)
|
||||
downstairs_chime_mock.async_test_sound.assert_called_once_with(kind="ding")
|
||||
|
||||
state = hass.states.get("siren.downstairs_siren")
|
||||
assert state.state == "unknown"
|
||||
|
||||
|
||||
async def test_turn_on_plays_default_chime(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the play chime request is sent correctly when turned on."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": "siren.downstairs_siren"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(123456)
|
||||
downstairs_chime_mock.async_test_sound.assert_called_once_with(kind="ding")
|
||||
|
||||
state = hass.states.get("siren.downstairs_siren")
|
||||
assert state.state == "unknown"
|
||||
|
||||
|
||||
async def test_explicit_ding_chime_can_be_played(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
) -> None:
|
||||
"""Tests the play chime request is sent correctly."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": "siren.downstairs_siren", "tone": "ding"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(123456)
|
||||
downstairs_chime_mock.async_test_sound.assert_called_once_with(kind="ding")
|
||||
|
||||
state = hass.states.get("siren.downstairs_siren")
|
||||
assert state.state == "unknown"
|
||||
|
||||
|
||||
async def test_motion_chime_can_be_played(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests the play chime request is sent correctly."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": "siren.downstairs_siren", "tone": "motion"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(123456)
|
||||
downstairs_chime_mock.async_test_sound.assert_called_once_with(kind="motion")
|
||||
|
||||
state = hass.states.get("siren.downstairs_siren")
|
||||
assert state.state == "unknown"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, True),
|
||||
(ring_doorbell.RingTimeout, False),
|
||||
(ring_doorbell.RingError, False),
|
||||
],
|
||||
ids=["Authentication", "Timeout", "Other"],
|
||||
)
|
||||
async def test_siren_errors_when_turned_on(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
exception_type,
|
||||
reauth_expected,
|
||||
) -> None:
|
||||
"""Tests the siren turns on correctly."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
config_entry = hass.config_entries.async_entries("ring")[0]
|
||||
|
||||
assert not any(config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(123456)
|
||||
downstairs_chime_mock.async_test_sound.side_effect = exception_type
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": "siren.downstairs_siren", "tone": "motion"},
|
||||
blocking=True,
|
||||
)
|
||||
downstairs_chime_mock.async_test_sound.assert_called_once_with(kind="motion")
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
any(
|
||||
flow
|
||||
for flow in config_entry.async_get_active_flows(hass, {SOURCE_REAUTH})
|
||||
if flow["handler"] == "ring"
|
||||
)
|
||||
== reauth_expected
|
||||
)
|
||||
|
||||
|
||||
async def test_camera_siren_on_off(
|
||||
hass: HomeAssistant, mock_ring_client, mock_ring_devices
|
||||
) -> None:
|
||||
"""Tests siren on a ring camera turns on and off."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
||||
entity_id = "siren.front_siren"
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
SIREN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
downstairs_chime_mock = mock_ring_devices.get_device(765432)
|
||||
downstairs_chime_mock.async_set_siren.assert_called_once_with(1)
|
||||
|
||||
downstairs_chime_mock.async_set_siren.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
SIREN_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
downstairs_chime_mock.async_set_siren.assert_called_once_with(0)
|
||||
|
||||
assert state.state == STATE_OFF
|
||||
171
home-assistant/tests/components/ring/test_switch.py
Normal file
171
home-assistant/tests/components/ring/test_switch.py
Normal file
@@ -0,0 +1,171 @@
|
||||
"""The tests for the Ring switch platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.ring.const import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_deprecated_siren_entity(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: ConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
):
|
||||
"""Create the entity so it is not ignored by the deprecation check."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
def create_entry(device_name, device_id):
|
||||
unique_id = f"{device_id}-siren"
|
||||
|
||||
entity_registry.async_get_or_create(
|
||||
domain=SWITCH_DOMAIN,
|
||||
platform=DOMAIN,
|
||||
unique_id=unique_id,
|
||||
suggested_object_id=f"{device_name}_siren",
|
||||
config_entry=mock_config_entry,
|
||||
)
|
||||
|
||||
create_entry("front", 765432)
|
||||
create_entry("internal", 345678)
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
create_deprecated_siren_entity,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_siren_off_reports_correctly(
|
||||
hass: HomeAssistant, mock_ring_client, create_deprecated_siren_entity
|
||||
) -> None:
|
||||
"""Tests that the initial state of a device that should be off is correct."""
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
|
||||
state = hass.states.get("switch.front_siren")
|
||||
assert state.state == "off"
|
||||
assert state.attributes.get("friendly_name") == "Front Siren"
|
||||
|
||||
|
||||
async def test_siren_on_reports_correctly(
|
||||
hass: HomeAssistant, mock_ring_client, create_deprecated_siren_entity
|
||||
) -> None:
|
||||
"""Tests that the initial state of a device that should be on is correct."""
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
|
||||
state = hass.states.get("switch.internal_siren")
|
||||
assert state.state == "on"
|
||||
assert state.attributes.get("friendly_name") == "Internal Siren"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id"),
|
||||
[
|
||||
("switch.front_siren"),
|
||||
("switch.front_door_in_home_chime"),
|
||||
("switch.front_motion_detection"),
|
||||
],
|
||||
)
|
||||
async def test_switch_can_be_turned_on_and_off(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
create_deprecated_siren_entity,
|
||||
entity_id,
|
||||
) -> None:
|
||||
"""Tests the switch turns on and off correctly."""
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
|
||||
assert hass.states.get(entity_id)
|
||||
|
||||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("exception_type", "reauth_expected"),
|
||||
[
|
||||
(ring_doorbell.AuthenticationError, True),
|
||||
(ring_doorbell.RingTimeout, False),
|
||||
(ring_doorbell.RingError, False),
|
||||
],
|
||||
ids=["Authentication", "Timeout", "Other"],
|
||||
)
|
||||
async def test_switch_errors_when_turned_on(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client,
|
||||
mock_ring_devices,
|
||||
exception_type,
|
||||
reauth_expected,
|
||||
create_deprecated_siren_entity,
|
||||
) -> None:
|
||||
"""Tests the switch turns on correctly."""
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
config_entry = hass.config_entries.async_entries("ring")[0]
|
||||
|
||||
assert not any(config_entry.async_get_active_flows(hass, {SOURCE_REAUTH}))
|
||||
|
||||
front_siren_mock = mock_ring_devices.get_device(765432)
|
||||
front_siren_mock.async_set_siren.side_effect = exception_type
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
"switch", "turn_on", {"entity_id": "switch.front_siren"}, blocking=True
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
front_siren_mock.async_set_siren.assert_called_once()
|
||||
assert (
|
||||
any(
|
||||
flow
|
||||
for flow in config_entry.async_get_active_flows(hass, {SOURCE_REAUTH})
|
||||
if flow["handler"] == "ring"
|
||||
)
|
||||
== reauth_expected
|
||||
)
|
||||
Reference in New Issue
Block a user