mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
parent
c5222708ed
commit
b6cb2bfe5b
@ -2,9 +2,17 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
|
from flexit_bacnet import VENTILATION_MODE_AWAY, VENTILATION_MODE_HOME
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.components.climate import (
|
||||||
|
ATTR_PRESET_MODE,
|
||||||
|
PRESET_AWAY,
|
||||||
|
PRESET_HOME,
|
||||||
|
SERVICE_SET_PRESET_MODE,
|
||||||
|
)
|
||||||
|
from homeassistant.components.flexit_bacnet.const import PRESET_TO_VENTILATION_MODE_MAP
|
||||||
|
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
@ -12,6 +20,8 @@ from . import setup_with_selected_platforms
|
|||||||
|
|
||||||
from tests.common import MockConfigEntry, snapshot_platform
|
from tests.common import MockConfigEntry, snapshot_platform
|
||||||
|
|
||||||
|
ENTITY_ID = "climate.device_name"
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_entity(
|
async def test_climate_entity(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -24,3 +34,50 @@ async def test_climate_entity(
|
|||||||
await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE])
|
await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE])
|
||||||
|
|
||||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_set_hvac_preset_mode(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_flexit_bacnet: AsyncMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test the initial parameters."""
|
||||||
|
await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE])
|
||||||
|
|
||||||
|
# Set preset mode to away
|
||||||
|
mock_flexit_bacnet.ventilation_mode = VENTILATION_MODE_AWAY
|
||||||
|
await hass.services.async_call(
|
||||||
|
Platform.CLIMATE,
|
||||||
|
SERVICE_SET_PRESET_MODE,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: ENTITY_ID,
|
||||||
|
ATTR_PRESET_MODE: PRESET_AWAY,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
state = hass.states.get(ENTITY_ID)
|
||||||
|
assert state.attributes[ATTR_PRESET_MODE] == PRESET_AWAY
|
||||||
|
|
||||||
|
mock_flexit_bacnet.set_ventilation_mode.assert_called_once_with(
|
||||||
|
PRESET_TO_VENTILATION_MODE_MAP[PRESET_AWAY]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set preset mode to home
|
||||||
|
mock_flexit_bacnet.ventilation_mode = VENTILATION_MODE_HOME
|
||||||
|
await hass.services.async_call(
|
||||||
|
Platform.CLIMATE,
|
||||||
|
SERVICE_SET_PRESET_MODE,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: ENTITY_ID,
|
||||||
|
ATTR_PRESET_MODE: PRESET_HOME,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
state = hass.states.get(ENTITY_ID)
|
||||||
|
assert state.attributes[ATTR_PRESET_MODE] == PRESET_HOME
|
||||||
|
|
||||||
|
mock_flexit_bacnet.set_ventilation_mode.assert_called_with(
|
||||||
|
PRESET_TO_VENTILATION_MODE_MAP[PRESET_HOME]
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user