mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Replace not needed guard in command_line with type check (#123722)
This commit is contained in:
parent
178cb0659a
commit
b09c6654ec
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
|
|
||||||
from homeassistant.components.cover import CoverEntity
|
from homeassistant.components.cover import CoverEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -141,10 +141,10 @@ class CommandCover(ManualTriggerEntity, CoverEntity):
|
|||||||
|
|
||||||
async def _async_query_state(self) -> str | None:
|
async def _async_query_state(self) -> str | None:
|
||||||
"""Query for the state."""
|
"""Query for the state."""
|
||||||
if self._command_state:
|
if TYPE_CHECKING:
|
||||||
LOGGER.debug("Running state value command: %s", self._command_state)
|
assert self._command_state
|
||||||
return await async_check_output_or_log(self._command_state, self._timeout)
|
LOGGER.debug("Running state value command: %s", self._command_state)
|
||||||
return None
|
return await async_check_output_or_log(self._command_state, self._timeout)
|
||||||
|
|
||||||
async def _update_entity_state(self, now: datetime | None = None) -> None:
|
async def _update_entity_state(self, now: datetime | None = None) -> None:
|
||||||
"""Update the state of the entity."""
|
"""Update the state of the entity."""
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
|
|
||||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -142,11 +142,11 @@ class CommandSwitch(ManualTriggerEntity, SwitchEntity):
|
|||||||
|
|
||||||
async def _async_query_state(self) -> str | int | None:
|
async def _async_query_state(self) -> str | int | None:
|
||||||
"""Query for state."""
|
"""Query for state."""
|
||||||
if self._command_state:
|
if TYPE_CHECKING:
|
||||||
if self._value_template:
|
assert self._command_state
|
||||||
return await self._async_query_state_value(self._command_state)
|
if self._value_template:
|
||||||
return await self._async_query_state_code(self._command_state)
|
return await self._async_query_state_value(self._command_state)
|
||||||
return None
|
return await self._async_query_state_code(self._command_state)
|
||||||
|
|
||||||
async def _update_entity_state(self, now: datetime | None = None) -> None:
|
async def _update_entity_state(self, now: datetime | None = None) -> None:
|
||||||
"""Update the state of the entity."""
|
"""Update the state of the entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user