Commit Graph

42 Commits (014c2d487d1075724fce3396a1c9eda36b823721)

Author SHA1 Message Date
Allen Porter dfab3b2651
Partially revert google local sync for search cases (#81761)
fixes undefined
2022-11-08 11:21:13 +01:00
Allen Porter 0e2bea038d
Update Google Calendar to synchronize calendar events efficiently (#80925)
* Sync google calendar and serve from local storage

Update to use new gcal_sync APIs
Update google calendar filter logic
Remove storage on config entry removal
Make timeline queries timezone aware
Do not block startup while syncing

* Minor readability tweaks

* Remove unnecessary args to async_add_entities

* Change how task is created on startup

* Update homeassistant/components/google/calendar.py

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

* Revert min time between updates

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-10-26 07:57:49 -07:00
Allen Porter a7f33535c7
Fix google calendar event transparency filter (#80438) 2022-10-16 14:45:27 -04:00
Allen Porter b969ed00b9
Fix google calendar disabled entity handling (#76699)
Fix google calendar disable entity handling
2022-08-13 15:02:32 +02:00
Allen Porter f4e61eff18
Add update coordinator for google calendar (#74690)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-10 21:24:52 -07:00
Allen Porter 6f9fcdff99
Improve calendar error handling to match best practices (#74891) 2022-07-10 10:04:57 -07:00
Allen Porter 08d8304a52
Migrate google calendar to new entity naming (#74727)
* Migrate google calendar to new entity naming

* Update homeassistant/components/google/calendar.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-07-08 07:59:50 -07:00
Allen Porter 561c9a77d8
Add google calendar service proper exception handling (#74686) 2022-07-07 20:50:19 -07:00
Allen Porter d399815bea
Allow multiple google calendar config entries (#73715)
* Support multiple config entries at once

* Add test coverage for multiple config entries

* Add support for multiple config entries to google config flow

* Clear hass.data when unloading config entry

* Make google config flow defensive against reuse of the same account

* Assign existing google config entries a unique id

* Migrate entities to new unique id format

* Support muliple accounts per oauth client id

* Fix mypy typing errors

* Hard fail to keep state consistent, removing graceful degredation

* Remove invalid entity regsitry entries
2022-06-21 06:42:41 -07:00
Allen Porter ab95299150
Bump gcal_sync to 0.10.0 and fix `google` typing (#73710)
Bump gcal_sync to 0.10.0
2022-06-19 20:16:07 +02:00
Allen Porter 91cd61804e
Deprecate google calendar add_event service, replaced with entity service (#72473)
* Deprecate google calendar add_event service, replaced with entity service

* Fix inconsistencies and bugs in input validation

* Update validation rules and exceptions

* Resolve merge conflicts
2022-06-09 16:08:08 +02:00
Allen Porter 9d933e732b
Remove google scan_for_calendars service and simplify platform setup (#73010)
* Remove google scan_for_calendars service and simplify platform setup

* Update invalid calendar yaml test
2022-06-03 21:56:53 -07:00
Allen Porter 371dfd85c8
Reduce the scope of the google calendar track deprecation (#72575) 2022-05-27 11:52:24 +02:00
Allen Porter e6ffae8bd3
Deprecate google calendar configuration.yaml (#72288)
* Deprecate google calendar configuration.yaml

* Remove unused translations

* Enable strict type checking and address pr feedback

* Move default hass.data init to `async_setup`
2022-05-22 14:29:11 -07:00
Allen Porter 8a13c6744a
Bump gcal_sync to 0.6.2 and switch to google calendar async iterator api (#70616)
* Switch to google calendar async iterator api

* Update homeassistant/components/google/calendar.py

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

* Add test coverage for paging through results

* Bump gcal_sync to 0.6.1

* Bump gcal-sync 0.6.2

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-27 07:22:15 -07:00
Allen Porter 0e0c0ce22b
Move google calendar integration to aiohttp (#70173)
* Use new aiohttp based google client library in gcal_sync.

* Use base url in tests for shorter string

* Remove unnecessary line of code

* Jump to gcal-sync-0.4.1

* Update tests/components/google/conftest.py

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

* Update to gcal_sync 0.5.0 incorporating PR feedback

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-20 20:18:24 -07:00
Allen Porter 36bb947cdf
Fix bug in google calendar offset calculation (#70024)
Move the offset reached computation outside of the update method so that it is
computed when state updates occur rather than when data refreshes happen (which
are throttled and happen at most every 15 minutes).

Issue #69892
2022-04-13 19:04:59 -07:00
Allen Porter f99b6004ea
Cleanup calendar APIs and introduce a dataclass for representing events (#68843)
* Introduce data class to hold calendar event data

* Rename CalendarEventDevice to CalendarEntity

* Apply suggestions from code review

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

* Fix docstring on google calendar api conversion function.

* Update todoist to new calendar enttiy api, tested manually

* Add back old API for a legacy compatibility layer

* Add deprecation warning for old calendar APIs

* Fix deprecation warning

* Fix merge for missing summary #69520

* Add mypy typing for newly introduced classes

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-10 12:04:07 -07:00
Allen Porter 10a1b1f734
Gracefully handle empty summary in google calendar (#69520)
Gracefully handle empty summary in google calendar matching the old behavior
before some code cleanup.
2022-04-07 08:26:07 +02:00
Allen Porter f61c911174
Remove some offset complexity from calendar event (#68724)
Simplify the calendar offset calculations to no longer update the event dictionary
using extra fields. calculate_offset is renamed to extract_offset and the integration
is responsible for overwriting the summary text.

This is in prepration for:
- Improved calendar event typing, removing unnecessary offset_reached field
- Calendar triggers which will remove offsets anyway
2022-03-27 10:02:19 -07:00
Allen Porter 7876ffe9e3
Update google calendar integration with a config flow (#68010)
* Convert google calendar to config flow and async

* Call correct exchange method

* Fix async method and reduce unnecessary diffs

* Wording improvements

* Reduce unnecessary diffs

* Run load/update config from executor

* Update homeassistant/components/google/calendar.py

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

* Remove unnecessary updating of unexpected multiple config entries.

* Remove unnecessary unique_id checks

* Improve readability with comments about device code expiration

* Update homeassistant/components/google/calendar.py

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

* Update homeassistant/components/google/calendar.py

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

* Update homeassistant/components/google/api.py

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

* Add comment for when code is none on timeout

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-03-15 07:51:02 +01:00
Allen Porter c456b4c646
Fix google calendar comment typo (#67389) 2022-02-28 18:52:52 +01:00
Allen Porter afaaabd2fe
Cleanup google calendar by removing some device abstractions (#67356)
* Remove unnecessary abstraction in google calendar

* Simplify diffs for calendar event filtering
2022-02-27 15:01:54 -08:00
Allen Porter deda9e38e4
Simplify google calendar API interactions (#67319)
* Simplify google calendar APIs and tests

* Simplify authentication logic at startup

* Improve readability of diffs

* Reduce diffs

* Simplify api datetime logic

* Remove duplicate test fixtures added in prior commit

* Remove duplicate event filter calls

* Fix event list argument names

* More improvements found from additional testing

* Remove unnecessary variables in create event call
2022-02-26 16:19:45 -08:00
Allen Porter 1383034df2
Simplify google calendar event filters (#67312)
Simplify google calendar event filtering logic currently copied between two methods.
2022-02-26 15:27:08 -08:00
Allen Porter d3374ecd8e
Add type hints for google calendar integration (#65353)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-02-01 17:28:32 +01:00
epenet ce6206b422
Add calendar setup type hints (#63272)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-03 13:14:02 +01:00
Allen Porter 23277181ca
Increase test coverage for google calendar (#62648)
* Increase test coverage for google calendar

Update tests to exercise the API responses, getting test coverage
to 97% for calendar.py

----------- coverage: platform linux, python 3.9.6-final-0 -----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
homeassistant/components/google/__init__.py     193     84    56%   92, 163-228, 238, 244-247, 254-262, 274, 298-299, 305-347, 387-392, 416-430, 435-437
homeassistant/components/google/calendar.py     122      4    97%   41, 45, 51, 135
---------------------------------------------------------------------------
TOTAL                                           315     88    72%

* Revert conftest changes

* Update typing errors found on CI

* Update python3.8 typing imports

* Remove commented out code
2021-12-23 07:31:56 +01:00
Bert Roos 476f3b5cb5
Fix Google Calendar event loading (#54231) 2021-08-16 20:20:16 -07:00
Erik Montnemery af4d06b12e
Update integrations f-i to override extra_state_attributes() (#47757) 2021-03-11 16:57:47 +01:00
Ville Skyttä dc880118a4
Lint suppression cleanups (#47248)
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01:00
tkdrob 92e5bf9786
Use core constants for google (#46210) 2021-02-08 12:24:48 +01:00
springstan a967f689c7
Remove unnecessary instances of dict.keys() (#42518) 2020-10-28 20:43:48 +01:00
Quentame 61edd33da7 Move imports in google component (#27826) 2019-10-17 17:11:51 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Martin Hjelmare 177f5a35ae Rewrite calendar component (#24950)
* Correct google calendar test name

* Rewrite calendar component

* Save component in hass.data.
* Rename device_state_attributes to state_attributes.
* Remove offset attribute from base state_attributes.
* Extract offset helpers to calendar component.
* Clean imports.
* Remove stale constants.
* Remove name and add async_get_events.
* Add normalize_event helper function. Copied from #21495.
* Add event property to base entity.
* Use event property for calendar state.
* Ensure event start and end.
* Remove entity init.
* Add comment about event data class.
* Temporary keep old start and end datetime format.

* Convert demo calendar

* Convert google calendar

* Convert google calendar.
* Clean up google component.
* Keep offset feature by using offset helpers.

* Convert caldav calendar

* Clean up caldav calendar.
* Update caldav cal on addition.
* Bring back offset to caldav calendar.
* Copy caldav event on update.

* Convert todoist calendar
2019-07-10 20:59:37 -07:00
Martin Hjelmare b9fda078a4
Clean and fix google calendar tests (#23608)
* Clean and fix google calendar tests

* Extract test calendar constant for google test
* Rewrite google calendar tests
* Clean and fix google calendar tests
* Clean and fix google component tests
* Add google conftest
* Skip flaky google calendar test

* Fix google calendar bug

* Fix yield fixture

* Set fixture names to avoid lint warning

* Fix yield fixture
2019-05-05 18:38:55 +02:00
Wojciech Mamak b60c7ce479 Fixed bug with max_result (#23507)
The config option 'max_result' was assigned to not existing 'max_result' variable, it should be assigned to 'maxResult'.
The current version causes an error when max_result option is used.
2019-04-28 21:01:33 +02:00
yosilevy e14dbfb006 Add google calendar max_results config option (#21874)
* Added max_results config capability to google calendar (people are creating custom components just to override that)

* Dummy commit

* Dummy commit 2

* Changed to positive_int

* Removed double imports
2019-03-28 19:56:12 -07:00
Paulus Schoutsen 4b1de61110
Use relative imports inside integrations (#22235)
* Use relative imports inside integrations

* Lint

* Fix automation tests

* Fix scene imports
2019-03-20 22:56:46 -07:00
Fabian Affolter 3736120c6a
Update file header (#21061)
* Update file header

* Fix lint issue

* Fix lint issue
2019-02-14 16:01:46 +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