Add Reolink Home Hub ringtone control (#126390)

* Add Hub alarm/visitor ringtones

* fix styling

* fix translations

* fix tests

* Rename buzzer to hub ringtone
pull/125763/head
starkillerOG 2024-09-22 14:41:47 +02:00 committed by GitHub
parent 66d310977d
commit 118ceedda1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 81 additions and 6 deletions

View File

@ -210,6 +210,18 @@
"hdr": { "hdr": {
"default": "mdi:hdr" "default": "mdi:hdr"
}, },
"hub_alarm_ringtone": {
"default": "mdi:music-note",
"state": {
"alarm": "mdi:bullhorn"
}
},
"hub_visitor_ringtone": {
"default": "mdi:music-note",
"state": {
"alarm": "mdi:bullhorn"
}
},
"motion_tone": { "motion_tone": {
"default": "mdi:music-note", "default": "mdi:music-note",
"state": { "state": {
@ -297,8 +309,8 @@
"manual_record": { "manual_record": {
"default": "mdi:record-rec" "default": "mdi:record-rec"
}, },
"buzzer": { "hub_ringtone_on_event": {
"default": "mdi:room-service" "default": "mdi:music-note"
}, },
"doorbell_button_sound": { "doorbell_button_sound": {
"default": "mdi:volume-high" "default": "mdi:volume-high"

View File

@ -13,6 +13,7 @@ from reolink_aio.api import (
DayNightEnum, DayNightEnum,
HDREnum, HDREnum,
Host, Host,
HubToneEnum,
SpotlightModeEnum, SpotlightModeEnum,
StatusLedEnum, StatusLedEnum,
TrackMethodEnum, TrackMethodEnum,
@ -114,6 +115,32 @@ SELECT_ENTITIES = (
api.set_quick_reply(ch, file_id=_get_quick_reply_id(api, ch, mess)) api.set_quick_reply(ch, file_id=_get_quick_reply_id(api, ch, mess))
), ),
), ),
ReolinkSelectEntityDescription(
key="hub_alarm_ringtone",
cmd_key="GetDeviceAudioCfg",
translation_key="hub_alarm_ringtone",
entity_category=EntityCategory.CONFIG,
get_options=[mode.name for mode in HubToneEnum],
supported=lambda api, ch: api.supported(ch, "hub_audio"),
value=lambda api, ch: HubToneEnum(api.hub_alarm_tone_id(ch)).name,
method=lambda api, ch, name: (
api.set_hub_audio(ch, alarm_tone_id=HubToneEnum[name].value)
),
),
ReolinkSelectEntityDescription(
key="hub_visitor_ringtone",
cmd_key="GetDeviceAudioCfg",
translation_key="hub_visitor_ringtone",
entity_category=EntityCategory.CONFIG,
get_options=[mode.name for mode in HubToneEnum],
supported=lambda api, ch: (
api.supported(ch, "hub_audio") and api.is_doorbell(ch)
),
value=lambda api, ch: HubToneEnum(api.hub_visitor_tone_id(ch)).name,
method=lambda api, ch, name: (
api.set_hub_audio(ch, visitor_tone_id=HubToneEnum[name].value)
),
),
ReolinkSelectEntityDescription( ReolinkSelectEntityDescription(
key="auto_track_method", key="auto_track_method",
cmd_key="GetAiCfg", cmd_key="GetAiCfg",

View File

@ -531,6 +531,38 @@
"auto": "Auto" "auto": "Auto"
} }
}, },
"hub_alarm_ringtone": {
"name": "Hub alarm ringtone",
"state": {
"alarm": "Alarm",
"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%]"
}
},
"hub_visitor_ringtone": {
"name": "Hub visitor ringtone",
"state": {
"alarm": "[%key:component::reolink::entity::select::hub_alarm_ringtone::state::alarm%]",
"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%]"
}
},
"motion_tone": { "motion_tone": {
"name": "Motion ringtone", "name": "Motion ringtone",
"state": { "state": {
@ -663,8 +695,8 @@
"manual_record": { "manual_record": {
"name": "Manual record" "name": "Manual record"
}, },
"buzzer": { "hub_ringtone_on_event": {
"name": "Buzzer on event" "name": "Hub ringtone on event"
}, },
"doorbell_button_sound": { "doorbell_button_sound": {
"name": "Doorbell button sound" "name": "Doorbell button sound"

View File

@ -171,7 +171,7 @@ SWITCH_ENTITIES = (
ReolinkSwitchEntityDescription( ReolinkSwitchEntityDescription(
key="buzzer", key="buzzer",
cmd_key="GetBuzzerAlarmV20", cmd_key="GetBuzzerAlarmV20",
translation_key="buzzer", translation_key="hub_ringtone_on_event",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
supported=lambda api, ch: api.supported(ch, "buzzer") and api.is_nvr, supported=lambda api, ch: api.supported(ch, "buzzer") and api.is_nvr,
value=lambda api, ch: api.buzzer_enabled(ch), value=lambda api, ch: api.buzzer_enabled(ch),
@ -248,7 +248,7 @@ NVR_SWITCH_ENTITIES = (
ReolinkNVRSwitchEntityDescription( ReolinkNVRSwitchEntityDescription(
key="buzzer", key="buzzer",
cmd_key="GetBuzzerAlarmV20", cmd_key="GetBuzzerAlarmV20",
translation_key="buzzer", translation_key="hub_ringtone_on_event",
icon="mdi:room-service", icon="mdi:room-service",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
supported=lambda api: api.supported(None, "buzzer"), supported=lambda api: api.supported(None, "buzzer"),

View File

@ -77,6 +77,10 @@
'0': 1, '0': 1,
'null': 1, 'null': 1,
}), }),
'GetDeviceAudioCfg': dict({
'0': 2,
'null': 2,
}),
'GetEmail': dict({ 'GetEmail': dict({
'0': 1, '0': 1,
'null': 2, 'null': 2,