mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Make screenlogic state enums lowercase (#133866)
This commit is contained in:
parent
4a2ae7f6fd
commit
f2a706ecf7
@ -93,7 +93,7 @@ class ScreenLogicClimate(ScreenLogicPushEntity, ClimateEntity, RestoreEntity):
|
|||||||
)
|
)
|
||||||
self._configured_heat_modes.append(HEAT_MODE.HEATER)
|
self._configured_heat_modes.append(HEAT_MODE.HEATER)
|
||||||
self._attr_preset_modes = [
|
self._attr_preset_modes = [
|
||||||
HEAT_MODE(mode_num).title for mode_num in self._configured_heat_modes
|
HEAT_MODE(mode_num).name.lower() for mode_num in self._configured_heat_modes
|
||||||
]
|
]
|
||||||
|
|
||||||
self._attr_min_temp = self.entity_data[ATTR.MIN_SETPOINT]
|
self._attr_min_temp = self.entity_data[ATTR.MIN_SETPOINT]
|
||||||
@ -137,8 +137,8 @@ class ScreenLogicClimate(ScreenLogicPushEntity, ClimateEntity, RestoreEntity):
|
|||||||
def preset_mode(self) -> str:
|
def preset_mode(self) -> str:
|
||||||
"""Return current/last preset mode."""
|
"""Return current/last preset mode."""
|
||||||
if self.hvac_mode == HVACMode.OFF:
|
if self.hvac_mode == HVACMode.OFF:
|
||||||
return HEAT_MODE(self._last_preset).title
|
return HEAT_MODE(self._last_preset).name.lower()
|
||||||
return HEAT_MODE(self.entity_data[VALUE.HEAT_MODE][ATTR.VALUE]).title
|
return HEAT_MODE(self.entity_data[VALUE.HEAT_MODE][ATTR.VALUE]).name.lower()
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Change the setpoint of the heater."""
|
"""Change the setpoint of the heater."""
|
||||||
|
@ -189,8 +189,8 @@ SUPPORTED_INTELLICHEM_SENSORS = [
|
|||||||
data_root=(DEVICE.INTELLICHEM, GROUP.DOSE_STATUS),
|
data_root=(DEVICE.INTELLICHEM, GROUP.DOSE_STATUS),
|
||||||
key=VALUE.ORP_DOSING_STATE,
|
key=VALUE.ORP_DOSING_STATE,
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["Dosing", "Mixing", "Monitoring"],
|
options=["dosing", "mixing", "monitoring"],
|
||||||
value_mod=lambda val: DOSE_STATE(val).title,
|
value_mod=lambda val: DOSE_STATE(val).name.lower(),
|
||||||
translation_key="chem_dose_state",
|
translation_key="chem_dose_state",
|
||||||
translation_placeholders={"chem": "ORP"},
|
translation_placeholders={"chem": "ORP"},
|
||||||
),
|
),
|
||||||
@ -217,8 +217,8 @@ SUPPORTED_INTELLICHEM_SENSORS = [
|
|||||||
data_root=(DEVICE.INTELLICHEM, GROUP.DOSE_STATUS),
|
data_root=(DEVICE.INTELLICHEM, GROUP.DOSE_STATUS),
|
||||||
key=VALUE.PH_DOSING_STATE,
|
key=VALUE.PH_DOSING_STATE,
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["Dosing", "Mixing", "Monitoring"],
|
options=["dosing", "mixing", "monitoring"],
|
||||||
value_mod=lambda val: DOSE_STATE(val).title,
|
value_mod=lambda val: DOSE_STATE(val).name.lower(),
|
||||||
translation_key="chem_dose_state",
|
translation_key="chem_dose_state",
|
||||||
translation_placeholders={"chem": "pH"},
|
translation_placeholders={"chem": "pH"},
|
||||||
),
|
),
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
"service_config_entry_name": "Config entry",
|
"service_config_entry_name": "Config entry",
|
||||||
"service_config_entry_description": "The config entry to use for this action.",
|
"service_config_entry_description": "The config entry to use for this action.",
|
||||||
"climate_preset_solar": "Solar",
|
"climate_preset_solar": "Solar",
|
||||||
"climate_preset_solar_prefered": "Solar Prefered",
|
"climate_preset_solar_preferred": "Solar Preferred",
|
||||||
"climate_preset_heater": "Heater"
|
"climate_preset_heater": "Heater",
|
||||||
|
"climate_preset_dont_change": "Don't Change"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"flow_title": "{name}",
|
"flow_title": "{name}",
|
||||||
@ -133,10 +134,30 @@
|
|||||||
},
|
},
|
||||||
"climate": {
|
"climate": {
|
||||||
"body_0": {
|
"body_0": {
|
||||||
"name": "Pool heat"
|
"name": "Pool heat",
|
||||||
|
"state_attributes": {
|
||||||
|
"preset_mode": {
|
||||||
|
"state": {
|
||||||
|
"solar": "[%key:component::screenlogic::common::climate_preset_solar%]",
|
||||||
|
"solar_preferred": "[%key:component::screenlogic::common::climate_preset_solar_preferred%]",
|
||||||
|
"heater": "[%key:component::screenlogic::common::climate_preset_heater%]",
|
||||||
|
"dont_change": "[%key:component::screenlogic::common::climate_preset_dont_change%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"body_1": {
|
"body_1": {
|
||||||
"name": "Spa heat"
|
"name": "Spa heat",
|
||||||
|
"state_attributes": {
|
||||||
|
"preset_mode": {
|
||||||
|
"state": {
|
||||||
|
"solar": "[%key:component::screenlogic::common::climate_preset_solar%]",
|
||||||
|
"solar_preferred": "[%key:component::screenlogic::common::climate_preset_solar_preferred%]",
|
||||||
|
"heater": "[%key:component::screenlogic::common::climate_preset_heater%]",
|
||||||
|
"dont_change": "[%key:component::screenlogic::common::climate_preset_dont_change%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"number": {
|
"number": {
|
||||||
@ -191,7 +212,12 @@
|
|||||||
"name": "[%key:component::screenlogic::entity::number::salt_tds_ppm::name%]"
|
"name": "[%key:component::screenlogic::entity::number::salt_tds_ppm::name%]"
|
||||||
},
|
},
|
||||||
"chem_dose_state": {
|
"chem_dose_state": {
|
||||||
"name": "{chem} dosing state"
|
"name": "{chem} dosing state",
|
||||||
|
"state": {
|
||||||
|
"dosing": "Dosing",
|
||||||
|
"mixing": "Mixing",
|
||||||
|
"monitoring": "Monitoring"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"chem_last_dose_time": {
|
"chem_last_dose_time": {
|
||||||
"name": "{chem} last dose time"
|
"name": "{chem} last dose time"
|
||||||
|
@ -619,7 +619,7 @@
|
|||||||
},
|
},
|
||||||
"heat_mode": {
|
"heat_mode": {
|
||||||
"name": "Spa Heat Mode",
|
"name": "Spa Heat Mode",
|
||||||
"value": 0,
|
"value": 3,
|
||||||
"device_type": "enum",
|
"device_type": "enum",
|
||||||
"enum_options": [
|
"enum_options": [
|
||||||
"Off",
|
"Off",
|
||||||
|
103
tests/components/screenlogic/test_climate.py
Normal file
103
tests/components/screenlogic/test_climate.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
"""Tests for ScreenLogic climate entity."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from unittest.mock import DEFAULT, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from screenlogicpy import ScreenLogicGateway
|
||||||
|
from screenlogicpy.device_const.heat import HEAT_MODE
|
||||||
|
|
||||||
|
from homeassistant.components.climate import (
|
||||||
|
ATTR_CURRENT_TEMPERATURE,
|
||||||
|
ATTR_HVAC_ACTION,
|
||||||
|
ATTR_HVAC_MODES,
|
||||||
|
ATTR_PRESET_MODE,
|
||||||
|
ATTR_PRESET_MODES,
|
||||||
|
ATTR_TEMPERATURE,
|
||||||
|
DOMAIN as CLIMATE_DOMAIN,
|
||||||
|
HVACAction,
|
||||||
|
HVACMode,
|
||||||
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
DATA_MISSING_VALUES_CHEM_CHLOR,
|
||||||
|
GATEWAY_DISCOVERY_IMPORT_PATH,
|
||||||
|
MOCK_ADAPTER_NAME,
|
||||||
|
stub_async_connect,
|
||||||
|
)
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
(
|
||||||
|
"tested_dataset",
|
||||||
|
"expected_entity_states",
|
||||||
|
),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
DATA_MISSING_VALUES_CHEM_CHLOR,
|
||||||
|
{
|
||||||
|
f"{CLIMATE_DOMAIN}.{slugify(MOCK_ADAPTER_NAME)}_pool_heat": {
|
||||||
|
"state": HVACMode.OFF,
|
||||||
|
"attributes": {
|
||||||
|
ATTR_CURRENT_TEMPERATURE: 27.2,
|
||||||
|
ATTR_TEMPERATURE: 28.3,
|
||||||
|
ATTR_HVAC_ACTION: HVACAction.OFF,
|
||||||
|
ATTR_HVAC_MODES: [HVACMode.OFF, HVACMode.HEAT],
|
||||||
|
ATTR_PRESET_MODE: "heater",
|
||||||
|
ATTR_PRESET_MODES: [HEAT_MODE.HEATER.name.lower()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
f"{CLIMATE_DOMAIN}.{slugify(MOCK_ADAPTER_NAME)}_spa_heat": {
|
||||||
|
"state": HVACMode.HEAT,
|
||||||
|
"attributes": {
|
||||||
|
ATTR_CURRENT_TEMPERATURE: 28.9,
|
||||||
|
ATTR_TEMPERATURE: 34.4,
|
||||||
|
ATTR_HVAC_ACTION: HVACAction.IDLE,
|
||||||
|
ATTR_HVAC_MODES: [HVACMode.OFF, HVACMode.HEAT],
|
||||||
|
ATTR_PRESET_MODE: "heater",
|
||||||
|
ATTR_PRESET_MODES: [HEAT_MODE.HEATER.name.lower()],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def test_climate_state(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
tested_dataset: dict,
|
||||||
|
expected_entity_states: dict,
|
||||||
|
) -> None:
|
||||||
|
"""Test setup for platforms that define expected data."""
|
||||||
|
|
||||||
|
def stub_connect(*args, **kwargs):
|
||||||
|
return stub_async_connect(tested_dataset, *args, **kwargs)
|
||||||
|
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch(
|
||||||
|
GATEWAY_DISCOVERY_IMPORT_PATH,
|
||||||
|
return_value={},
|
||||||
|
),
|
||||||
|
patch.multiple(
|
||||||
|
ScreenLogicGateway,
|
||||||
|
async_connect=stub_connect,
|
||||||
|
is_connected=True,
|
||||||
|
_async_connected_request=DEFAULT,
|
||||||
|
),
|
||||||
|
):
|
||||||
|
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
for entity_id, state_data in expected_entity_states.items():
|
||||||
|
assert (climate_state := hass.states.get(entity_id)) is not None
|
||||||
|
assert climate_state.state == state_data["state"]
|
||||||
|
for attribute, value in state_data["attributes"].items():
|
||||||
|
assert climate_state.attributes[attribute] == value
|
Loading…
x
Reference in New Issue
Block a user