Commit Graph

559 Commits (9cd48b4999deffdf143452dcbb9fa662a576c128)

Author SHA1 Message Date
J. Nick Koston 8e3454e46a
Remove legacy compatiblity for camera platforms that do not support width/height (#68039)
- async_camera_image or camera_image must accept the width and
  height arguments
2022-03-12 20:47:14 +02:00
GitHub Action 66d757115c [ci skip] Translation update 2022-03-11 00:21:48 +00:00
Franck Nijhof 63957787c4
Update PyTurboJPEG to 1.6.6 (#67800) 2022-03-07 23:26:30 +01:00
jan iversen 0d8ff3d724
Add codeowner to internal integrations that are without (#67286) 2022-02-28 09:06:16 +01:00
Paulus Schoutsen 7e4b63690d
Fix camera content type while browsing (#67256) 2022-02-26 10:02:13 +01:00
Paulus Schoutsen 0a6c8f8e6c
Improve not shown handling (#67247) 2022-02-25 11:52:14 -08:00
GitHub Action 6364e81be5 [ci skip] Translation update 2022-02-24 00:17:55 +00:00
Marc Mueller 45d8d04c40
Use assignment expressions [other] (#66882) 2022-02-19 17:22:51 +01:00
Paulus Schoutsen fec8c2ab82
Add support for MJPEG cameras to camera media source (#66499) 2022-02-14 17:04:19 +01:00
uvjustin c222be0958
Catch ConnectionResetError when writing MJPEG in camera (#66245) 2022-02-10 12:25:31 -08:00
Paulus Schoutsen 716a1e2a64
Add camera media source (#65977) 2022-02-08 14:32:02 -08:00
Paulus Schoutsen 08083f399e
Convert some tests to async and drop usage get_test_home_assistant (#64394)
* Fix some tests

* Update MS tests

* Convert last logbook tests to async
2022-01-18 19:37:17 -08:00
Josh Soref ab73d7c347
spelling: components/camera (#64242)
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-01-17 16:27:39 +01:00
Marc Mueller 67c35652f0
Update typing - collections.abc (2) (#63934) 2022-01-12 09:04:37 +01:00
Erik Montnemery 9c9dc4cb8c
Import websocket_api (part 1) (#63905) 2022-01-11 18:24:08 +01:00
Allen Porter 596edc8919
Add a stream_id parameter to the WebRTC provider (#63625)
* Add a stream_id parameter to the WebRTC provider

Add an additional stream id parameter (effectively, the camera entity id)
to allow updating an existing stream source when the strema changes. This
is useful for stream sources that have expiring URLs, like Nest.

* Redefine the provider using a type

* Use old typing methods for type definintion to pass python3.8 pylint
2022-01-10 17:56:18 -08:00
Franck Nijhof c339233421
Update PyTurboJPEG to 1.6.5 (#63803) 2022-01-10 13:28:04 +01:00
Franck Nijhof 31f37f3363
Update PyTurboJPEG to 1.6.4 (#63553) 2022-01-06 08:56:39 -08:00
Allen Porter 81aff973ea
Keep entity state management within entity (#63183)
Simplify the entity state management for webrtc providers, incurring
extra state writes on startup.  Followup post-review comments for PR #62962
2022-01-01 11:22:48 -08:00
Allen Porter 0dee4f85f0
Implement an rtsp to webrtc registry in camera (#62962)
* Implement a webrtc to rtsp support in camera as a registry

Allow integrations to register a provider that can convert an RTSP stream and WebRTC offer to a WebRTC answer. This is
planned to be used by the RTSPtoWebRTC server integration as an initial pass, but could
support other server implementations as well (or even native implementationf or that matter).

* Fix test bug to improve test covergae and restructure statements

* Add missing call to refresh webrtc providers

* Run provider refresh in parallel since it may send RPCs

* Replace for loop with any

* Fix pylint warning to use a generator
2021-12-31 13:44:33 -08:00
uvjustin 9dbba6b7f2
Use lock in Camera.create_stream (#62757)
Rename create_stream to async_create_stream in Camera
Rename get_image to async_get_image in Stream
Rename get_image to async_get_image in KeyFrameConverter
2021-12-25 04:14:43 +08:00
Erik Montnemery cb2c2d98c3
Remove unnecessary checks before calling os.makedirs (#62576) 2021-12-23 09:59:31 +01:00
Allen Porter 6ae7b928ea
Add a camera specific logger to help diagnose stream errors (#61647)
* Add a camera specific logger to help diagnose stream errors

Add a camera specific logger to help users associate stream errors with a particular camera.
Issue #54659

* Apply code review feedback

* Update package name based on manual testing
2021-12-19 19:42:37 -08:00
Allen Porter 647febd7d8
Mark camera unavailable when keepalive stream fails (#62294)
* Mark camera unavailable when keepalive stream fails

Add a listener in stream that notifies camera when the stream state has changed, and
use that to inform the camera `available` property. Update the property to be set
only from the main loop where it is read to reduce thread safety races.

Issue #54659

* Fix pylint import related errors

* Address lint naming errors

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-12-19 09:09:59 -08:00
Juan Jesús García de Soria 4526d25697
Update PyTurboJPEG to v1.6.3 (#60400) 2021-11-27 08:35:07 -10:00
Franck Nijhof 6b9c2d8295
Add shorthand attribute support to Camera platform (#59837) 2021-11-25 16:03:53 +01:00
GitHub Action e98977fb49 [ci skip] Translation update 2021-11-21 00:13:51 +00:00
Allen Porter 8ce3f18295
Remove unused stream_type attribute (#59625)
Remove this stream type that was previously renamed to frontend_stream_type
2021-11-13 04:45:18 -08:00
GitHub Action f00effaba2 [ci skip] Translation update 2021-11-13 00:11:56 +00:00
Marc Mueller 84618fa831
Use assignment expressions 30 (#58714) 2021-10-30 16:33:42 +02:00
Marc Mueller 7063c05127
Use assignment expressions 33 (#58717) 2021-10-30 16:32:41 +02:00
Allen Porter dafea00f41
Rename `stream_type` to `frontend_stream_type` (#57923)
Camera devices may support multiple stream sources so we want to clarify that
this is meant to decide which stream source is used in the frontend only.

Will set stream_type temporarily to allow rollout without breaking nightly,
and this will be removed after frontend is updated.
2021-10-17 20:16:29 -07:00
Marc Mueller 2b72b7b7b9
Use assignment expressions 09 (#57790) 2021-10-17 20:19:56 +02:00
Allen Porter 7d4dd94da8
Add WebSocket API for intiting a WebRTC stream (#57034)
* Add WebSocket API for intiting a WebRTC stream

See https://github.com/home-assistant/architecture/discussions/640

* Increase test coverage for webrtc camera stream

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-10-07 22:13:14 -07:00
Marc Mueller 565a9fea6b
Import Callable from collections.abc (2) (#56776) 2021-09-29 14:06:51 +02:00
Franck Nijhof 655dc890e4
Upgrade PyTurboJPEG to 1.6.1 (#56571) 2021-09-23 15:34:34 +02:00
Marc Mueller 48bada5a18
Update pylint to 2.11.1 (#56364) 2021-09-18 13:52:59 +02:00
J. Nick Koston fbcf21412d
Only warn once per entity when the async_camera_image signature needs to be updated (#55238) 2021-08-26 09:36:25 -07:00
J. Nick Koston dc851b9dd5
Ensure camera scaling always produces an image of at least the requested width and height (#55033) 2021-08-24 10:44:12 +02:00
Franck Nijhof d8eedaf9fd
Upgrade PyTurboJPEG to 1.5.2 (#54992) 2021-08-21 16:58:25 -05:00
Marc Mueller 69e413ac1e
Update pylint to 2.10.1 (#54963)
* Update pylint to 2.10.0

* useless-suppression

* Consider-using-tuple

* Apply suggestions from code review

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Use dict.items()

* Add pylint disable

* Use pylint 2.10.1

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-08-21 10:41:23 +02:00
J. Nick Koston 1e14b3a0ac
Ensure camera handles non-jpeg image sources correctly (#54474) 2021-08-11 08:12:46 -07:00
J. Nick Koston e99576c094
Pass width and height when requesting camera snapshot (#53835) 2021-08-10 19:33:06 -05:00
jan iversen 19245a5b63
Add CameraEntityDescription to camera integration (#53636) 2021-07-28 21:09:45 +02:00
GitHub Action 0c5ce9cac2 [ci skip] Translation update 2021-07-07 00:11:57 +00:00
GitHub Action 7615af35d8 [ci skip] Translation update 2021-06-07 00:18:16 +00:00
tkdrob 028a07d86f
Wrap up selectors (#50794)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-05-25 14:45:17 +02:00
Paulus Schoutsen 6a7968593d
Make camera source check faster (#51035) 2021-05-24 17:27:13 +01:00
Dermot Duffy 2e1037005c
Allow camera stream to fail safely (#50728) 2021-05-17 20:34:25 -07:00
Franck Nijhof eccefd154a
Extend targets for entity component services (#50760) 2021-05-17 14:06:50 +02:00
Ruslan Sayfutdinov 8e2b3aab44
Enable strict type checks for camera platform (#50395) 2021-05-10 15:12:15 +02:00
Ruslan Sayfutdinov 9b058551f7
Enable type checks for camera platform (#50179) 2021-05-09 18:04:57 +02:00
Tobias Sauerwein 2b79c91813
Clean up camera service schema (#49151) 2021-04-13 13:07:05 +02:00
Erik Montnemery 346a724ac3
Mark base components' state_attribute @final, rename others to extra_state_attributes (#48161)
* Mark base state_attributes @final, rename others to extra_state_attributes

* Fix calendar, update tests
2021-03-21 10:38:24 +01:00
Franck Nijhof ea4bbd771f
Add service names to previously enriched services (#46929)
Co-authored-by: Tobias Sauerwein <cgtobi@users.noreply.github.com>
2021-02-23 14:10:13 +01:00
Allen Porter 4aa4f7e285
Rollback stream StreamOutput refactoring in PR#46610 (#46684)
* Rollback PR#46610

* Update stream tests post-merge
2021-02-20 06:49:39 -08:00
Franck Nijhof dec2eb36fd
Add selectors to Camera service definitions (#46630) 2021-02-18 12:24:04 +01:00
Allen Porter 4236f6e5d4
Fix stream keepalive on startup (#46640)
This was accidentally dropped in a previous PR that refactored the interaction
between stream and camera. This is difficult to test from the existing
preload stream tests, so leaving untested for now.
2021-02-16 20:46:44 -08:00
Allen Porter 08201d146b
Separate HLS logic out of core StreamOutput to prepare for discontinuity (#46610)
Separate the HLS stream view logic out of StreamOutput since the hls
stream view is about to get more complex to track discontinuities. This
makes the idle timeout, shutdown, and coupling between hls and record
more explicit.
2021-02-16 06:59:43 -08:00
Allen Porter b33753f334
Move camera timeouts to constants (#46262)
Addresses feedback from pr #45431.  Also removes an redundant `create_stream` timeout.
2021-02-08 21:21:14 -08:00
Allen Porter 2bcf87b980
Change the API boundary between camera and stream with initial improvement for nest expiring stream urls (#45431)
* Change the API boundary between stream and camera

Shift more of the stream lifecycle management to the camera.  The motivation is to support stream urls that expire
giving the camera the ability to change the stream once it is created.

* Document stream lifecycle and simplify stream/camera interaction

* Reorder create_stream function to reduce diffs

* Increase test coverage for camera_sdm.py

* Fix ffmpeg typo.

* Add a stream identifier for each stream, managed by camera

* Remove stream record service

* Update homeassistant/components/stream/__init__.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Unroll changes to Stream interface back into camera component

* Fix preload stream to actually start the background worker

* Reduce unncessary diffs for readability

* Remove redundant camera stream start code

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-02-08 19:53:28 -08:00
Ville Skyttä 317ed418dd
Use singleton enum for "not set" sentinels (#41990)
* Use singleton enum for "not set" sentinel

https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions

* Remove unused variable
2020-12-19 12:46:27 +01:00
HomeAssistant Azure b71e28dfac [ci skip] Translation update 2020-11-04 00:13:14 +00:00
HomeAssistant Azure 6e53aa1155 [ci skip] Translation update 2020-10-23 00:03:04 +00:00
HomeAssistant Azure 6ae12c3faf [ci skip] Translation update 2020-10-10 00:05:05 +00:00
Jason Hunter 8bc62f3678
Fix camera play stream (#40641)
Co-authored-by: Justin Wong <46082645+uvjustin@users.noreply.github.com>
2020-09-28 14:24:30 +02:00
springstan c2d20c548f
Use content type multipart constant (#40314) 2020-09-23 11:29:56 +02:00
Jason Hunter 1a78d96014
allow creating directories from camera snapshot, stream record, and tensorflow file out (#39728) 2020-09-06 18:54:24 -04:00
Ville Skyttä b4bac0f7a0
Exception chaining and wrapping improvements (#39320)
* Remove unnecessary exception re-wraps

* Preserve exception chains on re-raise

We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.

The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.

Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.

* Fix mistaken re-wrap in homematicip_cloud/hap.py

Missed the difference between HmipConnectionError and
HmipcConnectionError.

* Do not hide original error on plex new cert validation error

Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
2020-08-28 13:50:32 +02:00
Cooper Dale 0b0e323632
Fix missing .name at entity_id in service example (#38515)
for propper filename
2020-08-03 18:22:52 +02:00
Ville Skyttä ac0dbb17af
Attrs cleanups (#37849) 2020-07-14 10:30:30 -07:00
Franck Nijhof 53545c984b
Log lines do not end with a full stop (#37527) 2020-07-05 23:04:19 +02:00
Paulus Schoutsen 276f3afb00
Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-31 22:18:30 -07:00
Ville Skyttä f8416484f8
More data entry flow and HTTP related type hints (#34430) 2020-05-26 09:28:22 -05:00
J. Nick Koston 3dfeec5033
Implement async_get_stream_source in the camera integration (#35704) 2020-05-25 15:41:50 -07:00
Franck Nijhof e3e3a113e9
async_get_url -> get_url (#35382) 2020-05-08 21:53:28 +02:00
Franck Nijhof 2223592486
Add get_url helper, deprecate base_url (#35224) 2020-05-08 02:29:47 +02:00
HomeAssistant Azure 7faba60e83 [ci skip] Translation update 2020-04-29 00:03:31 +00:00
HomeAssistant Azure aa2bfbb541 [ci skip] Translation update 2020-04-27 00:02:20 +00:00
HomeAssistant Azure 46920e9be6 [ci skip] Translation update 2020-04-22 00:03:20 +00:00
Joakim Sørensen 730a257f3c
Rename translations dir for integrations (#34494) 2020-04-21 16:11:05 -07:00
Paulus Schoutsen 95357dfc55 Update translations 2020-04-20 16:33:54 -07:00
Paulus Schoutsen d560e8245a
Import state strings (#34451) 2020-04-20 16:25:35 -07:00
Paulus Schoutsen 0d60d40512 Update translations 2020-04-16 13:00:10 -07:00
Paulus Schoutsen 6119e79023
Migrate frontend translations of domains to backend (#34294) 2020-04-16 11:52:27 -07:00
Martin Hjelmare 20aa089243
Clean up camera and demo camera (#34058)
* Clean up demo camera

* Complete test_motion_detection

* Clean up image reading

* Clean up camera integration async methods

* Fix and clean camera integration tests

* Fix image processing patch
2020-04-12 14:56:19 +02:00
Franck Nijhof 39336d3ea3
Add prettier (in pre-commit and CI) (#33693)
* 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
2020-04-05 17:27:16 +02:00
Paulus Schoutsen f1d3c0d19b
Remove unused manifest fields (#33595) 2020-04-03 12:58:19 -07:00
Paulus Schoutsen aef06a3544
Directly call write state 2 (#33513)
* Directly call async_write_ha_state pt2

* Directly call async_write_ha_state pt2

* Fix mock

* Address comments
2020-04-03 09:34:50 +02:00
ochlocracy 86f61b8e55
Fix camera.options to camera.stream_options. (#32767) 2020-03-13 11:50:16 -04:00
Rami Mosleh e1cc2acdf9
Specify rtsp_transport for Onvif Camera (#31918)
* specify rtsp_transport for onvif camera

* remove used variable

* Update homeassistant/components/stream/__init__.py

Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>

* change options to stream_options

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-03-06 09:59:57 -08:00
olijouve 0d667c1bd9
Add more onvif PTZ move modes (#30152)
* Adding support for PTZ move modes

Adding support for other PTZ move modes.
Onvif intergration used to only support RelativeMove where it should also supports AbsoluteMove, ContinuousMove and Stop.
For exemple Goke GK7102 based IP camera only support ContinuousMove mode.

This commit add those new modes with avaibility to select mode and params in service call.

* Adding support for PTZ move modes

Adding support for other PTZ move modes.
Onvif intergration used to only support RelativeMove where it should also supports AbsoluteMove, ContinuousMove and Stop.
For exemple Goke GK7102 based IP camera only support ContinuousMove mode.

Update service helper for new avaibility to select mode and params in service call.

* RelativeMode as default move_mode to avoid breakchange

RelativeMode as default move_mode to avoid breakchange

* add missing attribute

add missing continuous_duration attribute

* change service attribute label for continuous_duration

* update description

fix wrong assertion for move_mode attr description

* Update services.yaml

* Update services.yaml

fix wrong wording for move_mode

* Update camera.py

Using defined constants instead of  raw strings in conditions

* Update camera.py

Replace integer to floating point in logger debug PTZ values

* Update services.yaml

* Update services.yaml

* Update camera.py

* Update camera.py

* use dict[key] for required schema keys and keys with default schema values

* remove async for setup_ptz method

* lint error

* remove unecessary PTZ_NONE = "NONE"

changed request by @MartinHjelmare

* addressing @ MartinHjelmare comments

- Remove None in defaluts and dicts
- Replace long if blocks

* remove NONE

* lint issue

* Update camera.py

* Fix lint error - typo

* rename onvif_ptz service to just ptz

* rename onvif_ptz service to just ptz

* use dict[key] when default values are set

use service.data[key] instead of service.data.get[key] when default value is set in service schema

* adresse comment: use dict[key] for pan tilt zoom

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-03-06 15:14:01 +01:00
Pascal Vizeli 9aaab41985
Deprecate camera WS API (#32473) 2020-03-04 21:58:07 +01:00
Christian Clauss df7d2b3aeb
Fix typos found by codespell (#31243)
* Fix typos found by codespell

* Fix typos found by codespell

* codespell: Furture  ==> Future

* Update test_config_flow.py

* Update __init__.py

* Spellcheck: successfull  ==> successful

* Codespell: unsuccesful  ==> unsuccessful

* Codespell: cant  ==> can't

* Codespell: firware ==> firmware

* Codespell: mimick  ==> mimic
2020-01-31 08:33:00 -08:00
Paulus Schoutsen d405069406
Guard for callbacks in service helper (#31339) 2020-01-31 09:32:43 +01:00
Paulus Schoutsen e9e44dbd97
Fix callback and async (#31281)
* Fix callback and async

* Fix a return

* Fix test

* Fix mqtt tests

* Fix some more callbacks
2020-01-29 13:59:45 -08:00
Franck Nijhof bfa0edaf92 Migrate Integration Quality Scale from docs to manifest: internal (#30551) 2020-01-07 20:58:49 +01:00
Ville Skyttä e6388e186c
Remove unnecessary string literal concatenations (#30360) 2020-01-02 21:17:10 +02:00
Paulus Schoutsen e0d6810134
Remove stream from camera after deps (#30057) 2019-12-19 11:23:19 +01:00
Bas Nijholt 4c5c34919d Sort imports according to PEP8 for camera (#29691) 2019-12-09 11:50:48 +01:00