-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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 config flow to Amcrest #80453
Add config flow to Amcrest #80453
Conversation
4b31cb6
to
8c65bde
Compare
8c65bde
to
d1f65b5
Compare
Setup the Amcrest integration with config flow to be able to configure new Amcrest camera entities. Include import logic to update and deprecate existing yaml configurations.
d1f65b5
to
5aacfb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a quick look and some minor remarks to get you started.
e7007f8
to
ed95382
Compare
Co-authored-by: Mick Vleeshouwer <[email protected]>
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
somewhat related. There is currently a pretty significant performance issue with the lib: tchellomello/python-amcrest#231 |
key=_AUDIO_DETECTED_POLLED_KEY, | ||
name=_AUDIO_DETECTED_NAME, | ||
key=AUDIO_DETECTED_POLLED_KEY, | ||
name=AUDIO_DETECTED_NAME + " Polled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use f-strings
key=_CROSSLINE_DETECTED_POLLED_KEY, | ||
name=_CROSSLINE_DETECTED_NAME, | ||
key=CROSSLINE_DETECTED_POLLED_KEY, | ||
name=CROSSLINE_DETECTED_NAME + " Polled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use f-strings
key=_MOTION_DETECTED_POLLED_KEY, | ||
name=_MOTION_DETECTED_NAME, | ||
key=MOTION_DETECTED_POLLED_KEY, | ||
name=MOTION_DETECTED_NAME + " Polled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use f-strings
device_class=BinarySensorDeviceClass.SOUND, | ||
event_codes=_AUDIO_DETECTED_EVENT_CODES, | ||
event_codes=AUDIO_DETECTED_EVENT_CODES, | ||
should_poll=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there polling and non-polling sensors?
Not for this PR, but can the polling ones be disabled by default?
@@ -181,6 +176,7 @@ def __init__(self, name: str, device: AmcrestDevice, ffmpeg: FFmpegManager) -> N | |||
self._channel = device.channel | |||
self._token = self._auth = device.authentication | |||
self._control_light = device.control_light | |||
self._attr_unique_id = device.serial_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be multiple channels?
sensors = config_entry.options.get(CONF_SENSORS, []) | ||
if sensors: | ||
name = config_entry.data[CONF_NAME] | ||
device = hass.data[DOMAIN][DEVICES][config_entry.entry_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please type device
device = hass.data[DATA_AMCREST][DEVICES][name] | ||
"""Set up the camera entity.""" | ||
name = config_entry.data[CONF_NAME] | ||
device = hass.data[DOMAIN][DEVICES][config_entry.entry_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please type device
control_light: bool = entry.options.get(CONF_CONTROL_LIGHT, DEFAULT_CONTROL_LIGHT) | ||
|
||
hass.data.setdefault(DOMAIN, {DEVICES: {}, CAMERAS: []}) | ||
hass.data[DOMAIN][DEVICES][entry.entry_id] = AmcrestDevice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we store data by
hass.data[DOMAIN][entry.entry_id]
What you have is ok but I'd change DEVICES
to ENTRIES
since it looks like config entry data
hass, | ||
DOMAIN, | ||
"deprecated_yaml", | ||
breaks_in_ha_version=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MOTION_DETECTED_KEY = "motion_detected" | ||
MOTION_DETECTED_POLLED_KEY = "motion_detected_polled" | ||
MOTION_DETECTED_NAME = "Motion Detected" | ||
MOTION_DETECTED_EVENT_CODE = "VideoMotion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all these need to be renamed? Can we leave the _
to make this merge smaller?
vol.Optional(CONF_BINARY_SENSORS, default=[]): cv.multi_select( | ||
{sensor.key: sensor.name for sensor in BINARY_SENSORS} | ||
), | ||
vol.Optional(CONF_SENSORS, default=[]): cv.multi_select( | ||
{sensor.key: sensor.name for sensor in SENSORS} | ||
), | ||
vol.Optional(CONF_CONTROL_LIGHT, default=DEFAULT_CONTROL_LIGHT): bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not allow them to select entities in the options flow. We should use the standard functionality of HA to enable/disable entities.
Instead set entity_registery_enabled_default=True
using the old yaml so when they migrate, entities are there but disabled.
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
@flacjacket would you like to continue this PR? |
@bdraco Thanks for the ping on this, I'll try to get it back up-to-date and get the fixes in from the previous review this weekend |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
Setup the Amcrest integration with config flow to be able to configure new Amcrest camera entities. Include import logic to update and deprecate existing yaml configurations.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: