Commit Graph

45 Commits

Author SHA1 Message Date
Sid 0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Joost Lekkerkerker 690ba103ed
Improve lists in integrations [A] (#113006)
* Use list comprehension [A]

* Use list comprehension [A]

* Update homeassistant/components/aws/notify.py
2024-03-11 16:17:44 +01:00
Marc Mueller ff3a801936
Add empty line after module docstring [a-d] (#112697) 2024-03-08 14:51:32 +01:00
Franck Nijhof 18dddd6342
Update Ruff to v0.0.277 (#96108) 2023-07-09 10:10:23 -04:00
Sean Vig e7c614a825
Fix audio detection for IP4m-1041 Amcrest camera (#80066) 2022-10-11 14:29:35 +02:00
Sean Vig 08770d015b
Change Amcrest event monitor to non-async (#69640) 2022-05-04 10:15:52 -05:00
Sean Vig 38306417ad
Bump amcrest version to 1.9.7 (#68055) 2022-03-14 17:36:16 +01:00
Sean Vig 6af7425051
Create tasks to load Amcrest platforms (#64848)
* Create tasks to load Amcrest platforms

* Move closure definition out of for loop
2022-01-24 22:34:18 +01:00
Sean Vig 7781e308cd
Migrate amcrest integration to new async API (#56294) 2022-01-22 15:49:45 -10:00
epenet 665eeb4b27
Explicitely allow Platform enum in discovery helper (#63571)
* Adjust Platform type hint in discovery helper

* Adjust amcrest

* Adjust comfoconnect

* Adjust ecovacs

* Adjust egardia

* Rename arguments

* Convert Platform enum to string explicitely

* Revert "Adjust egardia"

This reverts commit ff7b0d6100.

* Revert "Adjust ecovacs"

This reverts commit 2749045e13.

* Revert "Adjust comfoconnect"

This reverts commit bfff08f7fc.

* Undo argument name change and conversion to string

* Remove comment

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-09 06:06:56 +01:00
Pedro Rodriguez Tavarez e0562385f1
Implement privacy_mode for amcrest integration (#57210) 2021-12-03 10:00:39 -08:00
Sean Vig f18e4bab60
Add resolution to Amcrest camera unique id (#56207)
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
2021-09-30 13:38:18 +02:00
Marc Mueller 565a9fea6b
Import Callable from collections.abc (2) (#56776) 2021-09-29 14:06:51 +02:00
Sean Vig 6b4e3bca6f
Add type annotations to amcrest integration (#54761)
Co-authored-by: Milan Meulemans <milan.meulemans@live.be>
2021-08-25 13:24:29 +02:00
Sean Vig 5cbb217318
Update amcrest to use binary sensor entity description (#55092) 2021-08-24 14:06:19 +02:00
Marc Mueller 1f6a70bafd
Use EntityDescription - amcrest (#54998) 2021-08-23 22:32:01 +02:00
Sean Vig 673be4f7dd
Bump Amcrest version to 1.8.0 (#53784)
* Bump Amcrest version to 1.8.0
* Add codeowner to Amcrest.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
2021-08-01 00:22:19 +02:00
Julien "_FrnchFrgg_" Rivaud 24a46d91d3
Fix amcrest detection of sensor reset (#50249)
Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
2021-05-10 10:49:08 -07:00
Julien "_FrnchFrgg_" Rivaud 5a9c3fea70
Enable passing Amcrest/Dahua signals through as HA events (#49004)
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
2021-04-13 21:33:46 +02:00
Franck Nijhof 6932cf9534
Use contextlib.suppress where possible (#48189) 2021-03-23 14:36:43 +01:00
Phil Bruckner c423501804
Add legacy polling option for Amcrest motion detection (#36955) 2020-06-24 23:20:39 -07:00
Phil Bruckner 0ed7bc3b8e
Convert amcrest binary sensors from poll to stream (#32818)
* 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.
2020-03-19 21:07:21 -07:00
Ville Skyttä 9b2544c923
Remove some unneeded pylint suppressions (#32152) 2020-02-24 16:47:15 -08:00
Phil Bruckner d1e7ade6db
Make amcrest integration more robust (#30843)
- 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.
2020-02-06 14:44:48 -06:00
Paulus Schoutsen f41623ca64
Log warning when entities referenced in service call not found (#31427)
* Raise entities not found error

* Make it a warning, not an error

* Add support for MATCH_ENTITY_NONE

* Fix lint

* Fix tests
2020-02-04 14:42:07 -08:00
Phil Bruckner 7e9507833b
Fix async bug in amcrest when registering services (#31334) 2020-01-30 23:28:53 -08:00
Phil Bruckner 89c04c94e0
Revert "Forget auth token when going offline so we can reconnect (#26630)" (#30705)
This reverts commit 2d6d6ba90e.
2020-01-12 14:21:07 -06:00
Phil Bruckner 609bf445f0
Remove Amcrest deprecated sensors and switches (#30308) 2019-12-31 08:16:41 -06:00
Bas Nijholt 96961b9bcc Sort imports according to PEP8 for components starting with "A" (#29761) 2019-12-09 13:57:24 +01:00
Antonio Larrosa 2d6d6ba90e Forget auth token when going offline so we can reconnect (#26630)
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.
2019-10-17 11:29:08 +02:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Phil Bruckner 233bc1a108 Improve amcrest error handling and bump amcrest package to 1.5.3 (#24262)
* 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.
2019-06-07 21:46:49 -07:00
Phil Bruckner d966e0cfce Add control of Amcrest indicator light (#23986)
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.
2019-05-31 13:41:48 -07:00
Phil Bruckner 86b017e2f0 Add amcrest camera services and deprecate switches (#22949)
* 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.
2019-04-24 22:39:49 -07:00
cgtobi 2c07bfb9e0 Remove dependencies and requirements (#23024)
* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit fe7171b4cd.

* Remove dependencies and requirements

* Revert "Remove dependencies and requirements"

This reverts commit 391355ee2c.

* Remove dependencies and requirements

* Fix flake8 complaints

* Fix more flake8 complaints

* Revert non-component removals
2019-04-12 10:13:30 -07:00
Phil Bruckner 34bb31f4ec Add amcrest binary_sensors (#22703)
* 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.
2019-04-09 15:21:47 +02:00
Pascal Vizeli 7066fb0d10
Fix ffmpeg default extra options (#22682) 2019-04-03 13:46:41 +02:00
Phil Bruckner 82296aeb71 Amcrest: Add on/off support & attributes. Bump amcrest to 1.3.0 (#22418)
* 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.
2019-04-01 17:36:29 -05:00
Phil Bruckner 9e4bd88a06 Bump amcrest to 1.2.7 for correct RTSP port (#22099)
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.
2019-03-16 08:20:49 +01:00
Phil Bruckner 8d2d71c16a Bump amcrest to 1.2.6 & use new exceptions (#22040)
* Bump amcrest to 1.2.6 & use new exceptions

* Fix lint failure

* Use AmcrestError instead of individual ones
2019-03-14 10:56:33 -07:00
Phil Bruckner 5616505032 Change amcrest camera_image to async (#21720)
Change AmcrestCam method camera_image to async so asyncio lock can be used instead of a threading lock. Bump amcrest package to 1.2.5.
2019-03-06 19:42:59 -08:00
Phil Bruckner 16d79b52c3 Serialize amcrest snapshot commands and bump PyPI package to 1.2.4 (#21664)
* Serialize snapshot commands and bump amcrest package to 1.2.4

Attempting to send a snapshot command when a previous one hasn't finished will result in warnings and/or errors. This can happen when the camera picture is clicked on in the frontend, resulting in the thread that updates the thumbnail in the background every 10 seconds to sometimes collide with the thread that updates the large picture in the foreground quickly. An automation that calls the camera.snapshot service in yet another thread can make the situation worse. Fix by adding a thread lock to serialize snapshot commands. Also bump the amcrest package to 1.2.4 which fixes error handling in the command method and improves performance by reusing requests sessions.

* Update amcrest package to 1.2.4
2019-03-05 17:03:19 +01:00
Fabian Affolter 127c55e0c1
Update file header (#21023)
* Update file header

* Update file header

* Update file header

* Update file header

* Update file header

* Fix lint issues
2019-02-13 21:21:14 +01:00
Paulus Schoutsen e2d3c27e85
Embed all platforms into components (#20677)
* Consolidate all components with platforms

* Organize tests

* Fix more tests

* Fix Verisure tests

* one final test fix

* Add change

* Fix coverage
2019-02-02 07:13:16 -08:00