Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss committed Mar 6, 2024
1 parent fa060d7 commit cec5d2f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 48 deletions.
1 change: 0 additions & 1 deletion custom_components/adaptive_cover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.event import (
async_track_entity_registry_updated_event,
async_track_state_change,
)

Expand Down
14 changes: 6 additions & 8 deletions custom_components/adaptive_cover/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any

import voluptuous as vol
from homeassistant.components.sensor import DOMAIN
from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
Expand Down Expand Up @@ -43,7 +42,6 @@
CONF_WEATHER_ENTITY,
CONF_WEATHER_STATE,
DOMAIN,
STRATEGY_MODES,
SensorType,
)

Expand Down Expand Up @@ -227,7 +225,7 @@ async def async_step_vertical(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.BLIND
if user_input is not None:
self.config.update(user_input)
if self.config[CONF_CLIMATE_MODE] == True:
if self.config[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self.async_step_update()
return self.async_show_form(step_id="vertical", data_schema=VERTICAL_OPTIONS)
Expand All @@ -237,7 +235,7 @@ async def async_step_horizontal(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.AWNING
if user_input is not None:
self.config.update(user_input)
if self.config[CONF_CLIMATE_MODE] == True:
if self.config[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self.async_step_update()
return self.async_show_form(
Expand All @@ -249,7 +247,7 @@ async def async_step_tilt(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.TILT
if user_input is not None:
self.config.update(user_input)
if self.config[CONF_CLIMATE_MODE] == True:
if self.config[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self.async_step_update()
return self.async_show_form(step_id="tilt", data_schema=TILT_OPTIONS)
Expand Down Expand Up @@ -331,7 +329,7 @@ async def async_step_vertical(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.BLIND
if user_input is not None:
self.options.update(user_input)
if self.options[CONF_CLIMATE_MODE] == True:
if self.options[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self._update_options()
return self.async_show_form(
Expand All @@ -346,7 +344,7 @@ async def async_step_horizontal(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.AWNING
if user_input is not None:
self.options.update(user_input)
if self.options[CONF_CLIMATE_MODE] == True:
if self.options[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self._update_options()
return self.async_show_form(
Expand All @@ -361,7 +359,7 @@ async def async_step_tilt(self, user_input: dict[str, Any] | None = None):
self.type_blind = SensorType.TILT
if user_input is not None:
self.options.update(user_input)
if self.options[CONF_CLIMATE_MODE] == True:
if self.options[CONF_CLIMATE_MODE] is True:
return await self.async_step_climate()
return await self._update_options()
return self.async_show_form(
Expand Down
4 changes: 1 addition & 3 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
CONF_HEIGHT_WIN,
CONF_INVERSE_STATE,
CONF_LENGTH_AWNING,
CONF_MODE,
CONF_PRESENCE_ENTITY,
CONF_SENSOR_TYPE,
CONF_SUNSET_OFFSET,
CONF_SUNSET_POS,
CONF_TEMP_ENTITY,
Expand Down Expand Up @@ -69,7 +67,7 @@ class AdaptiveDataUpdateCoordinator(DataUpdateCoordinator[AdaptiveCoverData]):

config_entry: ConfigEntry

def __init__(self, hass: HomeAssistant) -> None:
def __init__(self, hass: HomeAssistant) -> None: # noqa: D107
super().__init__(hass, LOGGER, name=DOMAIN)
self._switch_mode = True
self._cover_type = self.config_entry.data.get("sensor_type")
Expand Down
5 changes: 4 additions & 1 deletion custom_components/adaptive_cover/helpers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""Helper functions."""

from homeassistant.core import split_entity_id


def get_safe_state(hass, entity_id: str):
"""Get a safe state value if not available."""
state = hass.states.get(entity_id)
if not state or state.state in ["unknown", "unavailable"]:
return None
return state.state


def get_domain(entity: str):
"""Get domain of entity."""
if entity is not None:
domain, object_id = split_entity_id(entity)
return domain
return domain
35 changes: 1 addition & 34 deletions custom_components/adaptive_cover/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,17 @@
from homeassistant.components.sensor import SensorEntity, SensorStateClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import (
EventStateChangedData,
async_track_state_change_event,
)
from homeassistant.helpers.typing import EventType
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .calculation import (
AdaptiveHorizontalCover,
AdaptiveTiltCover,
AdaptiveVerticalCover,
ClimateCoverData,
ClimateCoverState,
NormalCoverState,
)
from .const import (
CONF_AWNING_ANGLE,
CONF_AZIMUTH,
CONF_DEFAULT_HEIGHT,
CONF_DISTANCE,
CONF_ENTITIES,
CONF_FOV_LEFT,
CONF_FOV_RIGHT,
CONF_HEIGHT_WIN,
CONF_INVERSE_STATE,
CONF_LENGTH_AWNING,
CONF_MODE,
CONF_SENSOR_TYPE,
CONF_SUNSET_OFFSET,
CONF_SUNSET_POS,
CONF_TEMP_HIGH,
CONF_TEMP_LOW,
CONF_TILT_DEPTH,
CONF_TILT_DISTANCE,
CONF_TILT_MODE,
CONF_WEATHER_STATE,
DOMAIN,
)
from .coordinator import AdaptiveDataUpdateCoordinator
from .helpers import get_domain, get_safe_state


async def async_setup_entry(
Expand Down
3 changes: 2 additions & 1 deletion custom_components/adaptive_cover/switch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Switch platform for the Adaptive Cover integration."""

from __future__ import annotations

from typing import Any

from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
Expand Down

0 comments on commit cec5d2f

Please sign in to comment.