From 4b463d88a84ceca267afe2c192201d7d76f511c4 Mon Sep 17 00:00:00 2001 From: Kai-Siang Wang Date: Fri, 17 May 2024 20:43:38 +0000 Subject: [PATCH] update datasets --- .gitignore | 3 +- .../components/rasc/datasets/arrival.csv | 203 ++++++++++++++++++ .../rasc/datasets/arrival_afternoon.csv | 26 +-- .../components/rasc/datasets/arrival_all.csv | 49 +++++ .../rasc/datasets/arrival_evening.csv | 42 ++-- homeassistant/components/rasc/helpers.py | 5 +- homeassistant/components/rasc/rescheduler.py | 9 +- 7 files changed, 294 insertions(+), 43 deletions(-) create mode 100644 homeassistant/components/rasc/datasets/arrival.csv create mode 100644 homeassistant/components/rasc/datasets/arrival_all.csv diff --git a/.gitignore b/.gitignore index f4e7f4768b175b..fee4c478b9807e 100644 --- a/.gitignore +++ b/.gitignore @@ -139,4 +139,5 @@ tmp_cache # results testrun*/ -results/ \ No newline at end of file +results/ +experiment_scripts/config-* \ No newline at end of file diff --git a/homeassistant/components/rasc/datasets/arrival.csv b/homeassistant/components/rasc/datasets/arrival.csv new file mode 100644 index 00000000000000..f574db8327dc6c --- /dev/null +++ b/homeassistant/components/rasc/datasets/arrival.csv @@ -0,0 +1,203 @@ +0 +0.1 +0.009999999999999995 +0.009999999999999995 +0.010000000000000009 +0.010000000000000009 +0.009999999999999981 +0.010000000000000009 +0.010000000000000009 +0.009999999999999981 +0.010000000000000009 +0.010000000000000009 +1.3800000000000001 +0.010000000000000009 +0.4099999999999999 +0.009999999999999787 +0.010000000000000231 +0.020000000000000018 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +0.2799999999999998 +0.020000000000000018 +0.010000000000000231 +0.020000000000000018 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +0.5699999999999998 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +0.009999999999999787 +0.010000000000000231 +1.33 +0.009999999999999787 +0.009999999999999787 +0.8700000000000001 +0.009999999999999787 +0.010000000000000675 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000000675 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000000675 +1.0699999999999994 +0.009999999999999787 +0.010000000000000675 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000000675 +0.009999999999999787 +0.009999999999999787 +0.41000000000000014 +0.009999999999999787 +0.1299999999999999 +0.020000000000000462 +0.08000000000000007 +1.1799999999999997 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000001563 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.9700000000000006 +0.009999999999999787 +0.019999999999999574 +0.05000000000000071 +0.009999999999999787 +0.009999999999999787 +0.7200000000000006 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000001563 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.9100000000000001 +1.0099999999999998 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000001563 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +1.120000000000001 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.4399999999999995 +0.009999999999999787 +0.010000000000001563 +0.06999999999999851 +0.010000000000001563 +0.019999999999999574 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.030000000000001137 +1.2299999999999986 +0.010000000000001563 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.009999999999999787 +0.010000000000001563 +0.8999999999999986 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.7899999999999991 +0.019999999999999574 +0.010000000000001563 +0.00999999999999801 +0.019999999999999574 +0.010000000000001563 +0.010000000000001563 +0.00999999999999801 +0.879999999999999 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +1.1000000000000014 +0.00999999999999801 +0.010000000000001563 +0.019999999999999574 +0.00999999999999801 +0.010000000000001563 +0.019999999999999574 +0.41000000000000014 +0.48999999999999844 +0.010000000000001563 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.019999999999999574 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.5 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.010000000000001563 +0.00999999999999801 +0.010000000000001563 +0.8099999999999987 +0.019999999999999574 +0.019999999999999574 +0.019999999999999574 +0.010000000000001563 +0.030000000000001137 +1.4399999999999977 +0.03999999999999915 diff --git a/homeassistant/components/rasc/datasets/arrival_afternoon.csv b/homeassistant/components/rasc/datasets/arrival_afternoon.csv index f9aa43d193b361..11285295f59371 100644 --- a/homeassistant/components/rasc/datasets/arrival_afternoon.csv +++ b/homeassistant/components/rasc/datasets/arrival_afternoon.csv @@ -1,13 +1,13 @@ -3,1706641906108,Turn on Service -7,712ec364f7bd4290ad579e0bb5e3b52e,Switch lights on at sunset -7,8fc3a937a5804719a4200bb80c1ff620,FF Corridor Light Control -8,1715667183338,Whole House Fan Control -9,1715667183342,Let There Be Dark -10,1715667183344,Door Open State to Color Light -12,1715667183345,Enhanced Auto UnLock Door -12,1715667183346,Brighten Dark Places -13,1715667183353,Car Door Opened -14,1715721247625,Close and lock all door -15,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control -15,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan -20,1715667183343,Let There Be Light \ No newline at end of file +0,1706641906108,Turn on Service +0.1,712ec364f7bd4290ad579e0bb5e3b52e,Switch lights on at sunset +0.009999999999999995,8fc3a937a5804719a4200bb80c1ff620,FF Corridor Light Control +0.009999999999999995,1715667183338,Whole House Fan Control +0.010000000000000009,1715667183342,Let There Be Dark +0.010000000000000009,1715667183344,Door Open State to Color Light +0.009999999999999981,1715667183345,Enhanced Auto UnLock Door +0.010000000000000009,1715667183346,Brighten Dark Places +0.010000000000000009,1715667183353,Car Door Opened +0.009999999999999981,1715721247625,Close and lock all door +0.010000000000000009,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control +0.010000000000000009,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan +1.3800000000000001,1715667183343,Let There Be Light \ No newline at end of file diff --git a/homeassistant/components/rasc/datasets/arrival_all.csv b/homeassistant/components/rasc/datasets/arrival_all.csv new file mode 100644 index 00000000000000..535a4be802a77e --- /dev/null +++ b/homeassistant/components/rasc/datasets/arrival_all.csv @@ -0,0 +1,49 @@ +0,653ae47ad5964ee2ad013d45168e4e6b,Switch lights off at sunrise +0.1,8fc3a937a5804719a4200bb80c1ff619,Switch on xmas tree +0.009999999999999995,bc1ac4bf0b54451882ca0b7033b7cfab,MorningAction +0.009999999999999995,1715677183344,Door Opening State to Color Light +0.010000000000000009,1715697183344,Door Closing State to Color Light +0.010000000000000009,1715667183349,Lock It When I Leave +0.009999999999999981,1715667183351,Car Departs +0.010000000000000009,1715687183344,Door Closed State to Color Light +0.010000000000000009,1715667183355,Lock it at a specific time +0.009999999999999981,1715797722148,Open garage door with S/C children +0.010000000000000009,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control +0.010000000000000009,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan +1.3800000000000001,1715667183344,Door Open State to Color Light +0.010000000000000009,1715707183344,Door Jammed State to Color Light +0.4099999999999999,1706641906108,Turn on Service +0.009999999999999787,712ec364f7bd4290ad579e0bb5e3b52e,Switch lights on at sunset +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff620,FF Corridor Light Control +0.020000000000000018,1715667183338,Whole House Fan Control +0.009999999999999787,1715667183342,Let There Be Dark +0.010000000000000231,1715667183344,Door Open State to Color Light +0.009999999999999787,1715667183345,Enhanced Auto UnLock Door +0.010000000000000231,1715667183346,Brighten Dark Places +0.2799999999999998,1715667183353,Car Door Opened +0.020000000000000018,1715721247625,Close and lock all door +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control +0.020000000000000018,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan +0.009999999999999787,1715667183343,Let There Be Light +0.010000000000000231,b438cb83bf414166bf478017f3095e9e,Switch off GF lights when to bed +0.009999999999999787,1715667183352,Garage Door Opened +0.010000000000000231,60b9cb7a9c4e4311a27cd23267a427d7,Switch off indoor lights when asleep +0.5699999999999998,daa3f20af9ba46d4a41581af68a4255d,Switch off GF lights when nobody home +0.009999999999999787,1715667183350,Car Arrives +0.010000000000000231,60fc38a590204b2da454ea90c7f8fc56,Switch off FF lights when nobody home +0.009999999999999787,67e1d02ebb094f1b8fbb8633f5364939,Switch off lights when nobody home after midnight +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff624,Lights on at sunset +0.009999999999999787,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff622,Lights on at night +0.009999999999999787,8fc3a937a5804719a4200bb80c1ff623,Lights off at night +0.010000000000000231,1715667183354,Interior Door Closed +0.009999999999999787,712ec364f7bd4290ad579e0bb5e3b52e,Lights on at sunset +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff625,Harmony off lights off +1.33,a2eb5a03211e48b98c4f49f002b6833b,SunsetAction +0.009999999999999787,1715667183344,Door Open State to Color Light +0.009999999999999787,a2eb5a03211e48b98c4f49f002b6833c,Good Night House +0.8700000000000001,1715667184345,Enhanced Auto Lock Door +0.009999999999999787,1715667183347,Garage Door Opener +0.010000000000000675,1715667183348,Let There Be Light! +0.009999999999999787,1715667183320,Unlock It When I Arrive +0.009999999999999787,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control \ No newline at end of file diff --git a/homeassistant/components/rasc/datasets/arrival_evening.csv b/homeassistant/components/rasc/datasets/arrival_evening.csv index 0a8208ebe47ba8..afe3b9038540c9 100644 --- a/homeassistant/components/rasc/datasets/arrival_evening.csv +++ b/homeassistant/components/rasc/datasets/arrival_evening.csv @@ -1,22 +1,22 @@ 0,b438cb83bf414166bf478017f3095e9e,Switch off GF lights when to bed -1,1715667183352,Garage Door Opened -2,60b9cb7a9c4e4311a27cd23267a427d7,Switch off indoor lights when asleep -2,daa3f20af9ba46d4a41581af68a4255d,Switch off GF lights when nobody home -3,1715667183350,Car Arrives -5,60fc38a590204b2da454ea90c7f8fc56,Switch off FF lights when nobody home -5,67e1d02ebb094f1b8fbb8633f5364939,Switch off lights when nobody home after midnight -6,8fc3a937a5804719a4200bb80c1ff624,Lights on at sunset -7,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan -7,8fc3a937a5804719a4200bb80c1ff622,Lights on at night -8,8fc3a937a5804719a4200bb80c1ff623,Lights off at night -9,1715667183354,Interior Door Closed -10,712ec364f7bd4290ad579e0bb5e3b52e,Lights on at sunset -15,8fc3a937a5804719a4200bb80c1ff625,Harmony off lights off -15,a2eb5a03211e48b98c4f49f002b6833b,SunsetAction -16,1715667183344,Door Open State to Color Light -18,a2eb5a03211e48b98c4f49f002b6833c,Good Night House -20,1715667184345,Enhanced Auto Lock Door -22,1715667183347,Garage Door Opener -25,1715667183348,Let There Be Light! -25,1715667183320,Unlock It When I Arrive -30,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control \ No newline at end of file +0.1,1715667183352,Garage Door Opened +0.009999999999999995,60b9cb7a9c4e4311a27cd23267a427d7,Switch off indoor lights when asleep +0.009999999999999995,daa3f20af9ba46d4a41581af68a4255d,Switch off GF lights when nobody home +0.010000000000000009,1715667183350,Car Arrives +0.010000000000000009,60fc38a590204b2da454ea90c7f8fc56,Switch off FF lights when nobody home +0.009999999999999981,67e1d02ebb094f1b8fbb8633f5364939,Switch off lights when nobody home after midnight +0.010000000000000009,8fc3a937a5804719a4200bb80c1ff624,Lights on at sunset +0.010000000000000009,a2eb5a03211e48b98c4f49f002b6833d,Whole House Fan +0.009999999999999981,8fc3a937a5804719a4200bb80c1ff622,Lights on at night +0.0100000000000000098,8fc3a937a5804719a4200bb80c1ff623,Lights off at night +0.010000000000000009,1715667183354,Interior Door Closed +1.3800000000000001,712ec364f7bd4290ad579e0bb5e3b52e,Lights on at sunset +0.010000000000000009,8fc3a937a5804719a4200bb80c1ff625,Harmony off lights off +0.4099999999999999,a2eb5a03211e48b98c4f49f002b6833b,SunsetAction +0.009999999999999787,1715667183344,Door Open State to Color Light +0.010000000000000231,a2eb5a03211e48b98c4f49f002b6833c,Good Night House +0.020000000000000018,1715667184345,Enhanced Auto Lock Door +0.009999999999999787,1715667183347,Garage Door Opener +0.010000000000000231,1715667183348,Let There Be Light! +0.009999999999999787,1715667183320,Unlock It When I Arrive +0.010000000000000231,8fc3a937a5804719a4200bb80c1ff621,CR Bed Light Control \ No newline at end of file diff --git a/homeassistant/components/rasc/helpers.py b/homeassistant/components/rasc/helpers.py index a0a40811ec2cb0..00801575a7ecd1 100644 --- a/homeassistant/components/rasc/helpers.py +++ b/homeassistant/components/rasc/helpers.py @@ -47,11 +47,10 @@ def __init__(self, hass: HomeAssistant, config: dict[str, Any]) -> None: self._hass.bus.async_listen("reschedule_event", self._handle_reschedule_event) def _handle_reschedule_event(self, event: Event): - if "diff" in event.data: - self._reschedule_diffs.append(event.data["diff"]) - return start_time = event.data["from"] - self._start_time end_time = event.data["to"] - self._start_time + diff = event.data["diff"] + self._reschedule_diffs.append(diff) self._reschedule_intervals.append((start_time, end_time)) def start(self) -> None: diff --git a/homeassistant/components/rasc/rescheduler.py b/homeassistant/components/rasc/rescheduler.py index 1123e12fe8d6d2..6c899f002c9a4d 100644 --- a/homeassistant/components/rasc/rescheduler.py +++ b/homeassistant/components/rasc/rescheduler.py @@ -6,7 +6,7 @@ import heapq from itertools import product import logging -import time +import time as t from typing import Optional from homeassistant.const import ( @@ -2388,7 +2388,7 @@ async def _reschedule( self, entity_id: str, action_id: str, diff: timedelta ) -> None: """Reschedule the entities based on the rescheduling policy.""" - start_time = time.time() + start_time = t.time() # Save the old schedule old_lt = self._scheduler.lineage_table.duplicate old_so = self._scheduler.duplicate_serialization_order @@ -2548,9 +2548,9 @@ async def _reschedule( serialization_order=new_so, ) self._apply_schedule(new_lt, new_so) - end_time = time.time() + end_time = t.time() self._hass.bus.async_fire( - "reschedule_event", {"from": start_time, "to": end_time} + "reschedule_event", {"from": start_time, "to": end_time, "diff": diff} ) def _apply_schedule( @@ -2679,7 +2679,6 @@ def _action_length_diff(self, event: Event) -> timedelta: async def _handle_undertime(self, event: Event) -> None: diff = self._action_length_diff(event) - self._hass.bus.async_fire("reschedule_event", {"diff": diff.total_seconds()}) entity_id: Optional[str] = event.data.get(ATTR_ENTITY_ID) action_id: Optional[str] = event.data.get(ATTR_ACTION_ID) if not entity_id or not action_id: