-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Reolink add new number entities #87932
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
Changes from 11 commits
752a7ef
3cbeb10
cd0e54c
1d2f6b2
99a7ffe
09215aa
ddd2ac4
6099990
0486a5a
3dfcbb3
c49e386
94728e9
543ed96
4b6b589
a7ceedd
2ba9039
b4416d0
d9cf556
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||||||||||||||||||
| NumberMode, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| from homeassistant.config_entries import ConfigEntry | ||||||||||||||||||||||
| from homeassistant.const import UnitOfTime | ||||||||||||||||||||||
| from homeassistant.core import HomeAssistant | ||||||||||||||||||||||
| from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -25,10 +26,10 @@ | |||||||||||||||||||||
| class ReolinkNumberEntityDescriptionMixin: | ||||||||||||||||||||||
| """Mixin values for Reolink number entities.""" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| value: Callable[[Host, int | None], bool] | ||||||||||||||||||||||
| get_min_value: Callable[[Host, int | None], float] | ||||||||||||||||||||||
| get_max_value: Callable[[Host, int | None], float] | ||||||||||||||||||||||
| method: Callable[[Host, int | None, float], Any] | ||||||||||||||||||||||
| value: Callable[[Host, int], float] | ||||||||||||||||||||||
| get_min_value: Callable[[Host, int], float] | ||||||||||||||||||||||
| get_max_value: Callable[[Host, int], float] | ||||||||||||||||||||||
| method: Callable[[Host, int, float], Any] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @dataclass | ||||||||||||||||||||||
|
|
@@ -38,7 +39,7 @@ class ReolinkNumberEntityDescription( | |||||||||||||||||||||
| """A class that describes number entities.""" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| mode: NumberMode = NumberMode.AUTO | ||||||||||||||||||||||
| supported: Callable[[Host, int | None], bool] = lambda api, ch: True | ||||||||||||||||||||||
| supported: Callable[[Host, int], bool] = lambda api, ch: True | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| NUMBER_ENTITIES = ( | ||||||||||||||||||||||
|
|
@@ -50,7 +51,7 @@ class ReolinkNumberEntityDescription( | |||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: api.zoom_range(ch)["zoom"]["pos"]["min"], | ||||||||||||||||||||||
| get_max_value=lambda api, ch: api.zoom_range(ch)["zoom"]["pos"]["max"], | ||||||||||||||||||||||
| supported=lambda api, ch: api.zoom_supported(ch), | ||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "zoom"), | ||||||||||||||||||||||
| value=lambda api, ch: api.get_zoom(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_zoom(ch, int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
|
|
@@ -62,10 +63,103 @@ class ReolinkNumberEntityDescription( | |||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: api.zoom_range(ch)["focus"]["pos"]["min"], | ||||||||||||||||||||||
| get_max_value=lambda api, ch: api.zoom_range(ch)["focus"]["pos"]["max"], | ||||||||||||||||||||||
| supported=lambda api, ch: api.zoom_supported(ch), | ||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "zoom"), | ||||||||||||||||||||||
| value=lambda api, ch: api.get_focus(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_zoom(ch, int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="floodlight_brightness", | ||||||||||||||||||||||
| name="Floodlight brightness", | ||||||||||||||||||||||
| icon="mdi:spotlight-beam", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 1, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "floodLight"), | ||||||||||||||||||||||
| value=lambda api, ch: api.whiteled_brightness(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_whiteled(ch, brightness=int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
|
Comment on lines
+70
to
+81
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between this number entity and the light entity for the floodlight? core/homeassistant/components/reolink/light.py Lines 46 to 55 in 0c042e8
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See discussion above: #87932 (review)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read up on the comment history in the PR. Please add a code comment explaining the situation so we don't need to wonder what's going on when reading the code.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a code comment and some extra documentation because this is indeed not clear enough, just a moment
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation PR is here: home-assistant/home-assistant.io#26469
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code comment PR is here: #89234 |
||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="volume", | ||||||||||||||||||||||
| name="Volume", | ||||||||||||||||||||||
| icon="mdi:volume-high", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 0, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "volume"), | ||||||||||||||||||||||
| value=lambda api, ch: api.volume(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_volume(ch, volume=int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="guard_return_time", | ||||||||||||||||||||||
| name="Guard return time", | ||||||||||||||||||||||
| icon="mdi:crosshairs-gps", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| native_unit_of_measurement=UnitOfTime.SECONDS, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 10, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 300, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "ptz_guard"), | ||||||||||||||||||||||
| value=lambda api, ch: api.ptz_guard_time(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_ptz_guard(ch, time=int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="motion_sensitivity", | ||||||||||||||||||||||
| name="Motion sensitivity", | ||||||||||||||||||||||
| icon="mdi:motion-sensor", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 1, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 50, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "md_sensitivity"), | ||||||||||||||||||||||
| value=lambda api, ch: api.md_sensitivity(ch), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_md_sensitivity(ch, int(value)), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="ai_face_sensititvity", | ||||||||||||||||||||||
| name="AI face sensitivity", | ||||||||||||||||||||||
| icon="mdi:face-recognition", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 0, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "ai_sensitivity") | ||||||||||||||||||||||
| and api.ai_supported(ch, "face"), | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| value=lambda api, ch: api.ai_sensitivity(ch, "face"), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_ai_sensitivity(ch, int(value), "face"), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="ai_person_sensititvity", | ||||||||||||||||||||||
| name="AI person sensitivity", | ||||||||||||||||||||||
| icon="mdi:account", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 0, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "ai_sensitivity") | ||||||||||||||||||||||
| and api.ai_supported(ch, "people"), | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| value=lambda api, ch: api.ai_sensitivity(ch, "people"), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_ai_sensitivity(ch, int(value), "people"), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="ai_vehicle_sensititvity", | ||||||||||||||||||||||
| name="AI vehicle sensitivity", | ||||||||||||||||||||||
| icon="mdi:car", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 0, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "ai_sensitivity") | ||||||||||||||||||||||
| and api.ai_supported(ch, "vehicle"), | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| value=lambda api, ch: api.ai_sensitivity(ch, "vehicle"), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_ai_sensitivity(ch, int(value), "vehicle"), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ReolinkNumberEntityDescription( | ||||||||||||||||||||||
| key="ai_pet_sensititvity", | ||||||||||||||||||||||
| name="AI pet sensitivity", | ||||||||||||||||||||||
| icon="mdi:dog-side", | ||||||||||||||||||||||
| native_step=1, | ||||||||||||||||||||||
| get_min_value=lambda api, ch: 0, | ||||||||||||||||||||||
| get_max_value=lambda api, ch: 100, | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| supported=lambda api, ch: api.supported(ch, "ai_sensitivity") | ||||||||||||||||||||||
| and api.ai_supported(ch, "dog_cat"), | ||||||||||||||||||||||
|
starkillerOG marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||
| value=lambda api, ch: api.ai_sensitivity(ch, "dog_cat"), | ||||||||||||||||||||||
| method=lambda api, ch, value: api.set_ai_sensitivity(ch, int(value), "dog_cat"), | ||||||||||||||||||||||
| ), | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -119,3 +213,4 @@ def native_value(self) -> float: | |||||||||||||||||||||
| async def async_set_native_value(self, value: float) -> None: | ||||||||||||||||||||||
| """Update the current value.""" | ||||||||||||||||||||||
| await self.entity_description.method(self._host.api, self._channel, value) | ||||||||||||||||||||||
| self.async_write_ha_state() | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.