mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add Reolink chime package ringtone (#125786)
* add chime package ringtone * fix mypy * fix mypy * fix mypy * fixes
This commit is contained in:
parent
bcbf810cbe
commit
e8bacd84ce
@ -34,6 +34,14 @@ class ReolinkHostEntityDescription(EntityDescription):
|
|||||||
supported: Callable[[Host], bool] = lambda api: True
|
supported: Callable[[Host], bool] = lambda api: True
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, kw_only=True)
|
||||||
|
class ReolinkChimeEntityDescription(EntityDescription):
|
||||||
|
"""A class that describes entities for a chime."""
|
||||||
|
|
||||||
|
cmd_key: str | None = None
|
||||||
|
supported: Callable[[Chime], bool] = lambda chime: True
|
||||||
|
|
||||||
|
|
||||||
class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
|
class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
|
||||||
"""Parent class for entities that control the Reolink NVR itself, without a channel.
|
"""Parent class for entities that control the Reolink NVR itself, without a channel.
|
||||||
|
|
||||||
@ -42,7 +50,11 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
entity_description: ReolinkHostEntityDescription | ReolinkChannelEntityDescription
|
entity_description: (
|
||||||
|
ReolinkHostEntityDescription
|
||||||
|
| ReolinkChannelEntityDescription
|
||||||
|
| ReolinkChimeEntityDescription
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -102,7 +114,7 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]
|
|||||||
class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||||
"""Parent class for Reolink hardware camera entities connected to a channel of the NVR."""
|
"""Parent class for Reolink hardware camera entities connected to a channel of the NVR."""
|
||||||
|
|
||||||
entity_description: ReolinkChannelEntityDescription
|
entity_description: ReolinkChannelEntityDescription | ReolinkChimeEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -164,6 +176,8 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
|||||||
class ReolinkChimeCoordinatorEntity(ReolinkChannelCoordinatorEntity):
|
class ReolinkChimeCoordinatorEntity(ReolinkChannelCoordinatorEntity):
|
||||||
"""Parent class for Reolink chime entities connected."""
|
"""Parent class for Reolink chime entities connected."""
|
||||||
|
|
||||||
|
entity_description: ReolinkChimeEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
reolink_data: ReolinkData,
|
reolink_data: ReolinkData,
|
||||||
|
@ -101,7 +101,10 @@
|
|||||||
"default": "mdi:spotlight-beam"
|
"default": "mdi:spotlight-beam"
|
||||||
},
|
},
|
||||||
"volume": {
|
"volume": {
|
||||||
"default": "mdi:volume-high"
|
"default": "mdi:volume-high",
|
||||||
|
"state": {
|
||||||
|
"0": "mdi:volume-off"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"guard_return_time": {
|
"guard_return_time": {
|
||||||
"default": "mdi:crosshairs-gps"
|
"default": "mdi:crosshairs-gps"
|
||||||
@ -208,13 +211,28 @@
|
|||||||
"default": "mdi:hdr"
|
"default": "mdi:hdr"
|
||||||
},
|
},
|
||||||
"motion_tone": {
|
"motion_tone": {
|
||||||
"default": "mdi:music-note"
|
"default": "mdi:music-note",
|
||||||
|
"state": {
|
||||||
|
"off": "mdi:music-note-off"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"people_tone": {
|
"people_tone": {
|
||||||
"default": "mdi:music-note"
|
"default": "mdi:music-note",
|
||||||
|
"state": {
|
||||||
|
"off": "mdi:music-note-off"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"visitor_tone": {
|
"visitor_tone": {
|
||||||
"default": "mdi:music-note"
|
"default": "mdi:music-note",
|
||||||
|
"state": {
|
||||||
|
"off": "mdi:music-note-off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"package_tone": {
|
||||||
|
"default": "mdi:music-note",
|
||||||
|
"state": {
|
||||||
|
"off": "mdi:music-note-off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
@ -23,6 +23,7 @@ from .entity import (
|
|||||||
ReolinkChannelCoordinatorEntity,
|
ReolinkChannelCoordinatorEntity,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChannelEntityDescription,
|
||||||
ReolinkChimeCoordinatorEntity,
|
ReolinkChimeCoordinatorEntity,
|
||||||
|
ReolinkChimeEntityDescription,
|
||||||
)
|
)
|
||||||
from .util import ReolinkConfigEntry, ReolinkData
|
from .util import ReolinkConfigEntry, ReolinkData
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ class ReolinkNumberEntityDescription(
|
|||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class ReolinkChimeNumberEntityDescription(
|
class ReolinkChimeNumberEntityDescription(
|
||||||
NumberEntityDescription,
|
NumberEntityDescription,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChimeEntityDescription,
|
||||||
):
|
):
|
||||||
"""A class that describes number entities for a chime."""
|
"""A class that describes number entities for a chime."""
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ from .entity import (
|
|||||||
ReolinkChannelCoordinatorEntity,
|
ReolinkChannelCoordinatorEntity,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChannelEntityDescription,
|
||||||
ReolinkChimeCoordinatorEntity,
|
ReolinkChimeCoordinatorEntity,
|
||||||
|
ReolinkChimeEntityDescription,
|
||||||
)
|
)
|
||||||
from .util import ReolinkConfigEntry, ReolinkData
|
from .util import ReolinkConfigEntry, ReolinkData
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class ReolinkSelectEntityDescription(
|
|||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class ReolinkChimeSelectEntityDescription(
|
class ReolinkChimeSelectEntityDescription(
|
||||||
SelectEntityDescription,
|
SelectEntityDescription,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChimeEntityDescription,
|
||||||
):
|
):
|
||||||
"""A class that describes select entities for a chime."""
|
"""A class that describes select entities for a chime."""
|
||||||
|
|
||||||
@ -154,6 +155,7 @@ CHIME_SELECT_ENTITIES = (
|
|||||||
cmd_key="GetDingDongCfg",
|
cmd_key="GetDingDongCfg",
|
||||||
translation_key="motion_tone",
|
translation_key="motion_tone",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
supported=lambda chime: "md" in chime.chime_event_types,
|
||||||
get_options=[method.name for method in ChimeToneEnum],
|
get_options=[method.name for method in ChimeToneEnum],
|
||||||
value=lambda chime: ChimeToneEnum(chime.tone("md")).name,
|
value=lambda chime: ChimeToneEnum(chime.tone("md")).name,
|
||||||
method=lambda chime, name: chime.set_tone("md", ChimeToneEnum[name].value),
|
method=lambda chime, name: chime.set_tone("md", ChimeToneEnum[name].value),
|
||||||
@ -164,6 +166,7 @@ CHIME_SELECT_ENTITIES = (
|
|||||||
translation_key="people_tone",
|
translation_key="people_tone",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
get_options=[method.name for method in ChimeToneEnum],
|
get_options=[method.name for method in ChimeToneEnum],
|
||||||
|
supported=lambda chime: "people" in chime.chime_event_types,
|
||||||
value=lambda chime: ChimeToneEnum(chime.tone("people")).name,
|
value=lambda chime: ChimeToneEnum(chime.tone("people")).name,
|
||||||
method=lambda chime, name: chime.set_tone("people", ChimeToneEnum[name].value),
|
method=lambda chime, name: chime.set_tone("people", ChimeToneEnum[name].value),
|
||||||
),
|
),
|
||||||
@ -173,9 +176,20 @@ CHIME_SELECT_ENTITIES = (
|
|||||||
translation_key="visitor_tone",
|
translation_key="visitor_tone",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
get_options=[method.name for method in ChimeToneEnum],
|
get_options=[method.name for method in ChimeToneEnum],
|
||||||
|
supported=lambda chime: "visitor" in chime.chime_event_types,
|
||||||
value=lambda chime: ChimeToneEnum(chime.tone("visitor")).name,
|
value=lambda chime: ChimeToneEnum(chime.tone("visitor")).name,
|
||||||
method=lambda chime, name: chime.set_tone("visitor", ChimeToneEnum[name].value),
|
method=lambda chime, name: chime.set_tone("visitor", ChimeToneEnum[name].value),
|
||||||
),
|
),
|
||||||
|
ReolinkChimeSelectEntityDescription(
|
||||||
|
key="package_tone",
|
||||||
|
cmd_key="GetDingDongCfg",
|
||||||
|
translation_key="package_tone",
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
get_options=[method.name for method in ChimeToneEnum],
|
||||||
|
supported=lambda chime: "package" in chime.chime_event_types,
|
||||||
|
value=lambda chime: ChimeToneEnum(chime.tone("package")).name,
|
||||||
|
method=lambda chime, name: chime.set_tone("package", ChimeToneEnum[name].value),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -197,6 +211,7 @@ async def async_setup_entry(
|
|||||||
ReolinkChimeSelectEntity(reolink_data, chime, entity_description)
|
ReolinkChimeSelectEntity(reolink_data, chime, entity_description)
|
||||||
for entity_description in CHIME_SELECT_ENTITIES
|
for entity_description in CHIME_SELECT_ENTITIES
|
||||||
for chime in reolink_data.host.api.chime_list
|
for chime in reolink_data.host.api.chime_list
|
||||||
|
if entity_description.supported(chime)
|
||||||
)
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
@ -578,6 +578,22 @@
|
|||||||
"moonlight": "[%key:component::reolink::entity::select::motion_tone::state::moonlight%]",
|
"moonlight": "[%key:component::reolink::entity::select::motion_tone::state::moonlight%]",
|
||||||
"waybackhome": "[%key:component::reolink::entity::select::motion_tone::state::waybackhome%]"
|
"waybackhome": "[%key:component::reolink::entity::select::motion_tone::state::waybackhome%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"package_tone": {
|
||||||
|
"name": "Package ringtone",
|
||||||
|
"state": {
|
||||||
|
"off": "[%key:common::state::off%]",
|
||||||
|
"citybird": "[%key:component::reolink::entity::select::motion_tone::state::citybird%]",
|
||||||
|
"originaltune": "[%key:component::reolink::entity::select::motion_tone::state::originaltune%]",
|
||||||
|
"pianokey": "[%key:component::reolink::entity::select::motion_tone::state::pianokey%]",
|
||||||
|
"loop": "[%key:component::reolink::entity::select::motion_tone::state::loop%]",
|
||||||
|
"attraction": "[%key:component::reolink::entity::select::motion_tone::state::attraction%]",
|
||||||
|
"hophop": "[%key:component::reolink::entity::select::motion_tone::state::hophop%]",
|
||||||
|
"goodday": "[%key:component::reolink::entity::select::motion_tone::state::goodday%]",
|
||||||
|
"operetta": "[%key:component::reolink::entity::select::motion_tone::state::operetta%]",
|
||||||
|
"moonlight": "[%key:component::reolink::entity::select::motion_tone::state::moonlight%]",
|
||||||
|
"waybackhome": "[%key:component::reolink::entity::select::motion_tone::state::waybackhome%]"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
@ -21,6 +21,7 @@ from .entity import (
|
|||||||
ReolinkChannelCoordinatorEntity,
|
ReolinkChannelCoordinatorEntity,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChannelEntityDescription,
|
||||||
ReolinkChimeCoordinatorEntity,
|
ReolinkChimeCoordinatorEntity,
|
||||||
|
ReolinkChimeEntityDescription,
|
||||||
ReolinkHostCoordinatorEntity,
|
ReolinkHostCoordinatorEntity,
|
||||||
ReolinkHostEntityDescription,
|
ReolinkHostEntityDescription,
|
||||||
)
|
)
|
||||||
@ -52,7 +53,7 @@ class ReolinkNVRSwitchEntityDescription(
|
|||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class ReolinkChimeSwitchEntityDescription(
|
class ReolinkChimeSwitchEntityDescription(
|
||||||
SwitchEntityDescription,
|
SwitchEntityDescription,
|
||||||
ReolinkChannelEntityDescription,
|
ReolinkChimeEntityDescription,
|
||||||
):
|
):
|
||||||
"""A class that describes switch entities for a chime."""
|
"""A class that describes switch entities for a chime."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user