File tree Expand file tree Collapse file tree 2 files changed +115
-10
lines changed
custom_components/calendar_event Expand file tree Collapse file tree 2 files changed +115
-10
lines changed Original file line number Diff line number Diff line change 66 "type" : " shell" ,
77 "command" : " scripts/develop" ,
88 "problemMatcher" : []
9+ },
10+ {
11+ "label" : " Run Tests" ,
12+ "type" : " shell" ,
13+ "command" : " uv run pytest tests/ -v" ,
14+ "group" : {
15+ "kind" : " test" ,
16+ "isDefault" : true
17+ },
18+ "problemMatcher" : [],
19+ "presentation" : {
20+ "reveal" : " always" ,
21+ "panel" : " new"
22+ }
23+ },
24+ {
25+ "label" : " Run Tests with Coverage" ,
26+ "type" : " shell" ,
27+ "command" : " uv run pytest tests/ --cov=custom_components.calendar_event --cov-report=term-missing -v" ,
28+ "group" : " test" ,
29+ "problemMatcher" : [],
30+ "presentation" : {
31+ "reveal" : " always" ,
32+ "panel" : " new"
33+ }
34+ },
35+ {
36+ "label" : " Run Mypy" ,
37+ "type" : " shell" ,
38+ "command" : " uv run mypy custom_components/calendar_event" ,
39+ "group" : " test" ,
40+ "problemMatcher" : [
41+ {
42+ "owner" : " mypy" ,
43+ "pattern" : [
44+ {
45+ "regexp" : " ^(.+?):(\\ d+):(\\ d+)?: (error|warning|note): (.+)$" ,
46+ "file" : 1 ,
47+ "line" : 2 ,
48+ "column" : 3 ,
49+ "severity" : 4 ,
50+ "message" : 5
51+ }
52+ ]
53+ }
54+ ],
55+ "presentation" : {
56+ "reveal" : " always" ,
57+ "panel" : " shared"
58+ }
59+ },
60+ {
61+ "label" : " Run Ruff Check" ,
62+ "type" : " shell" ,
63+ "command" : " uv run ruff check" ,
64+ "group" : " test" ,
65+ "problemMatcher" : [
66+ {
67+ "owner" : " ruff" ,
68+ "pattern" : [
69+ {
70+ "regexp" : " ^(.+?):(\\ d+):(\\ d+): ([A-Z]+\\ d+) (.+)$" ,
71+ "file" : 1 ,
72+ "line" : 2 ,
73+ "column" : 3 ,
74+ "code" : 4 ,
75+ "message" : 5
76+ }
77+ ]
78+ }
79+ ],
80+ "presentation" : {
81+ "reveal" : " always" ,
82+ "panel" : " shared"
83+ }
84+ },
85+ {
86+ "label" : " Run Ruff Fix" ,
87+ "type" : " shell" ,
88+ "command" : " uv run ruff check --fix" ,
89+ "group" : " test" ,
90+ "problemMatcher" : [],
91+ "presentation" : {
92+ "reveal" : " always" ,
93+ "panel" : " shared"
94+ }
95+ },
96+ {
97+ "label" : " Run All Checks (Lint Script)" ,
98+ "type" : " shell" ,
99+ "command" : " scripts/lint" ,
100+ "group" : {
101+ "kind" : " build" ,
102+ "isDefault" : true
103+ },
104+ "problemMatcher" : [],
105+ "presentation" : {
106+ "reveal" : " always" ,
107+ "panel" : " new"
108+ }
9109 }
10110 ],
11111 "configurations" : [
Original file line number Diff line number Diff line change 88from homeassistant .core import Event , HomeAssistant , callback
99from homeassistant .const import EVENT_STATE_CHANGED
1010from homeassistant .util .dt import utcnow
11+ from homeassistant .exceptions import HomeAssistantError
1112from homeassistant .helpers .event import async_track_entity_registry_updated_event
1213from homeassistant .config_entries import ConfigEntry
1314from homeassistant .helpers .entity_platform import AddConfigEntryEntitiesCallback
@@ -213,16 +214,20 @@ async def _get_event_matching_summary(self) -> dict | None:
213214 now = utcnow ()
214215 end_date_time = (now + timedelta (hours = 1 )).isoformat ()
215216
216- events = await self ._hass .services .async_call (
217- "calendar" ,
218- "get_events" ,
219- {
220- "entity_id" : self ._calendar_entity_id ,
221- "end_date_time" : end_date_time ,
222- },
223- blocking = True ,
224- return_response = True ,
225- )
217+ try :
218+ events = await self ._hass .services .async_call (
219+ "calendar" ,
220+ "get_events" ,
221+ {
222+ "entity_id" : self ._calendar_entity_id ,
223+ "end_date_time" : end_date_time ,
224+ },
225+ blocking = True ,
226+ return_response = True ,
227+ )
228+ except HomeAssistantError :
229+ # The service call can fail when the calendar is not available
230+ return None
226231
227232 if not isinstance (events , dict ):
228233 return None
You can’t perform that action at this time.
0 commit comments