Commit Graph
71 Commits
Author SHA1 Message Date
J. Nick KostonandGitHub 5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
SidandGitHub d5f883fbf0 Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Marc MuellerandGitHub 81c34ac952 Fix spelling [docstrings + comments] (#114168) 2024-03-25 11:33:00 +01:00
Marc MuellerandGitHub 38adfbf1a3 Add empty line after module docstring [tests a-e] (#112708) 2024-03-08 08:50:25 -05:00
1eac7bcbec Fix calendar trigger to survive config entry reloads (#111334)
* Fix calendar trigger to survive config entry reloads

* Apply suggestions from code review

---------

Co-authored-by: Martin Hjelmare <[email protected]>
2024-02-29 03:45:51 +01:00
1069693292 Update calendar tests to use mock entities instead of demo platform (#105317)
* Update calendar tests to use mock entities instead of demo platform

* Add Generator type to fixture

* Fix generator syntax

---------

Co-authored-by: Martin Hjelmare <[email protected]>
2024-01-30 06:36:14 +01:00
Kevin StillhammerandGitHub 51385dcaab Deprecate calendar.list_events (#102481)
* deprecate calendar.list_events

* rename events to get_events

* raise issue for use of deprecated service

* Make issue fixable

* Add fix_flow

* Add service translation/yaml
2023-11-19 07:12:43 -08:00
Kevin StillhammerandGitHub d7e195ba40 Use snapshots in calendar tests (#102299) 2023-10-20 15:14:31 +02:00
Ville SkyttäandGitHub 3094991236 Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Allen PorterandGitHub 26f2fabd85 Fix timezones used in list events (#95804)
* Fix timezones used in list events

* Add additional tests that catch floating vs timezone datetime comparisons
2023-07-05 08:25:03 +02:00
Allen PorterandGitHub 2f73be0e50 Ensure that calendar output values are json types (#95797) 2023-07-03 12:05:02 -07:00
Allen PorterandGitHub 7252c33df8 Limit fields returned for the list events service (#95506)
* Limit fields returned for the list events service

* Update websocket tests and fix bugs in response fields

* Omit 'None' fields in the list events response
2023-06-29 13:25:25 -04:00
Allen PorterandGitHub b9b5fe6be8 Add service response data for listing calendar events (#94759)
* Add service response data for listing calendar events

Add the capability of response data for for the entity component.

* Rename input arguments and add service description

* Improve list events to be more user friendly

Allow the end date to be determined based on a relative time duration. Make the start time optional and set to "now". Add additional test coverage. Update demo calendar to actually perform date range checks.

* Wrap docstrings properly.

* Increase test coverage

* Update to use new API calls

* Readability improvements

* Wrap docstrings

* Require at least one of end or duration

* Check for multiple entity matches earlier in the request

* Update documentation strings
2023-06-23 23:34:34 -04:00
Erik MontnemeryandGitHub 9a3077d64a Always setup demo platforms with device support from config entry (#94586)
* Always setup demo platforms with device support from config entry

* Adjust test fixutres

* Update tests depending on the demo integration
2023-06-14 16:50:35 +02:00
Erik MontnemeryandGitHub 0126cfa9d9 Allow exposing any entity to the default conversation agent (#92398)
* Allow exposing any entity to the default conversation agent

* Tweak

* Fix race, update tests

* Update tests
2023-05-03 09:45:54 -04:00
Allen PorterandGitHub 14b95ffe3a Relax calendar event validation to allow existing zero duration events (#91129)
Relax event valudation to allow existing zero duration events
2023-04-10 10:04:42 -04:00
J. Nick KostonandGitHub d0d4ab6056 Require a list of entity ids when fetching history (#90992) 2023-04-08 16:14:44 -10:00
epenetandGitHub 60692bcfdb Fix lingering timers in calendar tests (#90845) 2023-04-05 20:46:05 -04:00
epenetandGitHub 35b642c6c8 Improve type hints in calendar trigger tests (#90827) 2023-04-05 14:08:55 +02:00
epenetandGitHub 5f3868b141 Add missing type hints to tests (#90218)
* Add type hints to tests

* Revert gree as handled in #90222
2023-03-24 19:34:01 -07:00
Allen PorterandGitHub 9721ba59b6 Rewrite the calendar trigger to fix potential bugs (#89918)
Update the calander event trigger logic to have more exhaustive coverage. The
trigger will now use a timespan to create an explicit window for considering
upcoming events. The start/end of the time span is now more explicit, rather
than getting it from the alarm time.

The trigger is now broken into composable pieces:
- A timespan object for more explicitly managing the time window
- A function to get events during a time span
- A function to process upcoming events and determine the trigger times

The existing listener is now just responsible for scheduling alarms and glue.

This fixes bug with DST handling where the conversion back and forth between
UTC and timezone ends up dropping events during the jump forward. In practice,
an event was returned from the scanning, but it was never fired by the trigger
because (1) it was filtered out of the interval and (2) the event list was
previously cleared every iteration so it would get dropped.

Future improvements can bake more invariant checking into this structure.
2023-03-19 23:42:12 -04:00
epenetandGitHub ff8b91aeea Add freezer to known test fixtures in pylint (#89825)
Add freezer to known fixtures in pylint
2023-03-16 22:39:41 -04:00
Allen PorterandGitHub 4ddcb14053 Add additional CalendarEvent validation (#89533)
Add additional event validation
2023-03-14 20:27:38 -04:00
J. Nick KostonandGitHub 1c57339ec3 Refactor recorder tests to use recorder history API (#89565) 2023-03-11 21:51:16 -05:00
Allen PorterandGitHub e1e0400b16 Fix local calendar issue with events created with fixed UTC offsets (#88650)
Fix issue with events created with UTC offsets
2023-02-23 13:37:15 -05:00
Albin MédocandGitHub f40b712664 Fix 500 error when getting calendar events (#88276)
* Fix 500 error when getting calendar event

* Add test for calendar dates in wrong order

* Update calendar tests to use f strings
2023-02-22 15:33:43 +01:00
Erik MontnemeryandGitHub 9989a4787b Fix recorder platform tests (#88330) 2023-02-17 08:22:15 -06:00
Franck NijhofandGitHub ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenetandGitHub fa7acb4f0d Add type hints to integration tests (part 3) (#87844) 2023-02-10 16:05:01 +01:00
epenetandGitHub 807c69f621 Add type hints to integration tests (b-c) (#87698) 2023-02-08 18:08:43 +01:00
Allen PorterandGitHub 7ff1265b10 Add service to create calendar events (#85805) 2023-01-25 12:43:50 +01:00
624c93bb38 Add Local calendar edit support (#84141)
* Add update support for calendars and implement in local calendar

* Fix supported feature for update calendar

* Increase test coverage for websocket error cases

* Improve test coverage for update failure cases

* Improve test coverage by sharing code between update and create

* Update homeassistant/components/calendar/__init__.py

Co-authored-by: Martin Hjelmare <[email protected]>

Co-authored-by: Martin Hjelmare <[email protected]>
2022-12-27 12:36:43 -08:00
Erik MontnemeryandGitHub a6217ca9b9 Improve error message when an automation fails to validate (#83977) 2022-12-21 23:20:50 +01:00
Allen PorterandGitHub 69dab4acfe Reduce unnecessary alarm firing to speed up calendar trigger test (#80732) 2022-10-21 10:47:37 -04:00
Allen PorterandGitHub d1d218444b Improve calendar trigger test quality (#79451)
Improve calendar test quality
2022-10-21 10:56:17 +02:00
Erik MontnemeryandGitHub 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
Allen PorterandGitHub ddf668d1cb Remove CalendarEventDevice which was deprecated in 2022.5 (#77809) 2022-09-04 22:25:43 -07:00
Allen PorterandGitHub 939c33b1dc Exclude calendar description from recorder (#75375) 2022-07-17 13:31:14 -07:00
Franck NijhofandGitHub af2feb3d40 Update pyupgrade to v2.37.1 (#74989) 2022-07-11 16:54:01 +02:00
Allen PorterandGitHub 6f9fcdff99 Improve calendar error handling to match best practices (#74891) 2022-07-10 10:04:57 -07:00
Matej DrobničandGitHub 690fb2ae86 Add back description and location to calendar endpoint (#71887) 2022-05-15 20:31:22 +02:00
285fdeb581 Add calendar trigger offsets (#70963)
* Add support for calendar trigger offsets

* Add offset end test

* Update homeassistant/components/calendar/trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Always include offset in trigger data

Co-authored-by: Martin Hjelmare <[email protected]>
2022-04-30 17:21:30 -07:00
Allen PorterandGitHub dc7e3a6df6 Fix boundary case in calednar trigger (#70467)
Update calendar trigger scan logic to add a one second boundary due to the
exclusive search. Add a test that reproduced the issue.
2022-04-24 12:52:17 -07:00
Allen PorterandGitHub 5ffaa70bb6 Add calendar event end trigger (#70372)
* Add calendar event end trigger

* Rename start date to last_endtime

* Rename now to last_endtime
2022-04-22 21:19:35 -07:00
a2c74b9786 Add initial implementation of a calendar trigger (#68674)
* Add initial implementation of calendar trigger

This is an initial implementation of a calendar trigger, that supports
triggering on calendar start time.

See architecture proposal in:
https://github.com/home-assistant/architecture/discussions/700

* Address reviewer feedback

* Use f-strings for all tests

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Remove logging f-strings, and move to main code

* Remove mypy ignore

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Update calendar triggers to use new calendar data model

* Update tests/components/calendar/test_trigger.py

Co-authored-by: Franck Nijhof <[email protected]>

* Rewrite tests using freezegun

Rewrite tests using freezegun and improve edge case handling, and use utc consistently for all alarms.

* Update homeassistant/components/calendar/trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/calendar/trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Increase test coverage based on pr feedback

Co-authored-by: Martin Hjelmare <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
2022-04-21 08:09:50 -07:00
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 <[email protected]>

* 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 <[email protected]>
2022-04-10 12:04:07 -07:00
Ville SkyttäandGitHub 73d192b3f3 Use HTTPStatus instead of HTTP_ consts and magic values in comp.../[bc]* (#57989) 2021-10-22 19:43:40 +02:00
276f3afb00 Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <[email protected]>
2020-05-31 22:18:30 -07:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Paulus SchoutsenandGitHub 1ddc249989 Consolidate more platforms (#22308)
* Consolidate final platforms

* Fix some tests

* Fix more tests

* Fix more tests
2019-03-23 20:22:35 -07:00