Skip to content

Commit

Permalink
Reolink add auto tracking entities (home-assistant#90063)
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG authored Mar 27, 2023
1 parent 56293ad commit 97f8a3f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
54 changes: 54 additions & 0 deletions homeassistant/components/reolink/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,60 @@ class ReolinkNumberEntityDescription(
value=lambda api, ch: api.quick_reply_time(ch),
method=lambda api, ch, value: api.set_quick_reply(ch, time=int(value)),
),
ReolinkNumberEntityDescription(
key="auto_track_limit_left",
name="Auto track limit left",
icon="mdi:angle-acute",
mode=NumberMode.SLIDER,
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=-1,
native_max_value=2700,
supported=lambda api, ch: api.supported(ch, "auto_track_limit"),
value=lambda api, ch: api.auto_track_limit_left(ch),
method=lambda api, ch, value: api.set_auto_track_limit(ch, left=int(value)),
),
ReolinkNumberEntityDescription(
key="auto_track_limit_right",
name="Auto track limit right",
icon="mdi:angle-acute",
mode=NumberMode.SLIDER,
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=-1,
native_max_value=2700,
supported=lambda api, ch: api.supported(ch, "auto_track_limit"),
value=lambda api, ch: api.auto_track_limit_right(ch),
method=lambda api, ch, value: api.set_auto_track_limit(ch, right=int(value)),
),
ReolinkNumberEntityDescription(
key="auto_track_disappear_time",
name="Auto track disappear time",
icon="mdi:target-account",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_unit_of_measurement=UnitOfTime.SECONDS,
native_min_value=1,
native_max_value=60,
supported=lambda api, ch: api.supported(ch, "auto_track_disappear_time"),
value=lambda api, ch: api.auto_track_disappear_time(ch),
method=lambda api, ch, value: api.set_auto_tracking(
ch, disappear_time=int(value)
),
),
ReolinkNumberEntityDescription(
key="auto_track_stop_time",
name="Auto track stop time",
icon="mdi:target-account",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_unit_of_measurement=UnitOfTime.SECONDS,
native_min_value=1,
native_max_value=60,
supported=lambda api, ch: api.supported(ch, "auto_track_stop_time"),
value=lambda api, ch: api.auto_track_stop_time(ch),
method=lambda api, ch, value: api.set_auto_tracking(ch, stop_time=int(value)),
),
)


Expand Down
13 changes: 12 additions & 1 deletion homeassistant/components/reolink/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from typing import Any

from reolink_aio.api import DayNightEnum, Host, SpotlightModeEnum
from reolink_aio.api import DayNightEnum, Host, SpotlightModeEnum, TrackMethodEnum

from homeassistant.components.select import SelectEntity, SelectEntityDescription
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -79,6 +79,17 @@ class ReolinkSelectEntityDescription(
ch, file_id=[k for k, v in api.quick_reply_dict(ch).items() if v == mess][0]
),
),
ReolinkSelectEntityDescription(
key="auto_track_method",
name="Auto track method",
icon="mdi:target-account",
translation_key="auto_track_method",
entity_category=EntityCategory.CONFIG,
get_options=[method.name for method in TrackMethodEnum],
supported=lambda api, ch: api.supported(ch, "auto_track_method"),
value=lambda api, ch: TrackMethodEnum(api.auto_track_method(ch)).name,
method=lambda api, ch, name: api.set_auto_tracking(ch, method=name),
),
)


Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/reolink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
"state": {
"off": "Off"
}
},
"auto_track_method": {
"state": {
"digital": "Digital",
"digitalfirst": "Digital first",
"pantiltfirst": "Pan/tilt first"
}
}
}
}
Expand Down

0 comments on commit 97f8a3f

Please sign in to comment.