mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
Improve code quality for garage door modules in homematicip_cloud (#149856)
This commit is contained in:
parent
c0bf167e10
commit
3e615fd373
@ -283,19 +283,19 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity):
|
|||||||
@property
|
@property
|
||||||
def is_closed(self) -> bool | None:
|
def is_closed(self) -> bool | None:
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
return self._device.doorState == DoorState.CLOSED
|
return self.functional_channel.doorState == DoorState.CLOSED
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
await self._device.send_door_command_async(DoorCommand.OPEN)
|
await self.functional_channel.async_send_door_command(DoorCommand.OPEN)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
await self._device.send_door_command_async(DoorCommand.CLOSE)
|
await self.functional_channel.async_send_door_command(DoorCommand.CLOSE)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
await self._device.send_door_command_async(DoorCommand.STOP)
|
await self.functional_channel.async_send_door_command(DoorCommand.STOP)
|
||||||
|
|
||||||
|
|
||||||
class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
|
class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
|
||||||
|
@ -365,14 +365,16 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
|
|
||||||
assert ha_state.state == "closed"
|
assert ha_state.state == "closed"
|
||||||
assert ha_state.attributes["current_position"] == 0
|
assert ha_state.attributes["current_position"] == 0
|
||||||
service_call_counter = len(hmip_device.mock_calls)
|
service_call_counter = len(hmip_device.functionalChannels[1].mock_calls)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.OPEN,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
assert ha_state.state == CoverState.OPEN
|
assert ha_state.state == CoverState.OPEN
|
||||||
@ -381,9 +383,11 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
assert ha_state.state == CoverState.CLOSED
|
assert ha_state.state == CoverState.CLOSED
|
||||||
@ -392,9 +396,11 @@ async def test_hmip_garage_door_tormatic(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.STOP,)
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_garage_door_hoermann(
|
async def test_hmip_garage_door_hoermann(
|
||||||
@ -414,14 +420,16 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
|
|
||||||
assert ha_state.state == "closed"
|
assert ha_state.state == "closed"
|
||||||
assert ha_state.attributes["current_position"] == 0
|
assert ha_state.attributes["current_position"] == 0
|
||||||
service_call_counter = len(hmip_device.mock_calls)
|
service_call_counter = len(hmip_device.functionalChannels[1].mock_calls)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "open_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 1
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 1
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.OPEN,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.OPEN,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.OPEN)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
assert ha_state.state == CoverState.OPEN
|
assert ha_state.state == CoverState.OPEN
|
||||||
@ -430,9 +438,11 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "close_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 3
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 2
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.CLOSE,)
|
||||||
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
await async_manipulate_test_data(hass, hmip_device, "doorState", DoorState.CLOSED)
|
||||||
ha_state = hass.states.get(entity_id)
|
ha_state = hass.states.get(entity_id)
|
||||||
assert ha_state.state == CoverState.CLOSED
|
assert ha_state.state == CoverState.CLOSED
|
||||||
@ -441,9 +451,11 @@ async def test_hmip_garage_door_hoermann(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
"cover", "stop_cover", {"entity_id": entity_id}, blocking=True
|
||||||
)
|
)
|
||||||
assert len(hmip_device.mock_calls) == service_call_counter + 5
|
assert len(hmip_device.functionalChannels[1].mock_calls) == service_call_counter + 3
|
||||||
assert hmip_device.mock_calls[-1][0] == "send_door_command_async"
|
assert (
|
||||||
assert hmip_device.mock_calls[-1][1] == (DoorCommand.STOP,)
|
hmip_device.functionalChannels[1].mock_calls[-1][0] == "async_send_door_command"
|
||||||
|
)
|
||||||
|
assert hmip_device.functionalChannels[1].mock_calls[-1][1] == (DoorCommand.STOP,)
|
||||||
|
|
||||||
|
|
||||||
async def test_hmip_cover_shutter_group(
|
async def test_hmip_cover_shutter_group(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user