Some of the compatible hardware sends event signals that wouldn't map
well to entities, e.g. NTP sync notifications, SIP registering
information, or « doorbell button pressed » events with no « return to
rest state » matching event to have a properly behaved binary sensor.
Instead of only monitoring specific events, subscribe to all of them,
and pass them through (in addition to handling them as before if they
correspond to a configured binary sensor).
Also bump python-amcrest to 1.7.2. Digest of the changes:
* The library now passes through the event data instead of just presence of a
"Start" member in in.
* Connection to some devices has been fixed by not throwing the towel on
minor errors.
https://github.com/tchellomello/python-amcrest/compare/1.7.1...1.7.2
* Rename BinarySensorDevice to BinarySensorEntity
* Tweak
* Move deprecation warning to __new__, add test
* Move deprecation warning back to __init__
* Move deprecation warning to __init_subclass
* Add prettier (in pre-commit and CI)
* Make all file prettier
* Change order
* Add to Azure Pipelines
* Fix a YAML file prettier caught as invalid
* Remove flow mapping using curly braces from all YAML service files
Add new "amcrest.ptz_control" service to specify a PTZ camera movement or zoom direction (up, down, right, left, right_up, right_down, left_up, left_down, zoom_in, zoom_out). An optional travel_time attribute specifies the amount of movement between start/stop.
* Convert amcrest binary sensors from poll to stream
- Bump amcrest package to 1.6.0.
- For online binary sensor poll camera periodically to test communications in case
configuration & usage results in no other communication to camera.
- Start a separate thread to call camera's event_stream method since it never returns.
- Convert all received events into signals that cause corresponding sensors to update.
- Use camera's generic event_channels_happened method to update sensors at startup,
and whenever camera comes back online after being unavailable.
* Changes per review
* Changes per review 2
* Changes per review 3
- Move event stream decoding to amcrest package.
- Change name of event processing threads so global
counter is no longer required.
- Bump amcrest package to 1.7.0.
* Use f-strings in integrations starting with A
* Use f-strings in tests for integrations starting with A
* Fix pylint by renaming variable
* Fix nested for loop in f-string for aprs device_tracker
* Break long lines into multiple short lines
* Break long lines into multiple short lines v2
- Bump amcrest package to 1.5.6. Includes networking improvements, no longer
communicates during Http.__init__(), and allows running snapshot command
without using stream mode.
- Handle login errors better, and not just at startup.
- Increase network connect & read timeout to 6.05 seconds.
- Increase network read timeout to 20 seconds for snapshot command.
- Run snapshot command in separate task, that cannot be cancelled, to eliminate
possibility of two snapshot commands running simultaneously (since
AmcrestCam.async_camera_image can be cancelled.) Also makes sure any exceptions
from the command are caught properly.
When an amcrest camera was unplugged and then plugged again
it was impossible to reconnect to it, since the old
auth token was reused while we need to use a new one.
In fact, the method that is called every minute to check
the camera availability is going to fail always since we're
reusing an old token.
By forgetting the token (setting it to None) when going offline,
we ensure that we'll regenerate it in the next commands thus allowing
to reconnect to the camera when it comes back online.
* Improve amcrest error handling and bump amcrest package to 1.5.3
amcrest package update fixes command retry, especially with Digest Authentication, and allows sending snapshot command without channel parameter.
Get rid of persistent_notification.
Errors at startup, other than login errors, are no longer fatal.
Display debug messages about how many times an error has occurred in a row.
Remove initial communications test. If camera is off line at startup this just delays the component setup.
Handle urllib3 errors when getting data from commands that were sent with stream=True.
If errors occur during camera update, try repeating until it works or the camera is determined to be off line.
Drop channel parameter in snapshot command which allows camera to use its default channel, which is different in different camera models and firmware versions.
Make entities unavailable if too many errors occur in a row.
Add new configuration variables to control how many errors in a row should be interpreted as camera being offline, and how frequently to "ping" camera to see when it becomes available again.
Add online binary_sensor option to indicate if camera is available (i.e., responding to commands.)
* Update per review comments
Remove max_errors and recheck_interval configuration variables and used fixed values instead.
Move definition of AmcrestChecker class to module level.
Change should_poll in camera.py to return a fixed value of True and move logic to update method.
Enable feature by default but allow it to be disabled by "control_light: false" in config.
Get brand from camera instead of assuming Amcrest (since this works with other cameras, too.)
Retrieve RTSP URL in update method instead of in stream_source property and in handle_async_mjpeg_stream method.
Move amcrest imports from methods to global.
Improve sdcard sensor so it only sends one command to camera per update as opposed to the four it used to send to reduce network traffic and make data consistent. Also better handle returned values of 'unknown'.
* Add amcrest camera services and deprecate switches
- Implement enabling and disabling motion detection from camera platform.
- Add amcrest specific camera services for controlling audio stream, motion recording, continuous recording and camera color mode, as well as moving camera to PTZ preset and starting and stopping PTZ tour function.
- Add camera attributes to indicate the state of the various camera settings controlled by the new services.
- Deprecate switches in favor of camera services and attributes.
* Rename services and move service handling to __init__.py
Rename services from 'camera.amcrest_xxx' to 'amcrest.xxx'. This allows services to be documented in services.yaml.
Add services.yaml.
Reorganize hass.data[DATA_AMCREST] and do some general cleanup to make various platform modules more consistent.
Move service handling code to __init__.py from camera.py.
* Update per review comments, part 1
- Rebase
- Add permission checking to services
- Change cv.ensure_list_csv to cv.ensure_list
- Add comment for "pointless-statement" in setup
- Change handler_services to handled_services
- Remove check if services have alreaday been registered
- Pass ffmpeg instead of hass to AmcrestCam __init__
- Remove writing motion_detection attr from device_state_attributes
- Change service methods from callbacks to coroutines
* Update per review comments, part 2
- Use dispatcher to signal camera entities to run services.
- Reorganize a bit, including moving a few things to new modules const.py & helpers.py.
* Update per review comments, part 3
Move call data extraction from camera.py to __init__.py.
* Add amcrest binary_sensors
Add binary_sensors with option motion_detected. Deprecate motion_detector sensor.
* Update per review
* Update per review
Add custom validators to make sure camera names are unique, and to issue warning if deprecated sensors option motion_detector is used.
async_setup_platform should not return a value.
* Another review update
Since there is only one type of binary_sensor, remove type test in update method.
* Amcrest: Add on/off support & attributes to camera entity. Bump amcrest package to 1.3.0.
Add support for turn_on & turn_off services.
Add implementation of is_recording method, as well as brand, model, hardware_version, machine_name, serial_number, software_build and software_version attributes.
Bump amcrest package to 1.3.0 required for above changes and also handles errors in storage commands which resolves#19982.
* Update per review
Rebase to upstream/dev.
Remove video_enabled property and setter and replace with _enable_video_stream
method.
Remove static attributes from camera and sensors.
amcrest 1.2.7 now includes camera's configured RTSP port in generated URL. Necessary to make new stream component work correctly if camera does not use default RTSP port.