Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/dot-github/workflows/pip-23.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE authored Dec 2, 2023
2 parents be8f072 + 7640291 commit eebd670
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.3.1
pre-commit==3.4.0
black==23.9.1
pre-commit==3.5.0
black==23.11.0
flake8==6.1.0
reorder-python-imports==3.12.0
reorder-python-imports==3.12.0
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/[email protected].0
uses: actions/[email protected].1

- name: Run Labeler
uses: crazy-max/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run release-drafter
uses: release-drafter/release-drafter@v5.24.0
uses: release-drafter/release-drafter@v5.25.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Pre-commit
steps:
- name: Check out the repository
uses: actions/[email protected].0
uses: actions/[email protected].1

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
Expand All @@ -44,7 +44,7 @@ jobs:
name: HACS
steps:
- name: Check out the repository
uses: "actions/[email protected].0"
uses: "actions/[email protected].1"

- name: HACS validation
uses: "hacs/[email protected]"
Expand All @@ -57,7 +57,7 @@ jobs:
name: Hassfest
steps:
- name: Check out the repository
uses: "actions/[email protected].0"
uses: "actions/[email protected].1"

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
Expand All @@ -66,7 +66,7 @@ jobs:
name: Run tests
steps:
- name: Check out code from GitHub
uses: "actions/[email protected].0"
uses: "actions/[email protected].1"
- name: Setup Python ${{ env.DEFAULT_PYTHON }}
uses: "actions/[email protected]"
with:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ It will create HA devices depending on what you have installed:
- Minumum green level number input; how much power must be sourced from green sources (local generation) to do diversion charging
- Service to start boost (provide boost amount in kWh as parameter)
- Service to start smart boost (provide boost amount in kWh and desired finished time as paramters)
- Service to stop boost

- Eddi

Expand Down
6 changes: 6 additions & 0 deletions custom_components/myenergi/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ async def start_smart_boost(self, amount: float, when: str) -> None:
await self.device.start_smart_boost(amount, when)
self.schedule_update_ha_state()

async def stop_boost(self) -> None:
_LOGGER.debug("Stop boost called")
"""Stop boost"""
await self.device.stop_boost()
self.schedule_update_ha_state()


class MyenergiHub(CoordinatorEntity):
def __init__(self, coordinator, config_entry, meta):
Expand Down
5 changes: 5 additions & 0 deletions custom_components/myenergi/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ async def async_setup_entry(hass, entry, async_add_devices):
SMART_BOOST_SCHEMA,
"start_smart_boost",
)
platform.async_register_entity_service(
"myenergi_stop_boost",
{},
"stop_boost",
)
devices.append(ZappiChargeModeSelect(coordinator, device, entry))
elif device.kind == "eddi":
platform.async_register_entity_service(
Expand Down
8 changes: 8 additions & 0 deletions custom_components/myenergi/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ myenergi_smart_boost:
required: true
selector:
time:
myenergi_stop_boost:
name: Stop boost
description: Stop boost
target:
device:
model: Zappi
entity:
domain: select
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pre-commit==3.4.0
pre-commit==3.5.0
black==23.9.1
flake8==6.1.0
reorder-python-imports==3.12.0
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,10 @@ def mock_eddi_device():
"""Return a mocked eddi object."""
with patch("pymyenergi.client.Eddi.set_priority") as device:
yield device


@pytest.fixture
def mock_zappi_stop_boost():
"""Return a mocked Zappi object."""
with patch("pymyenergi.client.Zappi.stop_boost") as stop_boost:
yield stop_boost
20 changes: 20 additions & 0 deletions tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,23 @@ async def test_eddi_boost(
await hass.async_block_till_done()
assert mock_eddi_manual_boost.call_count == 1
mock_eddi_manual_boost.assert_called_with("Heater 1", 44.0)


async def test_stop_boost(
hass: HomeAssistant, mock_zappi_stop_boost: MagicMock
) -> None:
"""Verify device information includes expected details."""

await setup_mock_myenergi_config_entry(hass)

await hass.services.async_call(
"myenergi",
"myenergi_stop_boost",
{
ATTR_ENTITY_ID: TEST_ZAPPI_SELECT_CHARGE_MODE,
},
blocking=False,
)
assert mock_zappi_stop_boost.call_count == 0
await hass.async_block_till_done()
assert mock_zappi_stop_boost.call_count == 1

0 comments on commit eebd670

Please sign in to comment.