Commit graph

95 commits

Author SHA1 Message Date
Allen Porter
e56e25180b
Strip whitespace in nest cloud project id (#64503) 2022-01-20 09:13:49 +01:00
Allen Porter
f1435b1385
Add diagnostic information for nest (#64405)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-01-19 09:30:48 +01:00
Allen Porter
849abaca8b
Bump google-nest-sdm to 1.5.0 and add nest mp4 clip transcoding to animated gif (#64155) 2022-01-15 12:31:02 -08:00
Allen Porter
64c5f69c3d
Add thumbnails to nest media player (#62532) 2022-01-13 22:31:33 -08:00
Marc Mueller
d057850971
Update typing - collections.abc (3) (#63947) 2022-01-12 08:04:17 +01:00
Allen Porter
789c0a24dd
Improve nest media player clip/image and event handling for multiple events in a short time range (#63149) 2022-01-11 20:54:49 -08:00
Allen Porter
4203e1b064
Delete nest event image fetching and use same APIs as media player (#62789) 2022-01-07 16:37:54 +01:00
Allen Porter
da71e89f53
Add tests that exercise nest dhcp discovery behavior (#62526)
* Add tests that exercise nest dhcp discovery

Add tests that exercise the behavior of dhcp discovery for nest,
which is effectively that it doesn't work -- it only works when
you have already added a configuration.yaml.

Discovery can be made to work by using an entirely config flow
driven approach, which is in discussion.

* Adjust whitespace from merge
2022-01-05 17:35:55 -08:00
Allen Porter
d6c8f3965a
Improve nest camera failure handling on removal (#63207) 2022-01-05 16:17:51 +01:00
Allen Porter
224f960050
Set the nest configuration title to a user friendly name (#62886)
* Set the nest configuration title to a user friendly name

Set the config entry title name to be the name of the Google Home or
Nest Home that was authorized. In case more than one home was authorized,
they are all listed since they are all accessed over a single shared
home.

* Fix pylint errors

* Resolve pylint errors
2022-01-04 19:23:20 -08:00
Allen Porter
0bcad5579b
Set nest climate hvac_action to report idle when hvac mode is not off (#62811) 2022-01-04 17:28:46 +01:00
Allen Porter
9e3f7d2961
Simplify nest reauth config flow (#63058) 2022-01-02 21:43:50 +01:00
Allen Porter
15baea4ba3
Use more narrow exception catching in nest (#63225) 2022-01-02 18:54:56 +01:00
Allen Porter
ebc8e19788
Revert nest reloading due to lock up (#63206) 2022-01-02 17:08:38 +01:00
Allen Porter
788373a7ca
Update legacy nest config flow tests to use modern best practices (#63019)
* Update legacy nest tests to use modern best practices

Update legacy nest integration config flow tests to test the config flow actually through the integration APIs rather
than interacting with the config flow object directly. This is a pre-factoring pulled out of a larger config flow revamp
where we want to exercise the actual production code for initializing configuration, config flows, and authentication
implementations.

* Revert some test name/comment changes

* Update setup calls to verify async_setup_legacy is called
2021-12-29 10:38:50 -08:00
Allen Porter
2df0adfbc7
Reload nest integration when new devices are added (#62976) 2021-12-29 12:20:55 +01:00
Allen Porter
17fbfe2eed
Set a suggested_area on nest devices based on the Google Home room name (#62871) 2021-12-27 11:39:57 -08:00
Ville Skyttä
f913961d63
Use DeviceAutomationType in tests/components/[m-r]* (#62443) 2021-12-20 22:29:22 +01:00
Allen Porter
368e16f189
Simplify nest test patch using new keyword (#62336) 2021-12-19 11:45:04 -08:00
Allen Porter
a63fa53275
Persist nest media events to disk backed storage (#61641)
* Persist nest media events to disk backed storage

Persist nest events in the media player to disk, targeting about ~500mb
per camera device as a cap. Events are stored in config/nest/event_media/.

Add a NestEventMediaStore is used for persistence. It has three main jobs:
- Read/write the key/value data that holds event data (event type, time, device, etc)
- Read/write media contents to disk
- Pick the filename for the media event based on device and event deatils

The nest event media manager library handles cache management and eviction, and by
default uses an in memory cache. Home Assistant nest integration now provides the
disk backed implementation, which is invoked by the nest library.

The store reads the event metadata key/value dict on startup, and then writes it
back with a short delay of 5 seconds to avoid unnecessary writes.

Future work planned includes:
- Possibly a small memory buffer for media objects themselves. This could make sense
  when adding thumbnails to the media player grid to avoid unnecessary fetches
- Transcoding mp4 clips to animated image previews

* Address style errors

* Cleanup from CI test/pylint/etc.

* Put media for each device into its own directory

* Update comments for media store

* Decrease # of events to lower disk requirements

Target more like 1k events, to reduce disk needs.

* Address PR feedback

* Update homeassistant/components/nest/media_source.py

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

* Ignore incorrect mypy in nest library

* Fix pylint errors

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-12-18 23:53:40 -08:00
Allen Porter
bff677e34e
Bump google-nest-sdm to 0.4.8 (#61851) 2021-12-15 13:12:38 +01:00
Allen Porter
efbec55818
Suppress errors for legacy nest api when using media source (#61629) 2021-12-13 17:41:45 +01:00
Allen Porter
cd001d0243
Only publish nest camera event messages once per thread and bump nest version (#61587) 2021-12-12 14:12:05 -08:00
Allen Porter
c3e72bec0a
Update logic for nest media source can_play for events (#61537) 2021-12-12 14:10:20 -08:00
Allen Porter
bbe4a67a98
Coalesce nest media source preview clips by session and bump google-nest-sdm (#61081) 2021-12-05 23:59:24 -08:00
Allen Porter
5bd1139867
Fix regression in nest event media player with multiple devices (#61064) 2021-12-05 13:02:37 -08:00
Allen Porter
5fdcbbe0e1
Fetch media for events for rendering in the nest media player (#61056) 2021-12-05 09:45:40 -08:00
Allen Porter
08003c5287
Improve nest media source event timestamp display (#61027)
Drop subsecond text from the nest media source event timestamp display, using a common date/time
template string.
2021-12-05 00:39:18 -08:00
Allen Porter
ba99dc3af9
Add Nest Battery Cam event clip support with a Nest MediaSource (#60073) 2021-12-03 10:53:05 -08:00
Allen Porter
a84b12abe7
Revert "Add an entity service for saving nest event related snapshots" (#60632) 2021-11-30 16:16:00 +01:00
Allen Porter
c4e5242b0c
Add an entity service for saving nest event related snapshots (#58369)
* Add an entity service for saving nest event related snapshots

Add an entity service `nest.snapshot_event` for recording camera event
related media to disk. This is based on `camera.snapshot` but takes in
a parameter for a Nest API event_id.

PR #58299 adds `nest_event_id` to events published by nest so that they can
be hooked up to this service for capturing events.

Future related work includes:
- Height & Width parameters for the rendered image
- Support video clips for new battery cameras
- An API for proxying media related to events, separate from the camera image thumbnail
- A Nest MediaSource for browsing media related to events

* Revert debugging information

* Add test coverage for OSError failure case

* Add service description for nest snapshot service

* Reduce unnecessary diffs.

* Sort nest camera imports

* Remove unnecessary if block in snapshot
2021-11-29 23:04:29 -08:00
Allen Porter
cc543b200d
Update nest config flow to dramatically simplify end user setup with automated pub/sub subscription creation (#59260)
* Configure nest pubsub subscriber automatically

Update the config flow to configure the nest pubsub subscriber automatically.
After completing the authentication step, the user is now asked for the google
cloud console ID, which is needed to create a subscription.

Home Assistant manages the lifecycle of a subscription only when it is created
by the ConfigFlow. Otherwise (if specified in configuration.yaml) it treats
it similarly as before.

These are the considerations or failure modes taken into account:
- Subscription is created with reasonable default values as previously recommended (e.g. retion only keeps 5-15 minutes of backlog messages)
- Subscriptions are created with a naming scheme that makes it clear they came from home assistant, and with a random
  string
- Subscriptions are cleaned up when the ConfigEntry is removed. If removal fails, a subscription that is orphaned will
  be deleted after 30 days
- If the subscription gets into a bad state or deleted, the user can go through the re-auth flow to re-create it.
- Users can still specifcy a CONF_SUBSCRIBER_ID in the configuration.yaml, and
skip automatic subscriber creation

* Remove unnecessary nest config flow diffs and merge in upstream changes

* Incorporate review feedback into nest subscription config flow

* Update text wording in nest config flow
2021-11-29 22:41:29 -08:00
Allen Porter
0991a30125
Pre-factor nest subscriber to library (#59462)
* Pre-factor nest subscriber to library

Move the nest subscriber to a library that can be reused in a future PR:
- From ConfigFlow for creating subscriptions
- On nest removal to delete subscriptions

This is pulled out of PR #59260 to make that easier to review.

* Resolve pylint error in nest api subscriber

* Remove duplicate constants
2021-11-14 16:08:22 -08:00
Allen Porter
dbfe0cad52
Refactor nest test ConfigEntry setup in config flow tests (#59459)
* Refactor nest ConfigEntry creation in tests into a helper

This is pulled out of PR#59260 to make that overall diff smaller.

* Add typing consistently on new functions
2021-11-14 10:12:25 -08:00
Allen Porter
fa4e890696
Revamp nest authentication config flows and remove need for redirect urls (#59033)
* Add support for Installed Auth authentication flows.

Add support for additional credential types to make configuration simpler for
end users. The existing Web App auth flow requires users to configure
redirect urls with Google that has a very high security bar: requires ssl,
and a publicly resolvable dns name.

The new Installed App flow requires the user to copy/paste an access code
and is the same flow used by the `google` calendar integration. This also
allows us to let users create one authentication credential to use with
multiple google integrations.

* Remove hard migration for nest config entries, using soft migration

* Add comment explaining soft migration

* Revet changes to common.py made obsolete by removing migration

* Reduce unnecessary diffs in nest common.py

* Update config entries using library method

* Run `python3 -m script.translations develop`

* Revert nest auth domain

* Remove compat function which is no longer needed

* Remove stale nest comment

* Adjust typing for python3.8

* Address PR feedback for nest auth revamp
2021-11-04 15:56:16 -07:00
Allen Porter
9c5a79c641
Add an image placeholder for Nest WebRTC cameras (#58250) 2021-10-28 21:07:29 -07:00
epenet
19eba5a3a0
Use constants for device registry checks (#58514)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2021-10-27 11:34:58 +02:00
Allen Porter
f1b082a369
Publish nest event ids in camera related events (#58299) 2021-10-26 10:14:12 -05:00
Ville Skyttä
380cff167e
Use HTTPStatus in components/[nop]* (#58279) 2021-10-23 20:56:30 +02:00
Allen Porter
400e85a299
Rename tests filenames to conform to Home Assistant standards (#58266) 2021-10-22 22:25:55 -07:00
Allen Porter
fc7be8aa00
Fix a bug in a nest test that causes side effects for other tests (#58264)
Fix a bug where a constant configuration variable in the common test library
is modified during the test, causing side effects for other tests.

This was found by renaming the tests, which caused other tests to fail.
2021-10-22 21:33:40 -07:00
Michael Davie
e481c862a6
Change precision of Nest sensors (#56993)
* Change precision of Nest sensors

* Add comment to temp rounding

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* Update rounding and tests

* Add test for rounding

Co-authored-by: Allen Porter <allen.porter@gmail.com>
2021-10-22 20:31:25 -07:00
Allen Porter
7d6ad6e5e3
Add additional nest stream test coverage (#58013) 2021-10-22 23:30:15 +02:00
Allen Porter
4501906da3
Fix additional nest camera_sdm_tests to use STATE_STREAMING (#57920) 2021-10-17 22:04:12 +02:00
Allen Porter
3d33cad655
Improve nest error handling for websocket streams (#57885) 2021-10-17 19:46:18 +02:00
Allen Porter
95b07c138c
Set nest camera always on STATE_STREAMING (#57882) 2021-10-17 19:45:31 +02:00
Allen Porter
1fa6329c2e
Add Nest WebRTC and support Nest Battery Camera and Nest Battery Doorbell (#57299)
* Add WebSocket API for intiting a WebRTC stream

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

* Add nest support for initiating webrtc streams

Add an implementation of async_handle_web_rtc_offer in nest, with test coverage.
Issue #55302

* Rename offer variable to match overriden variable name

* Remove unnecessary checks covered by websocket function

* Update homeassistant/components/camera/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-13 03:28:52 -07:00
Allen Porter
d0cc890d2b
Add statistics support to nest sensors (#57393)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-10-12 10:56:57 +02:00
Erik Montnemery
f6682ba99d
Block tests from opening sockets (#55516) 2021-10-05 14:46:09 -10:00
Erik Montnemery
f6526de7b6
Use hass_client_no_auth test fixture in nest tests (#56326) 2021-09-18 23:17:09 +02:00