Increase tplink climate precision (#127996)

This commit is contained in:
Teemu R. 2024-10-11 13:15:30 +02:00 committed by GitHub
parent 7341337b5f
commit 1eea5b8a58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View file

@ -15,7 +15,7 @@ from homeassistant.components.climate import (
HVACAction,
HVACMode,
)
from homeassistant.const import PRECISION_WHOLE
from homeassistant.const import PRECISION_TENTHS
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -64,7 +64,7 @@ class TPLinkClimateEntity(CoordinatedTPLinkEntity, ClimateEntity):
| ClimateEntityFeature.TURN_ON
)
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
_attr_precision = PRECISION_WHOLE
_attr_precision = PRECISION_TENTHS
# This disables the warning for async_turn_{on,off}, can be removed later.
_enable_turn_on_off_backwards_compatibility = False

View file

@ -42,7 +42,7 @@
# name: test_states[climate.thermostat-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 20,
'current_temperature': 20.2,
'friendly_name': 'thermostat',
'hvac_action': <HVACAction.HEATING: 'heating'>,
'hvac_modes': list([
@ -52,7 +52,7 @@
'max_temp': 65536,
'min_temp': None,
'supported_features': <ClimateEntityFeature: 385>,
'temperature': 22,
'temperature': 22.2,
}),
'context': <ANY>,
'entity_id': 'climate.thermostat',

View file

@ -45,11 +45,11 @@ async def mocked_hub(hass: HomeAssistant) -> Device:
features = [
_mocked_feature(
"temperature", value=20, category=Feature.Category.Primary, unit="celsius"
"temperature", value=20.2, category=Feature.Category.Primary, unit="celsius"
),
_mocked_feature(
"target_temperature",
value=22,
value=22.2,
type_=Feature.Type.Number,
category=Feature.Category.Primary,
unit="celsius",
@ -94,8 +94,8 @@ async def test_climate(
state = hass.states.get(ENTITY_ID)
assert state.attributes[ATTR_HVAC_ACTION] is HVACAction.HEATING
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20
assert state.attributes[ATTR_TEMPERATURE] == 22
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20.2
assert state.attributes[ATTR_TEMPERATURE] == 22.2
async def test_states(