mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Remove deprecated services from Ezviz (#107582)
This commit is contained in:
parent
29cac5b093
commit
71dcbb95ab
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyezviz.exceptions import HTTPError, InvalidHost, PyEzvizError
|
from pyezviz.exceptions import HTTPError, InvalidHost, PyEzvizError
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components import ffmpeg
|
from homeassistant.components import ffmpeg
|
||||||
from homeassistant.components.camera import Camera, CameraEntityFeature
|
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||||
@ -17,34 +16,19 @@ from homeassistant.config_entries import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import discovery_flow
|
||||||
config_validation as cv,
|
|
||||||
discovery_flow,
|
|
||||||
issue_registry as ir,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.entity_platform import (
|
from homeassistant.helpers.entity_platform import (
|
||||||
AddEntitiesCallback,
|
AddEntitiesCallback,
|
||||||
async_get_current_platform,
|
async_get_current_platform,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_DIRECTION,
|
|
||||||
ATTR_ENABLE,
|
|
||||||
ATTR_LEVEL,
|
|
||||||
ATTR_SERIAL,
|
ATTR_SERIAL,
|
||||||
ATTR_SPEED,
|
|
||||||
CONF_FFMPEG_ARGUMENTS,
|
CONF_FFMPEG_ARGUMENTS,
|
||||||
DATA_COORDINATOR,
|
DATA_COORDINATOR,
|
||||||
DEFAULT_CAMERA_USERNAME,
|
DEFAULT_CAMERA_USERNAME,
|
||||||
DEFAULT_FFMPEG_ARGUMENTS,
|
DEFAULT_FFMPEG_ARGUMENTS,
|
||||||
DIR_DOWN,
|
|
||||||
DIR_LEFT,
|
|
||||||
DIR_RIGHT,
|
|
||||||
DIR_UP,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_ALARM_SOUND,
|
|
||||||
SERVICE_ALARM_TRIGGER,
|
|
||||||
SERVICE_PTZ,
|
|
||||||
SERVICE_WAKE_DEVICE,
|
SERVICE_WAKE_DEVICE,
|
||||||
)
|
)
|
||||||
from .coordinator import EzvizDataUpdateCoordinator
|
from .coordinator import EzvizDataUpdateCoordinator
|
||||||
@ -126,35 +110,10 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
platform = async_get_current_platform()
|
platform = async_get_current_platform()
|
||||||
|
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_PTZ,
|
|
||||||
{
|
|
||||||
vol.Required(ATTR_DIRECTION): vol.In(
|
|
||||||
[DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT]
|
|
||||||
),
|
|
||||||
vol.Required(ATTR_SPEED): cv.positive_int,
|
|
||||||
},
|
|
||||||
"perform_ptz",
|
|
||||||
)
|
|
||||||
|
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_ALARM_TRIGGER,
|
|
||||||
{
|
|
||||||
vol.Required(ATTR_ENABLE): cv.positive_int,
|
|
||||||
},
|
|
||||||
"perform_sound_alarm",
|
|
||||||
)
|
|
||||||
|
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
SERVICE_WAKE_DEVICE, {}, "perform_wake_device"
|
SERVICE_WAKE_DEVICE, {}, "perform_wake_device"
|
||||||
)
|
)
|
||||||
|
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_ALARM_SOUND,
|
|
||||||
{vol.Required(ATTR_LEVEL): cv.positive_int},
|
|
||||||
"perform_alarm_sound",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EzvizCamera(EzvizEntity, Camera):
|
class EzvizCamera(EzvizEntity, Camera):
|
||||||
"""An implementation of a EZVIZ security camera."""
|
"""An implementation of a EZVIZ security camera."""
|
||||||
@ -251,70 +210,9 @@ class EzvizCamera(EzvizEntity, Camera):
|
|||||||
|
|
||||||
return self._rtsp_stream
|
return self._rtsp_stream
|
||||||
|
|
||||||
def perform_ptz(self, direction: str, speed: int) -> None:
|
|
||||||
"""Perform a PTZ action on the camera."""
|
|
||||||
ir.async_create_issue(
|
|
||||||
self.hass,
|
|
||||||
DOMAIN,
|
|
||||||
"service_depreciation_ptz",
|
|
||||||
breaks_in_ha_version="2024.2.0",
|
|
||||||
is_fixable=True,
|
|
||||||
is_persistent=True,
|
|
||||||
severity=ir.IssueSeverity.WARNING,
|
|
||||||
translation_key="service_depreciation_ptz",
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.coordinator.ezviz_client.ptz_control(
|
|
||||||
str(direction).upper(), self._serial, "START", speed
|
|
||||||
)
|
|
||||||
self.coordinator.ezviz_client.ptz_control(
|
|
||||||
str(direction).upper(), self._serial, "STOP", speed
|
|
||||||
)
|
|
||||||
|
|
||||||
except HTTPError as err:
|
|
||||||
raise HTTPError("Cannot perform PTZ") from err
|
|
||||||
|
|
||||||
def perform_sound_alarm(self, enable: int) -> None:
|
|
||||||
"""Sound the alarm on a camera."""
|
|
||||||
ir.async_create_issue(
|
|
||||||
self.hass,
|
|
||||||
DOMAIN,
|
|
||||||
"service_depreciation_sound_alarm",
|
|
||||||
breaks_in_ha_version="2024.3.0",
|
|
||||||
is_fixable=True,
|
|
||||||
is_persistent=True,
|
|
||||||
severity=ir.IssueSeverity.WARNING,
|
|
||||||
translation_key="service_depreciation_sound_alarm",
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.coordinator.ezviz_client.sound_alarm(self._serial, enable)
|
|
||||||
except HTTPError as err:
|
|
||||||
raise HTTPError("Cannot sound alarm") from err
|
|
||||||
|
|
||||||
def perform_wake_device(self) -> None:
|
def perform_wake_device(self) -> None:
|
||||||
"""Basically wakes the camera by querying the device."""
|
"""Basically wakes the camera by querying the device."""
|
||||||
try:
|
try:
|
||||||
self.coordinator.ezviz_client.get_detection_sensibility(self._serial)
|
self.coordinator.ezviz_client.get_detection_sensibility(self._serial)
|
||||||
except (HTTPError, PyEzvizError) as err:
|
except (HTTPError, PyEzvizError) as err:
|
||||||
raise PyEzvizError("Cannot wake device") from err
|
raise PyEzvizError("Cannot wake device") from err
|
||||||
|
|
||||||
def perform_alarm_sound(self, level: int) -> None:
|
|
||||||
"""Enable/Disable movement sound alarm."""
|
|
||||||
ir.async_create_issue(
|
|
||||||
self.hass,
|
|
||||||
DOMAIN,
|
|
||||||
"service_deprecation_alarm_sound_level",
|
|
||||||
breaks_in_ha_version="2024.2.0",
|
|
||||||
is_fixable=True,
|
|
||||||
is_persistent=True,
|
|
||||||
severity=ir.IssueSeverity.WARNING,
|
|
||||||
translation_key="service_deprecation_alarm_sound_level",
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
self.coordinator.ezviz_client.alarm_sound(self._serial, level, 1)
|
|
||||||
except HTTPError as err:
|
|
||||||
raise HTTPError(
|
|
||||||
"Cannot set alarm sound level for on movement detected"
|
|
||||||
) from err
|
|
||||||
|
@ -24,10 +24,7 @@ ATTR_LEVEL = "level"
|
|||||||
ATTR_TYPE = "type_value"
|
ATTR_TYPE = "type_value"
|
||||||
|
|
||||||
# Service names
|
# Service names
|
||||||
SERVICE_PTZ = "ptz"
|
|
||||||
SERVICE_ALARM_TRIGGER = "sound_alarm"
|
|
||||||
SERVICE_WAKE_DEVICE = "wake_device"
|
SERVICE_WAKE_DEVICE = "wake_device"
|
||||||
SERVICE_ALARM_SOUND = "alarm_sound"
|
|
||||||
SERVICE_DETECTION_SENSITIVITY = "set_alarm_detection_sensibility"
|
SERVICE_DETECTION_SENSITIVITY = "set_alarm_detection_sensibility"
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
|
@ -1,46 +1,3 @@
|
|||||||
alarm_sound:
|
|
||||||
target:
|
|
||||||
entity:
|
|
||||||
integration: ezviz
|
|
||||||
domain: camera
|
|
||||||
fields:
|
|
||||||
level:
|
|
||||||
required: true
|
|
||||||
example: 0
|
|
||||||
default: 0
|
|
||||||
selector:
|
|
||||||
number:
|
|
||||||
min: 0
|
|
||||||
max: 2
|
|
||||||
step: 1
|
|
||||||
mode: box
|
|
||||||
ptz:
|
|
||||||
target:
|
|
||||||
entity:
|
|
||||||
integration: ezviz
|
|
||||||
domain: camera
|
|
||||||
fields:
|
|
||||||
direction:
|
|
||||||
required: true
|
|
||||||
example: "up"
|
|
||||||
default: "up"
|
|
||||||
selector:
|
|
||||||
select:
|
|
||||||
options:
|
|
||||||
- "up"
|
|
||||||
- "down"
|
|
||||||
- "left"
|
|
||||||
- "right"
|
|
||||||
speed:
|
|
||||||
required: true
|
|
||||||
example: 5
|
|
||||||
default: 5
|
|
||||||
selector:
|
|
||||||
number:
|
|
||||||
min: 1
|
|
||||||
max: 9
|
|
||||||
step: 1
|
|
||||||
mode: box
|
|
||||||
set_alarm_detection_sensibility:
|
set_alarm_detection_sensibility:
|
||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
@ -66,22 +23,7 @@ set_alarm_detection_sensibility:
|
|||||||
options:
|
options:
|
||||||
- "0"
|
- "0"
|
||||||
- "3"
|
- "3"
|
||||||
sound_alarm:
|
|
||||||
target:
|
|
||||||
entity:
|
|
||||||
integration: ezviz
|
|
||||||
domain: camera
|
|
||||||
fields:
|
|
||||||
enable:
|
|
||||||
required: true
|
|
||||||
example: 1
|
|
||||||
default: 1
|
|
||||||
selector:
|
|
||||||
number:
|
|
||||||
min: 1
|
|
||||||
max: 2
|
|
||||||
step: 1
|
|
||||||
mode: box
|
|
||||||
wake_device:
|
wake_device:
|
||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
|
@ -59,41 +59,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"issues": {
|
|
||||||
"service_deprecation_alarm_sound_level": {
|
|
||||||
"title": "Ezviz Alarm sound level service is being removed",
|
|
||||||
"fix_flow": {
|
|
||||||
"step": {
|
|
||||||
"confirm": {
|
|
||||||
"title": "[%key:component::ezviz::issues::service_deprecation_alarm_sound_level::title%]",
|
|
||||||
"description": "Ezviz Alarm sound level service is deprecated and will be removed.\nTo set the Alarm sound level, you can instead use the `select.select_option` service targetting the Warning sound entity.\n\nPlease remove this service from your automations and scripts and select **submit** to close this issue."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"service_depreciation_ptz": {
|
|
||||||
"title": "EZVIZ PTZ service is being removed",
|
|
||||||
"fix_flow": {
|
|
||||||
"step": {
|
|
||||||
"confirm": {
|
|
||||||
"title": "[%key:component::ezviz::issues::service_depreciation_ptz::title%]",
|
|
||||||
"description": "EZVIZ PTZ service is deprecated and will be removed.\nTo move the camera, you can instead use the `button.press` service targetting the PTZ* entities.\n\nPlease remove the use of this service from your automations and scripts and select **submit** to close this issue."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"service_depreciation_sound_alarm": {
|
|
||||||
"title": "Ezviz Sound alarm service is being removed",
|
|
||||||
"fix_flow": {
|
|
||||||
"step": {
|
|
||||||
"confirm": {
|
|
||||||
"title": "[%key:component::ezviz::issues::service_depreciation_sound_alarm::title%]",
|
|
||||||
"description": "Ezviz Sound alarm service is deprecated and will be removed.\nTo sound the alarm, you can instead use the `siren.toggle` service targeting the Siren entity.\n\nPlease remove the use of this service from your automations and scripts and select **submit** to fix this issue."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"entity": {
|
"entity": {
|
||||||
"select": {
|
"select": {
|
||||||
"alarm_sound_mode": {
|
"alarm_sound_mode": {
|
||||||
@ -219,30 +184,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"alarm_sound": {
|
|
||||||
"name": "Set warning sound level.",
|
|
||||||
"description": "Setx movement warning sound level.",
|
|
||||||
"fields": {
|
|
||||||
"level": {
|
|
||||||
"name": "Sound level",
|
|
||||||
"description": "Sound level (2 is disabled, 1 intensive, 0 soft)."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ptz": {
|
|
||||||
"name": "PTZ",
|
|
||||||
"description": "Moves the camera to the direction, with defined speed.",
|
|
||||||
"fields": {
|
|
||||||
"direction": {
|
|
||||||
"name": "Direction",
|
|
||||||
"description": "Direction to move camera (up, down, left, right)."
|
|
||||||
},
|
|
||||||
"speed": {
|
|
||||||
"name": "Speed",
|
|
||||||
"description": "Speed of movement (from 1 to 9)."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"set_alarm_detection_sensibility": {
|
"set_alarm_detection_sensibility": {
|
||||||
"name": "Detection sensitivity",
|
"name": "Detection sensitivity",
|
||||||
"description": "Sets the detection sensibility level.",
|
"description": "Sets the detection sensibility level.",
|
||||||
@ -257,16 +198,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sound_alarm": {
|
|
||||||
"name": "Sound alarm",
|
|
||||||
"description": "Sounds the alarm on your camera.",
|
|
||||||
"fields": {
|
|
||||||
"enable": {
|
|
||||||
"name": "Alarm sound",
|
|
||||||
"description": "Enter 1 or 2 (1=disable, 2=enable)."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wake_device": {
|
"wake_device": {
|
||||||
"name": "Wake camera",
|
"name": "Wake camera",
|
||||||
"description": "This can be used to wake the camera/device from hibernation."
|
"description": "This can be used to wake the camera/device from hibernation."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user