mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix ignored argument in service call for demo climate (#101137)
Fix service call for demo climate
This commit is contained in:
parent
7b9c1c3953
commit
542ab2dd76
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
|
ATTR_HVAC_MODE,
|
||||||
ATTR_TARGET_TEMP_HIGH,
|
ATTR_TARGET_TEMP_HIGH,
|
||||||
ATTR_TARGET_TEMP_LOW,
|
ATTR_TARGET_TEMP_LOW,
|
||||||
ClimateEntity,
|
ClimateEntity,
|
||||||
@ -258,6 +259,8 @@ class DemoClimate(ClimateEntity):
|
|||||||
):
|
):
|
||||||
self._target_temperature_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
self._target_temperature_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
||||||
self._target_temperature_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
self._target_temperature_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
||||||
|
if kwargs.get(ATTR_HVAC_MODE) is not None:
|
||||||
|
self._hvac_mode = HVACMode(str(kwargs.get(ATTR_HVAC_MODE)))
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_set_humidity(self, humidity: int) -> None:
|
async def async_set_humidity(self, humidity: int) -> None:
|
||||||
|
@ -198,6 +198,28 @@ async def test_set_target_temp_range_bad_attr(hass: HomeAssistant) -> None:
|
|||||||
assert state.attributes.get(ATTR_TARGET_TEMP_HIGH) == 24.0
|
assert state.attributes.get(ATTR_TARGET_TEMP_HIGH) == 24.0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_set_temp_with_hvac_mode(hass: HomeAssistant) -> None:
|
||||||
|
"""Test the setting of the hvac_mode in set_temperature."""
|
||||||
|
state = hass.states.get(ENTITY_CLIMATE)
|
||||||
|
assert state.attributes.get(ATTR_TEMPERATURE) == 21
|
||||||
|
assert state.state == HVACMode.COOL
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: ENTITY_CLIMATE,
|
||||||
|
ATTR_TEMPERATURE: 23,
|
||||||
|
ATTR_HVAC_MODE: HVACMode.OFF,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
state = hass.states.get(ENTITY_CLIMATE)
|
||||||
|
assert state.state == HVACMode.OFF
|
||||||
|
assert state.attributes.get(ATTR_TEMPERATURE) == 23
|
||||||
|
|
||||||
|
|
||||||
async def test_set_target_humidity_bad_attr(hass: HomeAssistant) -> None:
|
async def test_set_target_humidity_bad_attr(hass: HomeAssistant) -> None:
|
||||||
"""Test setting the target humidity without required attribute."""
|
"""Test setting the target humidity without required attribute."""
|
||||||
state = hass.states.get(ENTITY_CLIMATE)
|
state = hass.states.get(ENTITY_CLIMATE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user