mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Blebox cover tilt (#85515)
* feature: added tilt for shutterBox * test: include tilt in tests
This commit is contained in:
@@ -7,7 +7,9 @@ import pytest
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
ATTR_CURRENT_TILT_POSITION,
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
STATE_CLOSED,
|
||||
STATE_CLOSING,
|
||||
STATE_OPEN,
|
||||
@@ -21,6 +23,7 @@ from homeassistant.const import (
|
||||
SERVICE_CLOSE_COVER,
|
||||
SERVICE_OPEN_COVER,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
SERVICE_SET_COVER_TILT_POSITION,
|
||||
SERVICE_STOP_COVER,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
@@ -43,8 +46,10 @@ def shutterbox_fixture():
|
||||
full_name="shutterBox-position",
|
||||
device_class="shutter",
|
||||
current=None,
|
||||
tilt_current=None,
|
||||
state=None,
|
||||
has_stop=True,
|
||||
has_tilt=True,
|
||||
is_slider=True,
|
||||
)
|
||||
product = feature.product
|
||||
@@ -420,3 +425,47 @@ async def test_closed_state(feature, hass: HomeAssistant) -> None:
|
||||
feature_mock.async_update = AsyncMock(side_effect=initial_update)
|
||||
await async_setup_entity(hass, entity_id)
|
||||
assert hass.states.get(entity_id).state == STATE_CLOSED
|
||||
|
||||
|
||||
async def test_tilt_position(shutterbox, hass):
|
||||
"""Test tilt capability is available."""
|
||||
|
||||
feature_mock, entity_id = shutterbox
|
||||
|
||||
def tilt_update():
|
||||
feature_mock.tilt_current = 90
|
||||
|
||||
feature_mock.async_update = AsyncMock(side_effect=tilt_update)
|
||||
|
||||
await async_setup_entity(hass, entity_id)
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 10
|
||||
|
||||
|
||||
async def test_set_tilt_position(shutterbox, hass):
|
||||
"""Test tilt position setting."""
|
||||
|
||||
feature_mock, entity_id = shutterbox
|
||||
|
||||
def initial_update():
|
||||
feature_mock.state = 3
|
||||
|
||||
def set_tilt(tilt_position):
|
||||
assert tilt_position == 20
|
||||
feature_mock.state = 1
|
||||
|
||||
feature_mock.async_update = AsyncMock(side_effect=initial_update)
|
||||
feature_mock.async_set_tilt_position = AsyncMock(side_effect=set_tilt)
|
||||
|
||||
await async_setup_entity(hass, entity_id)
|
||||
assert hass.states.get(entity_id).state == STATE_CLOSED
|
||||
|
||||
feature_mock.async_update = AsyncMock()
|
||||
await hass.services.async_call(
|
||||
"cover",
|
||||
SERVICE_SET_COVER_TILT_POSITION,
|
||||
{"entity_id": entity_id, ATTR_TILT_POSITION: 80},
|
||||
blocking=True,
|
||||
)
|
||||
assert hass.states.get(entity_id).state == STATE_OPENING
|
||||
|
||||
Reference in New Issue
Block a user