mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Correctly support use of Farenheit in Gree Climate component (#50260)
This commit is contained in:
parent
aad90b8644
commit
bc30920824
@ -4,6 +4,10 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from greeclimate.device import (
|
from greeclimate.device import (
|
||||||
|
TEMP_MAX,
|
||||||
|
TEMP_MAX_F,
|
||||||
|
TEMP_MIN,
|
||||||
|
TEMP_MIN_F,
|
||||||
FanSpeed,
|
FanSpeed,
|
||||||
HorizontalSwing,
|
HorizontalSwing,
|
||||||
Mode,
|
Mode,
|
||||||
@ -55,8 +59,6 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
FAN_MEDIUM_HIGH,
|
FAN_MEDIUM_HIGH,
|
||||||
FAN_MEDIUM_LOW,
|
FAN_MEDIUM_LOW,
|
||||||
MAX_TEMP,
|
|
||||||
MIN_TEMP,
|
|
||||||
TARGET_TEMPERATURE_STEP,
|
TARGET_TEMPERATURE_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -184,12 +186,12 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||||||
@property
|
@property
|
||||||
def min_temp(self) -> float:
|
def min_temp(self) -> float:
|
||||||
"""Return the minimum temperature supported by the device."""
|
"""Return the minimum temperature supported by the device."""
|
||||||
return MIN_TEMP
|
return TEMP_MIN if self.temperature_unit == TEMP_CELSIUS else TEMP_MIN_F
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self) -> float:
|
def max_temp(self) -> float:
|
||||||
"""Return the maximum temperature supported by the device."""
|
"""Return the maximum temperature supported by the device."""
|
||||||
return MAX_TEMP
|
return TEMP_MAX if self.temperature_unit == TEMP_CELSIUS else TEMP_MAX_F
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self) -> float:
|
def target_temperature_step(self) -> float:
|
||||||
|
@ -16,9 +16,6 @@ COORDINATOR = "coordinator"
|
|||||||
FAN_MEDIUM_LOW = "medium low"
|
FAN_MEDIUM_LOW = "medium low"
|
||||||
FAN_MEDIUM_HIGH = "medium high"
|
FAN_MEDIUM_HIGH = "medium high"
|
||||||
|
|
||||||
MIN_TEMP = 16
|
|
||||||
MAX_TEMP = 30
|
|
||||||
|
|
||||||
MAX_ERRORS = 2
|
MAX_ERRORS = 2
|
||||||
|
|
||||||
TARGET_TEMPERATURE_STEP = 1
|
TARGET_TEMPERATURE_STEP = 1
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Gree Climate",
|
"name": "Gree Climate",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/gree",
|
"documentation": "https://www.home-assistant.io/integrations/gree",
|
||||||
"requirements": ["greeclimate==0.11.4"],
|
"requirements": ["greeclimate==0.11.7"],
|
||||||
"codeowners": ["@cmroche"],
|
"codeowners": ["@cmroche"],
|
||||||
"iot_class": "local_polling"
|
"iot_class": "local_polling"
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,7 @@ gpiozero==1.5.1
|
|||||||
gps3==0.33.3
|
gps3==0.33.3
|
||||||
|
|
||||||
# homeassistant.components.gree
|
# homeassistant.components.gree
|
||||||
greeclimate==0.11.4
|
greeclimate==0.11.7
|
||||||
|
|
||||||
# homeassistant.components.greeneye_monitor
|
# homeassistant.components.greeneye_monitor
|
||||||
greeneye_monitor==2.1
|
greeneye_monitor==2.1
|
||||||
|
@ -387,7 +387,7 @@ google-nest-sdm==0.2.12
|
|||||||
googlemaps==2.5.1
|
googlemaps==2.5.1
|
||||||
|
|
||||||
# homeassistant.components.gree
|
# homeassistant.components.gree
|
||||||
greeclimate==0.11.4
|
greeclimate==0.11.7
|
||||||
|
|
||||||
# homeassistant.components.growatt_server
|
# homeassistant.components.growatt_server
|
||||||
growattServer==1.0.1
|
growattServer==1.0.1
|
||||||
|
@ -55,6 +55,8 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -376,26 +378,42 @@ async def test_send_power_off_device_timeout(hass, discovery, device, mock_now):
|
|||||||
assert state.state == HVAC_MODE_OFF
|
assert state.state == HVAC_MODE_OFF
|
||||||
|
|
||||||
|
|
||||||
async def test_send_target_temperature(hass, discovery, device, mock_now):
|
@pytest.mark.parametrize(
|
||||||
|
"units,temperature", [(TEMP_CELSIUS, 25), (TEMP_FAHRENHEIT, 74)]
|
||||||
|
)
|
||||||
|
async def test_send_target_temperature(hass, discovery, device, units, temperature):
|
||||||
"""Test for sending target temperature command to the device."""
|
"""Test for sending target temperature command to the device."""
|
||||||
|
hass.config.units.temperature_unit = units
|
||||||
|
if units == TEMP_FAHRENHEIT:
|
||||||
|
device().temperature_units = 1
|
||||||
|
|
||||||
await async_setup_gree(hass)
|
await async_setup_gree(hass)
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_TEMPERATURE,
|
SERVICE_SET_TEMPERATURE,
|
||||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: 25.1},
|
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: temperature},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get(ENTITY_ID)
|
state = hass.states.get(ENTITY_ID)
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.attributes.get(ATTR_TEMPERATURE) == 25
|
assert state.attributes.get(ATTR_TEMPERATURE) == temperature
|
||||||
|
|
||||||
|
# Reset config temperature_unit back to CELSIUS, required for additional tests outside this component.
|
||||||
|
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"units,temperature", [(TEMP_CELSIUS, 25), (TEMP_FAHRENHEIT, 74)]
|
||||||
|
)
|
||||||
async def test_send_target_temperature_device_timeout(
|
async def test_send_target_temperature_device_timeout(
|
||||||
hass, discovery, device, mock_now
|
hass, discovery, device, units, temperature
|
||||||
):
|
):
|
||||||
"""Test for sending target temperature command to the device with a device timeout."""
|
"""Test for sending target temperature command to the device with a device timeout."""
|
||||||
|
hass.config.units.temperature_unit = units
|
||||||
|
if units == TEMP_FAHRENHEIT:
|
||||||
|
device().temperature_units = 1
|
||||||
device().push_state_update.side_effect = DeviceTimeoutError
|
device().push_state_update.side_effect = DeviceTimeoutError
|
||||||
|
|
||||||
await async_setup_gree(hass)
|
await async_setup_gree(hass)
|
||||||
@ -403,24 +421,36 @@ async def test_send_target_temperature_device_timeout(
|
|||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_TEMPERATURE,
|
SERVICE_SET_TEMPERATURE,
|
||||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: 25.1},
|
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: temperature},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get(ENTITY_ID)
|
state = hass.states.get(ENTITY_ID)
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.attributes.get(ATTR_TEMPERATURE) == 25
|
assert state.attributes.get(ATTR_TEMPERATURE) == temperature
|
||||||
|
|
||||||
|
# Reset config temperature_unit back to CELSIUS, required for additional tests outside this component.
|
||||||
|
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
async def test_update_target_temperature(hass, discovery, device, mock_now):
|
@pytest.mark.parametrize(
|
||||||
|
"units,temperature", [(TEMP_CELSIUS, 25), (TEMP_FAHRENHEIT, 74)]
|
||||||
|
)
|
||||||
|
async def test_update_target_temperature(hass, discovery, device, units, temperature):
|
||||||
"""Test for updating target temperature from the device."""
|
"""Test for updating target temperature from the device."""
|
||||||
device().target_temperature = 32
|
hass.config.units.temperature_unit = units
|
||||||
|
if units == TEMP_FAHRENHEIT:
|
||||||
|
device().temperature_units = 1
|
||||||
|
device().target_temperature = temperature
|
||||||
|
|
||||||
await async_setup_gree(hass)
|
await async_setup_gree(hass)
|
||||||
|
|
||||||
state = hass.states.get(ENTITY_ID)
|
state = hass.states.get(ENTITY_ID)
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.attributes.get(ATTR_TEMPERATURE) == 32
|
assert state.attributes.get(ATTR_TEMPERATURE) == temperature
|
||||||
|
|
||||||
|
# Reset config temperature_unit back to CELSIUS, required for additional tests outside this component.
|
||||||
|
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user