Commit Graph

128 Commits (1a4cac95a13bb3faf658ffc795642c58c5e31d63)

Author SHA1 Message Date
uvjustin 31ad208500
Use async with to fetch HTTP streams in tests (#82788) 2022-11-27 14:35:03 -05:00
uvjustin ee910bd0e4
Refactor camera stream settings (#81663) 2022-11-13 01:22:59 +08:00
uvjustin 84725f15a6
Use IntEnum for stream orientation (#81835)
* Use IntEnum for stream orientation

* Rename enum values

* Add comments

* Fix import
2022-11-09 07:28:28 -08:00
Erik Montnemery 31a787558f
Ensure recorder test fixture is setup before hass fixture (#80528)
* Ensure recorder test fixture is setup before hass fixture

* Adjust more tests
2022-10-19 07:58:47 +02:00
uvjustin 852b0caf5b
Add orientation transforms to stream (#77439) 2022-09-06 13:31:36 +08:00
uvjustin 6540bed59d
Defer preload stream start on startup (#75801) 2022-08-08 11:15:31 -04:00
uvjustin d989e4373d
Remove websocket_api send_big_result (#75452) 2022-07-19 21:08:11 -07:00
uvjustin 73f2bca377
Make Stream.stop() async (#73107)
* Make Stream.start() async
* Stop streams concurrently on shutdown
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-08 00:10:53 +08:00
Erik Montnemery 5f2b4001f3
Separate recorder database schema from other classes (#72977)
* Separate recorder database schema from other classes

* fix logbook imports

* migrate new tests

* few more

* last one

* fix merge

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-07 14:41:43 +02:00
Erik Montnemery 47d0cc9b09
Update integrations to pass target player when resolving media (#72597) 2022-05-27 09:05:06 -07:00
uvjustin 221b77297e
Declare exports from stream explicitly (#71898) 2022-05-15 17:58:57 +02:00
Erik Montnemery 28ebab9c5a
Simplify waiting for recorder in tests (#70647) 2022-04-25 12:04:47 +02:00
Erik Montnemery 982e314de6
Use recorder_mock in tests (#70363)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-04-22 19:29:44 -10:00
Franck Nijhof c93c7e8eff
Replace Camera STREAM_ constants with StreamType enum (#69871) 2022-04-11 16:27:27 -07:00
J. Nick Koston 522a9bb6b1
Exclude supported features and attribution from being recorded in the database (#69165) 2022-04-03 13:51:42 +02:00
Franck Nijhof 93571c2d01
Add EntityFeature enum to Camera (#69072) 2022-04-01 09:38:03 -07:00
J. Nick Koston f5a13fc51b
Add ability to exclude attributes from being recorded by entity domain (#68824) 2022-03-29 20:13:08 -07:00
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
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
Paulus Schoutsen fec8c2ab82
Add support for MJPEG cameras to camera media source (#66499) 2022-02-14 17:04:19 +01: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
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
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 6e13605cad
Add get_image method to Stream (#61918)
* Add get_image method to Stream

* Add KeyFrameConverter class
2021-12-23 00:24:53 +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
Ville Skyttä 73d192b3f3
Use HTTPStatus instead of HTTP_ consts and magic values in comp.../[bc]* (#57989) 2021-10-22 19:43:40 +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
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
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
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
Dermot Duffy 2e1037005c
Allow camera stream to fail safely (#50728) 2021-05-17 20:34:25 -07: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
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Ville Skyttä ad1a71ebc3
Don't try to create /test dir in camera tests (#39914)
ERROR:homeassistant.components.camera:
Can't write image to file: [Errno 13] Permission denied: '/test'
2020-09-14 08:40:59 +02:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +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
J. Nick Koston 3dfeec5033
Implement async_get_stream_source in the camera integration (#35704) 2020-05-25 15:41:50 -07:00
Franck Nijhof 2223592486
Add get_url helper, deprecate base_url (#35224) 2020-05-08 02:29:47 +02:00
Paulus Schoutsen 2af984917e
Use asynctest-mock in most places (#35109)
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -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 123ae941a9
Various camera test improvements (#34022) 2020-04-11 21:10:15 +02:00
Ville Skyttä 5e2ba2eb77
Enable some more bandit checks (#30857)
* Enable B108 (hardcoded tmp dir), address findings

* Enable B602 (subprocess popen with shell), address findings

* Enable B604 (start process with shell), address findings

* Enable B306 (mktemp), B307 (eval), and B325 (tempnam), no issues to address
2020-01-20 18:44:55 +02:00
Paulus Schoutsen 5fdc60e067
Add Safe Mode (#30723)
* Store last working HTTP settings

* Add safe mode

* Fix tests

* Add cloud to safe mode

* Update logging text

* Fix camera tests leaving files behind

* Make emulated_hue tests not leave files behind

* Make logbook tests not leave files behind

* Make tts tests not leave files behind

* Make image_processing tests not leave files behind

* Make manual_mqtt tests not leave files behind
2020-01-14 13:03:02 -08:00
Ville Skyttä e6388e186c
Remove unnecessary string literal concatenations (#30360) 2020-01-02 21:17:10 +02:00