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

Bump solarlog_cli to 0.2.2 #124948

Merged
merged 33 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
94a3d2a
Add inverter-devices
dontinelli Aug 5, 2024
a46ae76
Merge branch 'dev' into solarlog-inverter
dontinelli Aug 5, 2024
d3354cc
Minor code adjustments
dontinelli Aug 5, 2024
f223e78
Update manifest.json
dontinelli Aug 6, 2024
f7d5eaa
Update requirements_all.txt
dontinelli Aug 6, 2024
529cd1a
Update requirements_test_all.txt
dontinelli Aug 6, 2024
f7dedf4
Merge branch 'dev' into solarlog-inverter
dontinelli Aug 20, 2024
0dbb8d1
Update homeassistant/components/solarlog/sensor.py
dontinelli Aug 20, 2024
0b938b6
Split up base class, document SolarLogSensorEntityDescription
dontinelli Aug 21, 2024
472bf08
Merge branch 'dev' into solarlog-inverter
dontinelli Aug 25, 2024
178598e
Split up sensor types
dontinelli Aug 26, 2024
4feae31
Update snapshot
dontinelli Aug 26, 2024
14c92a9
Bump solarlog_cli to 0.2.1
dontinelli Aug 29, 2024
879f029
Add strict typing
dontinelli Aug 29, 2024
80cddb4
Bump fyta_cli to 0.6.3 (#124574)
dontinelli Aug 25, 2024
7905cd6
Ensure write access to hassrelease data folder (#124573)
balloob Aug 25, 2024
5e7ff02
Update a roborock blocking call to be fully async (#124266)
allenporter Aug 25, 2024
298bcc3
Add inverter-devices
dontinelli Aug 5, 2024
43a5a6e
Split up sensor types
dontinelli Aug 26, 2024
3848b02
Update snapshot
dontinelli Aug 26, 2024
24a6ad6
Bump solarlog_cli to 0.2.1
dontinelli Aug 29, 2024
9e59b05
Backport/rebase
dontinelli Aug 30, 2024
9c62c0e
Tidy up
dontinelli Aug 30, 2024
d368ad2
Simplyfication coordinator.py
dontinelli Aug 30, 2024
4c03959
Minor adjustments
dontinelli Aug 30, 2024
6e74b50
Merge branch 'dev' into solarlog-test
dontinelli Aug 30, 2024
c1ae650
Merge branch 'dev' into solarlog-test
dontinelli Aug 30, 2024
4dcfef7
Ruff
dontinelli Aug 30, 2024
e112474
Bump solarlog_cli to 0.2.2
dontinelli Aug 31, 2024
44e7828
Update homeassistant/components/solarlog/sensor.py
dontinelli Aug 31, 2024
c275847
Update homeassistant/components/solarlog/config_flow.py
dontinelli Aug 31, 2024
1c8035c
Update homeassistant/components/solarlog/sensor.py
dontinelli Aug 31, 2024
753951a
Update persentage-values in fixture
dontinelli Aug 31, 2024
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
1 change: 1 addition & 0 deletions .strict-typing
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ homeassistant.components.slack.*
homeassistant.components.sleepiq.*
homeassistant.components.smhi.*
homeassistant.components.snooz.*
homeassistant.components.solarlog.*
homeassistant.components.sonarr.*
homeassistant.components.speedtestdotnet.*
homeassistant.components.sql.*
Expand Down
23 changes: 9 additions & 14 deletions homeassistant/components/solarlog/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@callback
def solarlog_entries(hass: HomeAssistant):
def solarlog_entries(hass: HomeAssistant) -> set[str]:
"""Return the hosts already configured."""
return {
entry.data[CONF_HOST] for entry in hass.config_entries.async_entries(DOMAIN)
Expand All @@ -36,7 +36,7 @@ def __init__(self) -> None:
"""Initialize the config flow."""
self._errors: dict = {}

def _host_in_configuration_exists(self, host) -> bool:
def _host_in_configuration_exists(self, host: str) -> bool:
dontinelli marked this conversation as resolved.
Show resolved Hide resolved
"""Return True if host exists in configuration."""
if host in solarlog_entries(self.hass):
return True
Expand All @@ -50,7 +50,7 @@ def _parse_url(self, host: str) -> str:
url = ParseResult("http", netloc, path, *url[3:])
return url.geturl()

async def _test_connection(self, host):
async def _test_connection(self, host: str) -> bool:
"""Check if we can connect to the Solar-Log device."""
solarlog = SolarLogConnector(host)
try:
Expand All @@ -66,11 +66,12 @@ async def _test_connection(self, host):

return True

async def async_step_user(self, user_input=None) -> ConfigFlowResult:
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Step when user initializes a integration."""
self._errors = {}
if user_input is not None:
# set some defaults in case we need to return to the form
user_input[CONF_NAME] = slugify(user_input[CONF_NAME])
user_input[CONF_HOST] = self._parse_url(user_input[CONF_HOST])

Expand All @@ -81,20 +82,14 @@ async def async_step_user(self, user_input=None) -> ConfigFlowResult:
title=user_input[CONF_NAME], data=user_input
)
else:
user_input = {}
user_input[CONF_NAME] = DEFAULT_NAME
user_input[CONF_HOST] = DEFAULT_HOST
user_input = {CONF_NAME: DEFAULT_NAME, CONF_HOST: DEFAULT_HOST}

return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{
vol.Required(
CONF_NAME, default=user_input.get(CONF_NAME, DEFAULT_NAME)
): str,
vol.Required(
CONF_HOST, default=user_input.get(CONF_HOST, DEFAULT_HOST)
): str,
vol.Required(CONF_NAME, default=user_input[CONF_NAME]): str,
vol.Required(CONF_HOST, default=user_input[CONF_HOST]): str,
vol.Required("extended_data", default=False): bool,
}
),
Expand Down
19 changes: 10 additions & 9 deletions homeassistant/components/solarlog/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
SolarLogConnectionError,
SolarLogUpdateError,
)
from solarlog_cli.solarlog_models import SolarlogData

from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import update_coordinator
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

_LOGGER = logging.getLogger(__name__)

if TYPE_CHECKING:
from . import SolarlogConfigEntry


class SolarLogCoordinator(update_coordinator.DataUpdateCoordinator):
class SolarLogCoordinator(DataUpdateCoordinator[SolarlogData]):
"""Get and update the latest data."""

def __init__(self, hass: HomeAssistant, entry: SolarlogConfigEntry) -> None:
Expand All @@ -43,29 +44,29 @@ def __init__(self, hass: HomeAssistant, entry: SolarlogConfigEntry) -> None:
self.name = entry.title
self.host = url.geturl()

extended_data = entry.data["extended_data"]

self.solarlog = SolarLogConnector(
self.host, extended_data, hass.config.time_zone
self.host, entry.data["extended_data"], hass.config.time_zone
)

async def _async_setup(self) -> None:
"""Do initialization logic."""
if self.solarlog.extended_data:
device_list = await self.solarlog.client.get_device_list()
device_list = await self.solarlog.update_device_list()
self.solarlog.set_enabled_devices({key: True for key in device_list})

async def _async_update_data(self):
async def _async_update_data(self) -> SolarlogData:
"""Update the data from the SolarLog device."""
_LOGGER.debug("Start data update")

try:
data = await self.solarlog.update_data()
await self.solarlog.update_device_list()
if self.solarlog.extended_data:
await self.solarlog.update_device_list()
data.inverter_data = await self.solarlog.update_inverter_data()
except SolarLogConnectionError as err:
raise ConfigEntryNotReady(err) from err
except SolarLogUpdateError as err:
raise update_coordinator.UpdateFailed(err) from err
raise UpdateFailed(err) from err

_LOGGER.debug("Data successfully updated")

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/solarlog/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/solarlog",
"iot_class": "local_polling",
"loggers": ["solarlog_cli"],
"requirements": ["solarlog_cli==0.1.6"]
"requirements": ["solarlog_cli==0.2.2"]
}
Loading
Loading