mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Remove ssh switch from unsupported devices for UniFi Protect (#71859)
This commit is contained in:
parent
ba7d397704
commit
fdc8830dd3
@ -43,7 +43,7 @@ async def _set_highfps(obj: Camera, value: bool) -> None:
|
|||||||
await obj.set_video_mode(VideoMode.DEFAULT)
|
await obj.set_video_mode(VideoMode.DEFAULT)
|
||||||
|
|
||||||
|
|
||||||
ALL_DEVICES_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
||||||
ProtectSwitchEntityDescription(
|
ProtectSwitchEntityDescription(
|
||||||
key="ssh",
|
key="ssh",
|
||||||
name="SSH Enabled",
|
name="SSH Enabled",
|
||||||
@ -53,9 +53,6 @@ ALL_DEVICES_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|||||||
ufp_value="is_ssh_enabled",
|
ufp_value="is_ssh_enabled",
|
||||||
ufp_set_method="set_ssh",
|
ufp_set_method="set_ssh",
|
||||||
),
|
),
|
||||||
)
|
|
||||||
|
|
||||||
CAMERA_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|
||||||
ProtectSwitchEntityDescription(
|
ProtectSwitchEntityDescription(
|
||||||
key="status_light",
|
key="status_light",
|
||||||
name="Status Light On",
|
name="Status Light On",
|
||||||
@ -222,6 +219,15 @@ SENSE_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|||||||
|
|
||||||
|
|
||||||
LIGHT_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
LIGHT_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
||||||
|
ProtectSwitchEntityDescription(
|
||||||
|
key="ssh",
|
||||||
|
name="SSH Enabled",
|
||||||
|
icon="mdi:lock",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
ufp_value="is_ssh_enabled",
|
||||||
|
ufp_set_method="set_ssh",
|
||||||
|
),
|
||||||
ProtectSwitchEntityDescription(
|
ProtectSwitchEntityDescription(
|
||||||
key="status_light",
|
key="status_light",
|
||||||
name="Status Light On",
|
name="Status Light On",
|
||||||
@ -243,6 +249,18 @@ DOORLOCK_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
VIEWER_SWITCHES: tuple[ProtectSwitchEntityDescription, ...] = (
|
||||||
|
ProtectSwitchEntityDescription(
|
||||||
|
key="ssh",
|
||||||
|
name="SSH Enabled",
|
||||||
|
icon="mdi:lock",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
ufp_value="is_ssh_enabled",
|
||||||
|
ufp_set_method="set_ssh",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -254,11 +272,11 @@ async def async_setup_entry(
|
|||||||
entities: list[ProtectDeviceEntity] = async_all_device_entities(
|
entities: list[ProtectDeviceEntity] = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectSwitch,
|
ProtectSwitch,
|
||||||
all_descs=ALL_DEVICES_SWITCHES,
|
|
||||||
camera_descs=CAMERA_SWITCHES,
|
camera_descs=CAMERA_SWITCHES,
|
||||||
light_descs=LIGHT_SWITCHES,
|
light_descs=LIGHT_SWITCHES,
|
||||||
sense_descs=SENSE_SWITCHES,
|
sense_descs=SENSE_SWITCHES,
|
||||||
lock_descs=DOORLOCK_SWITCHES,
|
lock_descs=DOORLOCK_SWITCHES,
|
||||||
|
viewer_descs=VIEWER_SWITCHES,
|
||||||
)
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ from pyunifiprotect.data.types import RecordingMode, SmartDetectObjectType, Vide
|
|||||||
|
|
||||||
from homeassistant.components.unifiprotect.const import DEFAULT_ATTRIBUTION
|
from homeassistant.components.unifiprotect.const import DEFAULT_ATTRIBUTION
|
||||||
from homeassistant.components.unifiprotect.switch import (
|
from homeassistant.components.unifiprotect.switch import (
|
||||||
ALL_DEVICES_SWITCHES,
|
|
||||||
CAMERA_SWITCHES,
|
CAMERA_SWITCHES,
|
||||||
LIGHT_SWITCHES,
|
LIGHT_SWITCHES,
|
||||||
ProtectSwitchEntityDescription,
|
ProtectSwitchEntityDescription,
|
||||||
@ -29,7 +28,9 @@ from .conftest import (
|
|||||||
CAMERA_SWITCHES_BASIC = [
|
CAMERA_SWITCHES_BASIC = [
|
||||||
d
|
d
|
||||||
for d in CAMERA_SWITCHES
|
for d in CAMERA_SWITCHES
|
||||||
if d.name != "Detections: Face" and d.name != "Detections: Package"
|
if d.name != "Detections: Face"
|
||||||
|
and d.name != "Detections: Package"
|
||||||
|
and d.name != "SSH Enabled"
|
||||||
]
|
]
|
||||||
CAMERA_SWITCHES_NO_EXTRA = [
|
CAMERA_SWITCHES_NO_EXTRA = [
|
||||||
d for d in CAMERA_SWITCHES_BASIC if d.name not in ("High FPS", "Privacy Mode")
|
d for d in CAMERA_SWITCHES_BASIC if d.name not in ("High FPS", "Privacy Mode")
|
||||||
@ -215,7 +216,7 @@ async def test_switch_setup_light(
|
|||||||
|
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
description = LIGHT_SWITCHES[0]
|
description = LIGHT_SWITCHES[1]
|
||||||
|
|
||||||
unique_id, entity_id = ids_from_device_description(
|
unique_id, entity_id = ids_from_device_description(
|
||||||
Platform.SWITCH, light, description
|
Platform.SWITCH, light, description
|
||||||
@ -230,7 +231,7 @@ async def test_switch_setup_light(
|
|||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
||||||
|
|
||||||
description = ALL_DEVICES_SWITCHES[0]
|
description = LIGHT_SWITCHES[0]
|
||||||
|
|
||||||
unique_id = f"{light.id}_{description.key}"
|
unique_id = f"{light.id}_{description.key}"
|
||||||
entity_id = f"switch.test_light_{description.name.lower().replace(' ', '_')}"
|
entity_id = f"switch.test_light_{description.name.lower().replace(' ', '_')}"
|
||||||
@ -271,7 +272,7 @@ async def test_switch_setup_camera_all(
|
|||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
||||||
|
|
||||||
description = ALL_DEVICES_SWITCHES[0]
|
description = CAMERA_SWITCHES[0]
|
||||||
|
|
||||||
description_entity_name = (
|
description_entity_name = (
|
||||||
description.name.lower().replace(":", "").replace(" ", "_")
|
description.name.lower().replace(":", "").replace(" ", "_")
|
||||||
@ -301,7 +302,7 @@ async def test_switch_setup_camera_none(
|
|||||||
|
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
for description in CAMERA_SWITCHES:
|
for description in CAMERA_SWITCHES_BASIC:
|
||||||
if description.ufp_required_field is not None:
|
if description.ufp_required_field is not None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -318,7 +319,7 @@ async def test_switch_setup_camera_none(
|
|||||||
assert state.state == STATE_OFF
|
assert state.state == STATE_OFF
|
||||||
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION
|
||||||
|
|
||||||
description = ALL_DEVICES_SWITCHES[0]
|
description = CAMERA_SWITCHES[0]
|
||||||
|
|
||||||
description_entity_name = (
|
description_entity_name = (
|
||||||
description.name.lower().replace(":", "").replace(" ", "_")
|
description.name.lower().replace(":", "").replace(" ", "_")
|
||||||
@ -342,7 +343,7 @@ async def test_switch_setup_camera_none(
|
|||||||
async def test_switch_light_status(hass: HomeAssistant, light: Light):
|
async def test_switch_light_status(hass: HomeAssistant, light: Light):
|
||||||
"""Tests status light switch for lights."""
|
"""Tests status light switch for lights."""
|
||||||
|
|
||||||
description = LIGHT_SWITCHES[0]
|
description = LIGHT_SWITCHES[1]
|
||||||
|
|
||||||
light.__fields__["set_status_light"] = Mock()
|
light.__fields__["set_status_light"] = Mock()
|
||||||
light.set_status_light = AsyncMock()
|
light.set_status_light = AsyncMock()
|
||||||
@ -367,7 +368,7 @@ async def test_switch_camera_ssh(
|
|||||||
):
|
):
|
||||||
"""Tests SSH switch for cameras."""
|
"""Tests SSH switch for cameras."""
|
||||||
|
|
||||||
description = ALL_DEVICES_SWITCHES[0]
|
description = CAMERA_SWITCHES[0]
|
||||||
|
|
||||||
camera.__fields__["set_ssh"] = Mock()
|
camera.__fields__["set_ssh"] = Mock()
|
||||||
camera.set_ssh = AsyncMock()
|
camera.set_ssh = AsyncMock()
|
||||||
@ -418,7 +419,7 @@ async def test_switch_camera_simple(
|
|||||||
async def test_switch_camera_highfps(hass: HomeAssistant, camera: Camera):
|
async def test_switch_camera_highfps(hass: HomeAssistant, camera: Camera):
|
||||||
"""Tests High FPS switch for cameras."""
|
"""Tests High FPS switch for cameras."""
|
||||||
|
|
||||||
description = CAMERA_SWITCHES[2]
|
description = CAMERA_SWITCHES[3]
|
||||||
|
|
||||||
camera.__fields__["set_video_mode"] = Mock()
|
camera.__fields__["set_video_mode"] = Mock()
|
||||||
camera.set_video_mode = AsyncMock()
|
camera.set_video_mode = AsyncMock()
|
||||||
@ -441,7 +442,7 @@ async def test_switch_camera_highfps(hass: HomeAssistant, camera: Camera):
|
|||||||
async def test_switch_camera_privacy(hass: HomeAssistant, camera: Camera):
|
async def test_switch_camera_privacy(hass: HomeAssistant, camera: Camera):
|
||||||
"""Tests Privacy Mode switch for cameras."""
|
"""Tests Privacy Mode switch for cameras."""
|
||||||
|
|
||||||
description = CAMERA_SWITCHES[3]
|
description = CAMERA_SWITCHES[4]
|
||||||
|
|
||||||
camera.__fields__["set_privacy"] = Mock()
|
camera.__fields__["set_privacy"] = Mock()
|
||||||
camera.set_privacy = AsyncMock()
|
camera.set_privacy = AsyncMock()
|
||||||
@ -468,7 +469,7 @@ async def test_switch_camera_privacy_already_on(
|
|||||||
):
|
):
|
||||||
"""Tests Privacy Mode switch for cameras with privacy mode defaulted on."""
|
"""Tests Privacy Mode switch for cameras with privacy mode defaulted on."""
|
||||||
|
|
||||||
description = CAMERA_SWITCHES[3]
|
description = CAMERA_SWITCHES[4]
|
||||||
|
|
||||||
camera_privacy.__fields__["set_privacy"] = Mock()
|
camera_privacy.__fields__["set_privacy"] = Mock()
|
||||||
camera_privacy.set_privacy = AsyncMock()
|
camera_privacy.set_privacy = AsyncMock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user