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 pyenphase to 1.23.1 #136200

Merged
merged 3 commits into from
Jan 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion homeassistant/components/enphase_envoy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"documentation": "https://www.home-assistant.io/integrations/enphase_envoy",
"iot_class": "local_polling",
"loggers": ["pyenphase"],
"requirements": ["pyenphase==1.23.0"],
"requirements": ["pyenphase==1.23.1"],
"zeroconf": [
{
"type": "_enphase-envoy._tcp.local."
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/enphase_envoy/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EnvoyRelaySelectEntityDescription(SelectEntityDescription):
class EnvoyStorageSettingsSelectEntityDescription(SelectEntityDescription):
"""Describes an Envoy storage settings select entity."""

value_fn: Callable[[EnvoyStorageSettings], str]
value_fn: Callable[[EnvoyStorageSettings], str | None]
update_fn: Callable[[Envoy, str], Awaitable[dict[str, Any]]]


Expand Down Expand Up @@ -118,7 +118,9 @@ class EnvoyStorageSettingsSelectEntityDescription(SelectEntityDescription):
key="storage_mode",
translation_key="storage_mode",
options=STORAGE_MODE_OPTIONS,
value_fn=lambda storage_settings: STORAGE_MODE_MAP[storage_settings.mode],
value_fn=lambda storage_settings: (
None if not storage_settings.mode else STORAGE_MODE_MAP[storage_settings.mode]
),
update_fn=lambda envoy, value: envoy.set_storage_mode(
REVERSE_STORAGE_MODE_MAP[value]
),
Expand Down Expand Up @@ -235,7 +237,7 @@ def __init__(
)

@property
def current_option(self) -> str:
def current_option(self) -> str | None:
"""Return the state of the select entity."""
assert self.data.tariff is not None
assert self.data.tariff.storage_settings is not None
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions tests/components/enphase_envoy/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,28 @@ async def test_select_storage_modes(
mock_envoy.set_storage_mode.assert_called_once_with(
REVERSE_STORAGE_MODE_MAP[current_state]
)


@pytest.mark.parametrize(
("mock_envoy", "use_serial"),
[
("envoy_metered_batt_relay", "enpower_654321"),
("envoy_eu_batt", "envoy_1234"),
],
indirect=["mock_envoy"],
)
async def test_select_storage_modes_if_none(
hass: HomeAssistant,
mock_envoy: AsyncMock,
config_entry: MockConfigEntry,
use_serial: str,
) -> None:
"""Test select platform entity storage mode when tariff storage_mode is none."""
mock_envoy.data.tariff.storage_settings.mode = None
with patch("homeassistant.components.enphase_envoy.PLATFORMS", [Platform.SELECT]):
await setup_integration(hass, config_entry)

test_entity = f"{Platform.SELECT}.{use_serial}_storage_mode"

assert (entity_state := hass.states.get(test_entity))
assert entity_state.state == "unknown"