Commit Graph

17 Commits (fb00cd8963a6153ea26e71b343018284ed50c238)

Author SHA1 Message Date
Allen Porter 2f73be0e50
Ensure that calendar output values are json types (#95797) 2023-07-03 12:05:02 -07:00
epenet 60692bcfdb
Fix lingering timers in calendar tests (#90845) 2023-04-05 20:46:05 -04:00
epenet 35b642c6c8
Improve type hints in calendar trigger tests (#90827) 2023-04-05 14:08:55 +02:00
epenet 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 Porter 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
epenet 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
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet fa7acb4f0d
Add type hints to integration tests (part 3) (#87844) 2023-02-10 16:05:01 +01:00
epenet 807c69f621
Add type hints to integration tests (b-c) (#87698) 2023-02-08 18:08:43 +01:00
Erik Montnemery a6217ca9b9
Improve error message when an automation fails to validate (#83977) 2022-12-21 23:20:50 +01:00
Allen Porter 69dab4acfe
Reduce unnecessary alarm firing to speed up calendar trigger test (#80732) 2022-10-21 10:47:37 -04:00
Allen Porter d1d218444b
Improve calendar trigger test quality (#79451)
Improve calendar test quality
2022-10-21 10:56:17 +02:00
Franck Nijhof af2feb3d40
Update pyupgrade to v2.37.1 (#74989) 2022-07-11 16:54:01 +02:00
Allen Porter 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 <marhje52@gmail.com>

* Always include offset in trigger data

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-30 17:21:30 -07:00
Allen Porter 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 Porter 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
Allen Porter 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 <marhje52@gmail.com>

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

* Remove mypy ignore

* Apply suggestions from code review

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

* Update calendar triggers to use new calendar data model

* Update tests/components/calendar/test_trigger.py

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* 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 <marhje52@gmail.com>

* Update homeassistant/components/calendar/trigger.py

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

* Increase test coverage based on pr feedback

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2022-04-21 08:09:50 -07:00