From 327208c943249eecdf69e3091230b9bb30e86d95 Mon Sep 17 00:00:00 2001 From: Clifford Roche Date: Mon, 19 Jul 2021 11:07:15 -0400 Subject: [PATCH] Bugfix current temperature in gree climate (#53149) * Bugfix current temperature gree climate * Retry build * Update from the review --- homeassistant/components/gree/climate.py | 4 ++-- tests/components/gree/test_climate.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/gree/climate.py b/homeassistant/components/gree/climate.py index acd57ef590d..73ea66e5895 100644 --- a/homeassistant/components/gree/climate.py +++ b/homeassistant/components/gree/climate.py @@ -159,8 +159,8 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity): @property def current_temperature(self) -> float: - """Return the target temperature, gree devices don't provide internal temp.""" - return self.target_temperature + """Return the reported current temperature for the device.""" + return self.coordinator.device.current_temperature @property def target_temperature(self) -> float: diff --git a/tests/components/gree/test_climate.py b/tests/components/gree/test_climate.py index c062cfc5615..d88f6a6fbf0 100644 --- a/tests/components/gree/test_climate.py +++ b/tests/components/gree/test_climate.py @@ -7,6 +7,7 @@ from greeclimate.exceptions import DeviceNotBoundError, DeviceTimeoutError import pytest from homeassistant.components.climate.const import ( + ATTR_CURRENT_TEMPERATURE, ATTR_FAN_MODE, ATTR_HVAC_MODE, ATTR_PRESET_MODE, @@ -379,16 +380,21 @@ async def test_send_power_off_device_timeout(hass, discovery, device, mock_now): @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): """Test for sending target temperature command to the device.""" hass.config.units.temperature_unit = units + + fake_device = device() if units == TEMP_FAHRENHEIT: - device().temperature_units = 1 + fake_device.temperature_units = 1 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( DOMAIN, SERVICE_SET_TEMPERATURE, @@ -399,8 +405,13 @@ async def test_send_target_temperature(hass, discovery, device, units, temperatu state = hass.states.get(ENTITY_ID) assert state is not None 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