mirror of
https://github.com/home-assistant/core.git
synced 2026-10-07 14:58:11 -04:00
Offer the Peblar Custom Solar smart charging mode (#183359)
This commit is contained in:
@@ -44,11 +44,17 @@ def _smart_charging_options(configuration: PeblarUserConfiguration) -> list[str]
|
||||
A charger without a power meter configured rejects solar charging, and
|
||||
scheduled charging can be switched off during commissioning. Offering
|
||||
those anyway lands the user on a mode the charger quietly ignores.
|
||||
|
||||
Custom solar arrived with firmware 1.10. Rather than check the version,
|
||||
take the charger at its word: it reports the settings that go with the
|
||||
mode, and leaves them out when it has never heard of it.
|
||||
"""
|
||||
solar = configuration.solar_charging_allowed
|
||||
custom = solar and configuration.solar_charging_custom_power_target is not None
|
||||
return [
|
||||
option
|
||||
for option, allowed in (
|
||||
("custom_solar", custom),
|
||||
("default", True),
|
||||
("fast_solar", solar),
|
||||
("pure_solar", solar),
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
"smart_charging": {
|
||||
"name": "Smart charging",
|
||||
"state": {
|
||||
"custom_solar": "Custom solar",
|
||||
"default": "Default",
|
||||
"fast_solar": "Fast solar",
|
||||
"pure_solar": "Pure solar",
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
"SeccOcppUri": "",
|
||||
"SessionManagerChargeWithoutAuth": false,
|
||||
"SolarChargingAllowed": true,
|
||||
"SolarChargingCustomAlwaysCharge": false,
|
||||
"SolarChargingCustomPowerTarget": 0,
|
||||
"SolarChargingCustomPowerThreshold": -1300,
|
||||
"SolarChargingEnable": true,
|
||||
"SolarChargingMode": "PureSolar",
|
||||
"SolarChargingSource": "homewizard",
|
||||
|
||||
@@ -138,6 +138,9 @@
|
||||
'SeccOcppUri': '',
|
||||
'SessionManagerChargeWithoutAuth': False,
|
||||
'SolarChargingAllowed': True,
|
||||
'SolarChargingCustomAlwaysCharge': False,
|
||||
'SolarChargingCustomPowerTarget': 0,
|
||||
'SolarChargingCustomPowerThreshold': -1300,
|
||||
'SolarChargingEnable': True,
|
||||
'SolarChargingMode': 'PureSolar',
|
||||
'SolarChargingSource': 'homewizard',
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
<SelectEntityCapabilityAttribute.OPTIONS: 'options'>: list([
|
||||
'custom_solar',
|
||||
'default',
|
||||
'fast_solar',
|
||||
'pure_solar',
|
||||
@@ -179,6 +180,7 @@
|
||||
'attributes': ReadOnlyDict({
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Peblar EV Charger Smart charging',
|
||||
<SelectEntityCapabilityAttribute.OPTIONS: 'options'>: list([
|
||||
'custom_solar',
|
||||
'default',
|
||||
'fast_solar',
|
||||
'pure_solar',
|
||||
|
||||
@@ -262,14 +262,18 @@ async def test_hw_entity_absent_when_hw_flag_false(
|
||||
),
|
||||
(
|
||||
{"ScheduledChargingAllowed": False},
|
||||
["default", "fast_solar", "pure_solar", "smart_solar"],
|
||||
["custom_solar", "default", "fast_solar", "pure_solar", "smart_solar"],
|
||||
),
|
||||
(
|
||||
{"SolarChargingAllowed": False, "ScheduledChargingAllowed": False},
|
||||
["default"],
|
||||
),
|
||||
(
|
||||
{"SolarChargingCustomPowerTarget": None},
|
||||
["default", "fast_solar", "pure_solar", "scheduled", "smart_solar"],
|
||||
),
|
||||
],
|
||||
ids=["no solar", "no scheduled", "neither"],
|
||||
ids=["no solar", "no scheduled", "neither", "firmware without custom solar"],
|
||||
indirect=["mock_peblar"],
|
||||
)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
@@ -281,8 +285,30 @@ async def test_smart_charging_options_follow_the_charger(
|
||||
|
||||
A charger without a power meter rejects solar charging, and the web
|
||||
interface hides those modes. Offering them anyway lets the user pick
|
||||
something the charger quietly ignores.
|
||||
something the charger quietly ignores. The same goes for custom solar,
|
||||
which firmware older than 1.10 has never heard of.
|
||||
"""
|
||||
state = hass.states.get("select.peblar_ev_charger_smart_charging")
|
||||
assert state
|
||||
assert state.attributes[ATTR_OPTIONS] == expected_options
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_selecting_custom_solar(
|
||||
hass: HomeAssistant,
|
||||
mock_peblar: MagicMock,
|
||||
) -> None:
|
||||
"""Test the mode firmware 1.10 added reaches the charger."""
|
||||
mock_peblar.smart_charging.reset_mock()
|
||||
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
{
|
||||
ATTR_ENTITY_ID: "select.peblar_ev_charger_smart_charging",
|
||||
ATTR_OPTION: "custom_solar",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
mock_peblar.smart_charging.assert_called_once_with(SmartChargingMode.CUSTOM_SOLAR)
|
||||
|
||||
Reference in New Issue
Block a user