@@ -166,6 +166,14 @@ async def test_parse_date_time_day_names(hass, caplog):
166166 ("not range(20:00, 10:00)" , dt (2019 , 9 , 3 , 19 , 59 , 59 , 999999 ), True ),
167167 ("not range(20:00, 10:00)" , dt (2019 , 9 , 3 , 12 , 0 , 0 , 0 ), True ),
168168 ("not range(20:00, 10:00)" , dt (2019 , 9 , 3 , 0 , 0 , 0 , 0 ), False ),
169+ ("range(sunrise, sunset)" , dt (2019 , 9 , 1 , 6 , 37 , 14 , 0 ), False ),
170+ ("range(sunrise, sunset)" , dt (2019 , 9 , 1 , 6 , 37 , 16 , 0 ), True ),
171+ ("range(sunrise, sunset - 20m)" , dt (2019 , 9 , 1 , 19 , 19 , 14 , 0 ), True ),
172+ ("range(sunrise, sunset - 20m)" , dt (2019 , 9 , 1 , 19 , 19 , 16 , 0 ), False ),
173+ ("range(sunrise + 20m, sunset)" , dt (2019 , 9 , 2 , 6 , 58 , 5 , 0 ), False ),
174+ ("range(sunrise + 20m, sunset)" , dt (2019 , 9 , 2 , 6 , 58 , 7 , 0 ), True ),
175+ ("range(sunrise, sunset + 1m)" , dt (2019 , 11 , 4 , 17 , 7 , 55 , 0 ), True ),
176+ ("range(sunrise, sunset + 1m)" , dt (2019 , 11 , 4 , 17 , 7 , 57 , 0 ), False ),
169177 ("cron(* * * * *)" , dt (2019 , 9 , 3 , 6 , 0 , 0 , 0 ), True ),
170178 ("cron(* * * 9 *)" , dt (2019 , 9 , 3 , 6 , 0 , 0 , 0 ), True ),
171179 ("cron(* * 3 9 *)" , dt (2019 , 9 , 3 , 6 , 0 , 0 , 0 ), True ),
@@ -180,6 +188,15 @@ async def test_parse_date_time_day_names(hass, caplog):
180188def test_timer_active_check (hass , spec , now , expected ):
181189 """Run time active check tests."""
182190
191+ #
192+ # Hardcode a location and timezone so we can check sunrise
193+ # and sunset.
194+ #
195+ hass .config .latitude = 38
196+ hass .config .longitude = - 122
197+ hass .config .elevation = 0
198+ hass .config .time_zone = "America/Los_Angeles"
199+
183200 startup_time = dt (2019 , 9 , 1 , 13 , 0 , 0 , 0 )
184201 Function .init (hass )
185202 TrigTime .init (hass )
0 commit comments