Skip to content

Commit

Permalink
Disable charge switch (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmarlor authored Oct 31, 2022
2 parents 0c64c9f + b177667 commit 012253c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions custom_components/foxess_em/battery/battery_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
self._last_update = None
self._boost = False
self._full = False
self._disable = False

# Refresh on SoC change
battery_refresh = async_track_state_change(
Expand Down Expand Up @@ -184,3 +185,11 @@ def set_full(self, status: bool) -> None:
def full_status(self) -> bool:
"""Full status"""
return self._full

def set_disable(self, status: bool) -> None:
"""Set disable on/off"""
self._disable = status

def disable_status(self) -> bool:
"""Disable status"""
return self._disable
4 changes: 4 additions & 0 deletions custom_components/foxess_em/charge/charge_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def __init__(

async def _eco_start_setup(self, *args) -> None: # pylint: disable=unused-argument
"""Set target SoC"""
if self._battery_controller.disable_status() is True:
_LOGGER.info("Skipping setup of charging schedule due to disabled status")
return

_LOGGER.debug("Calculating optimal battery SoC")

await self._forecast_controller.async_refresh()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/foxess_em/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
SOLCAST_API_SITE = "site"
SOLCAST_API_KEY = "key"
SOLCAST_SCAN_INTERVAL = "scan_interval"
# SOLCAST_URL = "https://8b382699-2afc-4114-befe-d26e2e0381a2.mock.pstmn.io"
# SOLCAST_URL = "https://19a8e676-7094-43d3-a2d3-e1e7304f9eda.mock.pstmn.io"
SOLCAST_URL = "https://api.solcast.com.au"
FOX_USERNAME = "fox_username"
FOX_PASSWORD = "fox_password"
Expand Down
7 changes: 7 additions & 0 deletions custom_components/foxess_em/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
is_on="full_status",
switch="set_full",
),
"disable": SwitchDescription(
key="disable",
name="Disable Auto Charge",
icon="mdi:sync-off",
is_on="disable_status",
switch="set_disable",
),
}


Expand Down

0 comments on commit 012253c

Please sign in to comment.