Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reolink bitrate and framerate select entities #131571

Merged
merged 12 commits into from
Nov 26, 2024
12 changes: 12 additions & 0 deletions homeassistant/components/reolink/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,18 @@
"state": {
"off": "mdi:music-note-off"
}
},
"main_frame_rate": {
"default": "mdi:play-speed"
},
"sub_frame_rate": {
"default": "mdi:play-speed"
},
"main_bit_rate": {
"default": "mdi:play-speed"
},
"sub_bit_rate": {
"default": "mdi:play-speed"
}
},
"sensor": {
Expand Down
50 changes: 49 additions & 1 deletion homeassistant/components/reolink/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from reolink_aio.exceptions import InvalidParameterError, ReolinkError

from homeassistant.components.select import SelectEntity, SelectEntityDescription
from homeassistant.const import EntityCategory
from homeassistant.const import EntityCategory, UnitOfDataRate, UnitOfFrequency
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -175,6 +175,54 @@ def _get_quick_reply_id(api: Host, ch: int, mess: str) -> int:
value=lambda api, ch: HDREnum(api.HDR_state(ch)).name,
method=lambda api, ch, name: api.set_HDR(ch, HDREnum[name].value),
),
ReolinkSelectEntityDescription(
key="main_frame_rate",
cmd_key="GetEnc",
translation_key="main_frame_rate",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
unit_of_measurement=UnitOfFrequency.HERTZ,
get_options=lambda api, ch: [str(v) for v in api.frame_rate_list(ch, "main")],
supported=lambda api, ch: api.supported(ch, "frame_rate"),
value=lambda api, ch: str(api.frame_rate(ch, "main")),
method=lambda api, ch, value: api.set_frame_rate(ch, int(value), "main"),
),
ReolinkSelectEntityDescription(
key="sub_frame_rate",
cmd_key="GetEnc",
translation_key="sub_frame_rate",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
unit_of_measurement=UnitOfFrequency.HERTZ,
get_options=lambda api, ch: [str(v) for v in api.frame_rate_list(ch, "sub")],
supported=lambda api, ch: api.supported(ch, "frame_rate"),
value=lambda api, ch: str(api.frame_rate(ch, "sub")),
method=lambda api, ch, value: api.set_frame_rate(ch, int(value), "sub"),
),
ReolinkSelectEntityDescription(
key="main_bit_rate",
cmd_key="GetEnc",
translation_key="main_bit_rate",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
get_options=lambda api, ch: [str(v) for v in api.bit_rate_list(ch, "main")],
supported=lambda api, ch: api.supported(ch, "bit_rate"),
value=lambda api, ch: str(api.bit_rate(ch, "main")),
method=lambda api, ch, value: api.set_bit_rate(ch, int(value), "main"),
),
ReolinkSelectEntityDescription(
key="sub_bit_rate",
cmd_key="GetEnc",
translation_key="sub_bit_rate",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
get_options=lambda api, ch: [str(v) for v in api.bit_rate_list(ch, "sub")],
supported=lambda api, ch: api.supported(ch, "bit_rate"),
value=lambda api, ch: str(api.bit_rate(ch, "sub")),
method=lambda api, ch, value: api.set_bit_rate(ch, int(value), "sub"),
),
)

CHIME_SELECT_ENTITIES = (
Expand Down
12 changes: 12 additions & 0 deletions homeassistant/components/reolink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,18 @@
"moonlight": "[%key:component::reolink::entity::select::motion_tone::state::moonlight%]",
"waybackhome": "[%key:component::reolink::entity::select::motion_tone::state::waybackhome%]"
}
},
"main_frame_rate": {
"name": "Clear frame rate"
},
"sub_frame_rate": {
"name": "Fluent frame rate"
},
"main_bit_rate": {
"name": "Clear bit rate"
},
"sub_bit_rate": {
"name": "Fluent bit rate"
}
},
"sensor": {
Expand Down
Loading