mirror of
https://github.com/home-assistant/core.git
synced 2026-10-07 06:50:41 -04:00
Use the energy site timezone in the Teslemetry tariff calendar (#183456)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Calendar platform for Teslemetry integration."""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
from typing import Any, override
|
||||
|
||||
from homeassistant.components.calendar import CalendarEntity, CalendarEvent
|
||||
@@ -111,6 +111,8 @@ def _build_event(
|
||||
class TeslemetryTariffSchedule(TeslemetryEnergyInfoEntity, CalendarEntity):
|
||||
"""Energy Site Tariff Schedule Calendar."""
|
||||
|
||||
_time_zone: tzinfo
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
data: Any,
|
||||
@@ -122,11 +124,20 @@ class TeslemetryTariffSchedule(TeslemetryEnergyInfoEntity, CalendarEntity):
|
||||
self.charges: dict[str, dict[str, Any]] = {}
|
||||
super().__init__(data, key_base)
|
||||
|
||||
@override
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Resolve the site timezone the tariff is defined in."""
|
||||
name = self.coordinator.data.get("installation_time_zone")
|
||||
self._time_zone = (
|
||||
name and await dt_util.async_get_time_zone(name)
|
||||
) or dt_util.get_default_time_zone()
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@property
|
||||
@override
|
||||
def event(self) -> CalendarEvent | None:
|
||||
"""Return the current active tariff event."""
|
||||
now = dt_util.now()
|
||||
now = dt_util.now(self._time_zone)
|
||||
current_season_name = self._get_current_season(now)
|
||||
|
||||
if not current_season_name or not self.seasons.get(current_season_name):
|
||||
@@ -173,12 +184,14 @@ class TeslemetryTariffSchedule(TeslemetryEnergyInfoEntity, CalendarEntity):
|
||||
"""Return calendar events (tariff periods) within a datetime range."""
|
||||
events: list[CalendarEvent] = []
|
||||
|
||||
start_date = dt_util.as_local(start_date)
|
||||
end_date = dt_util.as_local(end_date)
|
||||
start_date = start_date.astimezone(self._time_zone)
|
||||
end_date = end_date.astimezone(self._time_zone)
|
||||
|
||||
# Start one day earlier to catch TOU periods that cross midnight
|
||||
# from the previous evening into the query range.
|
||||
current_day = dt_util.start_of_local_day(start_date) - timedelta(days=1)
|
||||
current_day = start_date.replace(
|
||||
hour=0, minute=0, second=0, microsecond=0
|
||||
) - timedelta(days=1)
|
||||
while current_day < end_date:
|
||||
season_name = self._get_current_season(current_day)
|
||||
if not season_name or not self.seasons.get(season_name):
|
||||
@@ -215,7 +228,7 @@ class TeslemetryTariffSchedule(TeslemetryEnergyInfoEntity, CalendarEntity):
|
||||
|
||||
def _get_current_season(self, date_to_check: datetime) -> str | None:
|
||||
"""Determine the active season for a given date."""
|
||||
local_date = dt_util.as_local(date_to_check)
|
||||
local_date = date_to_check.astimezone(self._time_zone)
|
||||
year = local_date.year
|
||||
|
||||
for season_name, season_data in self.seasons.items():
|
||||
|
||||
@@ -45,11 +45,11 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2023-12-31 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Buy tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.20/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 03:00:00',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'calendar.energy_site_buy_tariff',
|
||||
@@ -105,11 +105,11 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2023-12-31 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Sell tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.08/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 03:00:00',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'calendar.energy_site_sell_tariff',
|
||||
@@ -127,35 +127,25 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2023-12-31 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Buy tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.20/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 03:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple0-calendar.energy_site_buy_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_buy_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -164,8 +154,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -174,8 +164,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -184,8 +174,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -194,8 +184,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -204,8 +194,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -214,8 +204,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -224,8 +214,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -234,8 +224,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -244,8 +234,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -254,8 +244,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
]),
|
||||
@@ -270,35 +280,25 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2023-12-31 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Sell tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.08/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 03:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple0-calendar.energy_site_sell_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_sell_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -307,8 +307,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -317,8 +317,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -327,8 +327,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -337,8 +337,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -347,8 +347,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -357,8 +357,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -367,8 +367,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -377,8 +377,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -387,8 +387,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -397,8 +397,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
]),
|
||||
@@ -413,35 +433,25 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 21:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 03:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Buy tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'On peak: 0.22/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 22:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple1-calendar.energy_site_buy_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_buy_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -450,8 +460,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -460,8 +470,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -470,8 +480,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -480,8 +490,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -490,8 +500,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -500,8 +510,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -510,8 +520,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -520,8 +530,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -530,8 +540,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -540,8 +550,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
]),
|
||||
@@ -556,35 +586,25 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 21:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 03:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Sell tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'On peak: 0.16/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 16:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2023-12-31 22:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple1-calendar.energy_site_sell_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_sell_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -593,8 +613,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -603,8 +623,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -613,8 +633,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -623,8 +643,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -633,8 +653,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -643,8 +663,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -653,8 +673,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -663,8 +683,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -673,8 +693,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -683,8 +703,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
]),
|
||||
@@ -699,35 +739,25 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-02 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Buy tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.20/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 03:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple2-calendar.energy_site_buy_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_buy_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -736,8 +766,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -746,8 +776,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -756,8 +786,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -766,8 +796,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -776,8 +806,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -786,8 +816,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -796,8 +826,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -806,8 +836,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -816,8 +846,8 @@
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -826,8 +856,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.22/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.22/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.20/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.20/kWh',
|
||||
}),
|
||||
]),
|
||||
@@ -842,35 +892,25 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-02 16:00:00',
|
||||
<CalendarEntityStateAttribute.END_TIME: 'end_time'>: '2024-01-01 22:00:00',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Energy Site Sell tariff',
|
||||
<CalendarEntityStateAttribute.LOCATION: 'location'>: '',
|
||||
<CalendarEntityStateAttribute.MESSAGE: 'message'>: 'Off peak: 0.08/kWh',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 21:00:00',
|
||||
<CalendarEntityStateAttribute.START_TIME: 'start_time'>: '2024-01-01 03:00:00',
|
||||
})
|
||||
# ---
|
||||
# name: test_calendar_events[time_tuple2-calendar.energy_site_sell_tariff][events]
|
||||
dict({
|
||||
'calendar.energy_site_sell_tariff': dict({
|
||||
'events': list([
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2023-12-31T21:00:00-08:00',
|
||||
'start': '2023-12-31T16:00:00-08:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-01T16:00:00-08:00',
|
||||
'start': '2023-12-31T21:00:00-08:00',
|
||||
'end': '2024-01-01T16:00:00+10:00',
|
||||
'start': '2023-12-31T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -879,8 +919,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-01T21:00:00-08:00',
|
||||
'start': '2024-01-01T16:00:00-08:00',
|
||||
'end': '2024-01-01T21:00:00+10:00',
|
||||
'start': '2024-01-01T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -889,8 +929,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-02T16:00:00-08:00',
|
||||
'start': '2024-01-01T21:00:00-08:00',
|
||||
'end': '2024-01-02T16:00:00+10:00',
|
||||
'start': '2024-01-01T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -899,8 +939,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-02T21:00:00-08:00',
|
||||
'start': '2024-01-02T16:00:00-08:00',
|
||||
'end': '2024-01-02T21:00:00+10:00',
|
||||
'start': '2024-01-02T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -909,8 +949,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-03T16:00:00-08:00',
|
||||
'start': '2024-01-02T21:00:00-08:00',
|
||||
'end': '2024-01-03T16:00:00+10:00',
|
||||
'start': '2024-01-02T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -919,8 +959,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-03T21:00:00-08:00',
|
||||
'start': '2024-01-03T16:00:00-08:00',
|
||||
'end': '2024-01-03T21:00:00+10:00',
|
||||
'start': '2024-01-03T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -929,8 +969,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-04T16:00:00-08:00',
|
||||
'start': '2024-01-03T21:00:00-08:00',
|
||||
'end': '2024-01-04T16:00:00+10:00',
|
||||
'start': '2024-01-03T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -939,8 +979,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-04T21:00:00-08:00',
|
||||
'start': '2024-01-04T16:00:00-08:00',
|
||||
'end': '2024-01-04T21:00:00+10:00',
|
||||
'start': '2024-01-04T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -949,8 +989,8 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-05T16:00:00-08:00',
|
||||
'start': '2024-01-04T21:00:00-08:00',
|
||||
'end': '2024-01-05T16:00:00+10:00',
|
||||
'start': '2024-01-04T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -959,8 +999,8 @@
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-05T21:00:00-08:00',
|
||||
'start': '2024-01-05T16:00:00-08:00',
|
||||
'end': '2024-01-05T21:00:00+10:00',
|
||||
'start': '2024-01-05T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
@@ -969,8 +1009,28 @@
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-06T16:00:00-08:00',
|
||||
'start': '2024-01-05T21:00:00-08:00',
|
||||
'end': '2024-01-06T16:00:00+10:00',
|
||||
'start': '2024-01-05T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: On peak
|
||||
Price: 0.16/kWh
|
||||
''',
|
||||
'end': '2024-01-06T21:00:00+10:00',
|
||||
'start': '2024-01-06T16:00:00+10:00',
|
||||
'summary': 'On peak: 0.16/kWh',
|
||||
}),
|
||||
dict({
|
||||
'description': '''
|
||||
Season: Summer
|
||||
Period: Off peak
|
||||
Price: 0.08/kWh
|
||||
''',
|
||||
'end': '2024-01-07T16:00:00+10:00',
|
||||
'start': '2024-01-06T21:00:00+10:00',
|
||||
'summary': 'Off peak: 0.08/kWh',
|
||||
}),
|
||||
]),
|
||||
|
||||
@@ -31,6 +31,7 @@ from .const import SITE_INFO, SITE_INFO_MULTI_SEASON, SITE_INFO_WEEK_CROSSING
|
||||
ENTITY_BUY = "calendar.energy_site_buy_tariff"
|
||||
ENTITY_SELL = "calendar.energy_site_sell_tariff"
|
||||
ENTITY_OPERATION_MODE = "select.energy_site_operation_mode"
|
||||
SITE_TIME_ZONE = dt_util.get_time_zone("Australia/Brisbane")
|
||||
|
||||
TARIFF_V2 = SITE_INFO["response"]["tariff_content_v2"]
|
||||
SLIM_SITE_INFO = {
|
||||
@@ -141,7 +142,7 @@ async def test_calendar(
|
||||
mock_legacy: AsyncMock,
|
||||
) -> None:
|
||||
"""Tests that the calendar entity is correct."""
|
||||
tz = dt_util.get_default_time_zone()
|
||||
tz = SITE_TIME_ZONE
|
||||
freezer.move_to(datetime(2024, 1, 1, 10, 0, 0, tzinfo=tz))
|
||||
|
||||
entry = await setup_platform(hass, [Platform.CALENDAR])
|
||||
@@ -149,6 +150,27 @@ async def test_calendar(
|
||||
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_calendar_site_time_zone(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_legacy: AsyncMock,
|
||||
) -> None:
|
||||
"""Test the tariff is evaluated in the site timezone, not the Home Assistant one."""
|
||||
await hass.config.async_set_time_zone("US/Pacific")
|
||||
# 17:00 at the Australia/Brisbane site, inside ON_PEAK 16-21
|
||||
freezer.move_to("2024-01-01T07:00:00Z")
|
||||
|
||||
await setup_platform(hass, [Platform.CALENDAR])
|
||||
|
||||
state = hass.states.get(ENTITY_BUY)
|
||||
assert state
|
||||
assert state.state == "on"
|
||||
assert state.attributes["message"] == "On peak: 0.22/kWh"
|
||||
assert state.attributes["start_time"] == "2023-12-31 22:00:00"
|
||||
assert state.attributes["end_time"] == "2024-01-01 03:00:00"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"entity_id",
|
||||
[ENTITY_BUY, ENTITY_SELL],
|
||||
@@ -172,7 +194,7 @@ async def test_calendar_events(
|
||||
time_tuple: tuple,
|
||||
) -> None:
|
||||
"""Tests that the energy tariff calendar entity events are correct."""
|
||||
tz = dt_util.get_default_time_zone()
|
||||
tz = SITE_TIME_ZONE
|
||||
freezer.move_to(datetime(*time_tuple, tzinfo=tz))
|
||||
|
||||
await setup_platform(hass, [Platform.CALENDAR])
|
||||
@@ -383,7 +405,7 @@ async def test_calendar_midnight_crossing_local_start(
|
||||
mock_legacy: AsyncMock,
|
||||
) -> None:
|
||||
"""Test async_get_events includes overnight period at local midnight."""
|
||||
tz = dt_util.get_default_time_zone()
|
||||
tz = SITE_TIME_ZONE
|
||||
freezer.move_to(datetime(2024, 1, 1, 10, 0, 0, tzinfo=tz))
|
||||
|
||||
await setup_platform(hass, [Platform.CALENDAR])
|
||||
@@ -435,7 +457,7 @@ async def test_calendar_end_of_day_period(
|
||||
mock_site_info_end_of_day: AsyncMock,
|
||||
) -> None:
|
||||
"""Test a tariff period ending at the day boundary parses instead of crashing."""
|
||||
tz = dt_util.get_default_time_zone()
|
||||
tz = SITE_TIME_ZONE
|
||||
# Sunday 23:45, inside the 23:30->24:00 end-of-day period
|
||||
freezer.move_to(datetime(2024, 1, 7, 23, 45, 0, tzinfo=tz))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user