Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for whole apsystems ez1 series #123356

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Check Max output for apsystems on startup, not setup
  • Loading branch information
mawoka-myblock committed Aug 19, 2024
commit edacf177fc476e5e6c00a4c6bb5000e19cdad93f
9 changes: 7 additions & 2 deletions homeassistant/components/apsystems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, Platform
from homeassistant.core import HomeAssistant

from .const import DEFAULT_PORT, MAX_OUTPUT
from .const import DEFAULT_PORT
from .coordinator import ApSystemsDataCoordinator

PLATFORMS: list[Platform] = [
Expand All @@ -35,7 +35,12 @@ class ApSystemsData:

async def async_setup_entry(hass: HomeAssistant, entry: ApSystemsConfigEntry) -> bool:
"""Set up this integration using UI."""
max_output = entry.data.get(MAX_OUTPUT, 800)
temp_api = APsystemsEZ1M(
ip_address=entry.data[CONF_IP_ADDRESS],
port=entry.data.get(CONF_PORT, DEFAULT_PORT),
timeout=8,
)
max_output = (await temp_api.get_device_info()).maxPower
api = APsystemsEZ1M(
ip_address=entry.data[CONF_IP_ADDRESS],
port=entry.data.get(CONF_PORT, DEFAULT_PORT),
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/apsystems/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv

from .const import DEFAULT_PORT, DOMAIN, MAX_OUTPUT
from .const import DEFAULT_PORT, DOMAIN

DATA_SCHEMA = vol.Schema(
{
Expand Down Expand Up @@ -48,7 +48,7 @@ async def async_step_user(
self._abort_if_unique_id_configured()
return self.async_create_entry(
title="Solar",
data={**user_input, MAX_OUTPUT: device_info.maxPower},
data=user_input,
)

return self.async_show_form(
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/apsystems/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
LOGGER: Logger = getLogger(__package__)
DOMAIN = "apsystems"
DEFAULT_PORT = 8050
MAX_OUTPUT = "max_output"
3 changes: 1 addition & 2 deletions tests/components/apsystems/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import AsyncMock

from homeassistant.components.apsystems.const import DOMAIN, MAX_OUTPUT
from homeassistant.components.apsystems.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
from homeassistant.core import HomeAssistant
Expand All @@ -25,7 +25,6 @@ async def test_form_create_success(
assert result["result"].unique_id == "MY_SERIAL_NUMBER"
assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result["data"].get(CONF_IP_ADDRESS) == "127.0.0.1"
assert result["data"].get(MAX_OUTPUT) == 1000


async def test_form_create_success_custom_port(
Expand Down
Loading