Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ schedule taking into account the pool water temperature.
* Splits the total target duration into two runs around the solar noon.
1/3 before ans 2/3 after to allow filtering during the hottest part of the day.
* You can add a customizable break between the two runs.
* Initializes an entity (`pool_pump.schedule`) that shows the current or next
run of the pool pump.
* Initializes the following entities:
* `pool_pump.next_run_schedule`: Pretty string of the scheduled current/next run.
* `pool_pump.next_run_start`: Starting datetime of the current/next run.
* `pool_pump.next_run_stop`: End datetime of the current/next run.
* `pool_pump.total_daily_filtering_duration`: Turn switch off.
* Optional: Support for a water level sensor to specify an entity that indicates if the
pool has reached a critical water level in which case the pool pump should
not run at all.
Expand Down
18 changes: 17 additions & 1 deletion custom_components/pool_pump/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from homeassistant.core import Config, HomeAssistant

from pypool_pump import AbacusFilteringDuration
from pypool_pump import Run


_LOGGER = logging.getLogger(__name__)
Expand All @@ -38,6 +39,8 @@
ATTR_POOL_TEMPERATURE_ENTITY_ID,
ATTR_TOTAL_DAILY_FILTERING_DURATION,
ATTR_NEXT_RUN_SCHEDULE,
ATTR_NEXT_RUN_START,
ATTR_NEXT_RUN_STOP,
ATTR_WATER_LEVEL_CRITICAL_ENTITY_ID,
ATTR_SCHEDULE_BREAK_DURATION_IN_HOURS,
DEFAULT_BREAK_DURATION_IN_HOURS,
Expand Down Expand Up @@ -114,6 +117,12 @@ async def check(call):
run = manager_tomorrow.next_run()
_LOGGER.debug("Next run: %s", run)
schedule = run.pretty_print()
hass.states.async_set(
"{}.{}".format(DOMAIN, ATTR_NEXT_RUN_START), run.start_time.strftime('%Y-%m-%d, %H:%M')
)
hass.states.async_set(
"{}.{}".format(DOMAIN, ATTR_NEXT_RUN_STOP), run.stop_time.strftime('%Y-%m-%d, %H:%M')
)
# Set time range so that this can be displayed in the UI.
hass.states.async_set(
"{}.{}".format(DOMAIN, ATTR_NEXT_RUN_SCHEDULE), schedule
Expand Down Expand Up @@ -147,7 +156,7 @@ def __init__(self, hass, now):

# TODO: check when the schedule for next day is computed
noon = dt_util.as_local(
get_astral_event_date(self._hass, "solar_noon", self._now.date())
get_astral_event_date(self._hass, "noon", self._now.date())
)
_LOGGER.debug("Solar noon is at: {}".format(noon))

Expand All @@ -156,6 +165,13 @@ def __init__(self, hass, now):
# Create runs with a pivot on solar noon
self._runs = self._pool_controler.update_schedule(noon)

# Add Run on sunrise
sunrise = dt_util.as_local(
get_astral_event_date(self._hass, "sunrise", self._now.date())
)
sunrise_run = Run(sunrise, 1)
self._runs.insert(0,sunrise_run)

def __repr__(self):
"""Return string representation of this feed."""
return "<{}(runs={})>".format(self.__class__.__name__, self._runs)
Expand Down
4 changes: 3 additions & 1 deletion custom_components/pool_pump/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NAME = "Pool Pump Manager"
DOMAIN = "pool_pump"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.2beta1"
VERSION = "0.0.3beta1"

ISSUE_URL = "https://github.com/oncleben31/ha-pool_pump/issues"
DOC_URL = "https://github.com/oncleben31/ha-pool_pump"
Expand All @@ -22,6 +22,8 @@
ATTR_POOL_TEMPERATURE_ENTITY_ID = "pool_temperature_entity_id"
ATTR_TOTAL_DAILY_FILTERING_DURATION = "total_daily_filtering_duration"
ATTR_NEXT_RUN_SCHEDULE = "next_run_schedule"
ATTR_NEXT_RUN_START = "next_run_start"
ATTR_NEXT_RUN_STOP = "next_run_stop"
ATTR_SCHEDULE_BREAK_DURATION_IN_HOURS = "schedule_break_in_hours"
DEFAULT_BREAK_DURATION_IN_HOURS = 0.0

Expand Down
1 change: 1 addition & 0 deletions custom_components/pool_pump/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"domain": "pool_pump",
"name": "Pool Pump Manager",
"version": "0.0.3",
"documentation": "https://github.com/oncleben31/ha-pool_pump",
"dependencies": [],
"config_flow": false,
Expand Down
7 changes: 5 additions & 2 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ schedule taking into account the pool water temperature.
* Splits the total target duration into two runs arround the solar noon.
1/3 before ans 2/3 after to allow filtering during the hottest part of the day.
* You can add a customisable break between the two runs.
* Initialises an entity (`pool_pump.schedule`) that shows the current or next
run of the pool pump.
* Initializes the following entities:
* `pool_pump.next_run_schedule`: Pretty string of the scheduled current/next run.
* `pool_pump.next_run_start`: Starting datetime of the current/next run.
* `pool_pump.next_run_stop`: End datetime of the current/next run.
* `pool_pump.total_daily_filtering_duration`: Turn switch off.
* Optional: Support for a water level sensor to specify an entity that indicates if the
pool has reached a critical water level in which case the pool pump should
not run at all.
Expand Down