mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Bugfix current temperature in gree climate (#53149)
* Bugfix current temperature gree climate * Retry build * Update from the review
This commit is contained in:
parent
f6b162bc39
commit
327208c943
@ -159,8 +159,8 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> float:
|
def current_temperature(self) -> float:
|
||||||
"""Return the target temperature, gree devices don't provide internal temp."""
|
"""Return the reported current temperature for the device."""
|
||||||
return self.target_temperature
|
return self.coordinator.device.current_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self) -> float:
|
def target_temperature(self) -> float:
|
||||||
|
@ -7,6 +7,7 @@ from greeclimate.exceptions import DeviceNotBoundError, DeviceTimeoutError
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
|
ATTR_CURRENT_TEMPERATURE,
|
||||||
ATTR_FAN_MODE,
|
ATTR_FAN_MODE,
|
||||||
ATTR_HVAC_MODE,
|
ATTR_HVAC_MODE,
|
||||||
ATTR_PRESET_MODE,
|
ATTR_PRESET_MODE,
|
||||||
@ -379,16 +380,21 @@ async def test_send_power_off_device_timeout(hass, discovery, device, mock_now):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"units,temperature", [(TEMP_CELSIUS, 25), (TEMP_FAHRENHEIT, 74)]
|
"units,temperature", [(TEMP_CELSIUS, 26), (TEMP_FAHRENHEIT, 74)]
|
||||||
)
|
)
|
||||||
async def test_send_target_temperature(hass, discovery, device, units, temperature):
|
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
|
hass.config.units.temperature_unit = units
|
||||||
|
|
||||||
|
fake_device = device()
|
||||||
if units == TEMP_FAHRENHEIT:
|
if units == TEMP_FAHRENHEIT:
|
||||||
device().temperature_units = 1
|
fake_device.temperature_units = 1
|
||||||
|
|
||||||
await async_setup_gree(hass)
|
await async_setup_gree(hass)
|
||||||
|
|
||||||
|
# Make sure we're trying to test something that isn't the default
|
||||||
|
assert fake_device.current_temperature != temperature
|
||||||
|
|
||||||
assert await hass.services.async_call(
|
assert await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_TEMPERATURE,
|
SERVICE_SET_TEMPERATURE,
|
||||||
@ -399,8 +405,13 @@ async def test_send_target_temperature(hass, discovery, device, units, temperatu
|
|||||||
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) == temperature
|
assert state.attributes.get(ATTR_TEMPERATURE) == temperature
|
||||||
|
assert (
|
||||||
|
state.attributes.get(ATTR_CURRENT_TEMPERATURE)
|
||||||
|
== fake_device.current_temperature
|
||||||
|
)
|
||||||
|
|
||||||
# Reset config temperature_unit back to CELSIUS, required for additional tests outside this component.
|
# Reset config temperature_unit back to CELSIUS, required for
|
||||||
|
# additional tests outside this component.
|
||||||
hass.config.units.temperature_unit = TEMP_CELSIUS
|
hass.config.units.temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user