Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/ruff-0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss authored Mar 13, 2024
2 parents 9eddfa8 + ebe9351 commit f0440e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
14 changes: 9 additions & 5 deletions custom_components/adaptive_cover/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ class ClimateCoverData:
def current_temperature(self) -> float:
"""Get current temp from entity."""
if self.temp_entity is not None:
temp = get_safe_state(self.hass, self.temp_entity)
if get_domain(self.temp_entity) == "climate":
temp = self.hass.states.get(self.temp_entity).attributes[
if get_domain(self.temp_entity) != "climate":
temp = get_safe_state(self.hass, self.temp_entity)
else:
if self.hass.states.get(self.temp_entity).attributes[
"current_temperature"
]
]:
temp = self.hass.states.get(self.temp_entity).attributes[
"current_temperature"
]
return temp

@property
Expand Down Expand Up @@ -195,7 +199,7 @@ def is_sunny(self) -> bool:
if self.weather_entity is not None:
weather_state = get_safe_state(self.hass, self.weather_entity)
if self.weather_condition is not None:
return weather_state in weather_state
return weather_state in self.weather_condition
return False


Expand Down
14 changes: 7 additions & 7 deletions custom_components/adaptive_cover/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
selector.NumberSelectorConfig(min=1, max=100, step=1, mode="slider")
),
vol.Required(CONF_FOV_LEFT, default=90): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=90, step=1, mode="slider")
selector.NumberSelectorConfig(min=1, max=90, step=1, mode="slider")
),
vol.Required(CONF_FOV_RIGHT, default=90): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=90, step=1, mode="slider")
selector.NumberSelectorConfig(min=1, max=90, step=1, mode="slider")
),
vol.Required(CONF_SUNSET_POS, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=100, step=1, mode="slider")
Expand All @@ -93,7 +93,7 @@
VERTICAL_OPTIONS = vol.Schema(
{
vol.Required(CONF_HEIGHT_WIN, default=2.1): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=6, step=0.01, mode="slider")
selector.NumberSelectorConfig(min=0.1, max=6, step=0.01, mode="slider")
),
vol.Required(CONF_DISTANCE, default=0.5): selector.NumberSelector(
selector.NumberSelectorConfig(min=0.1, max=2, step=0.1, mode="slider")
Expand All @@ -110,10 +110,10 @@
HORIZONTAL_OPTIONS = vol.Schema(
{
vol.Required(CONF_HEIGHT_AWNING, default=2.1): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=6, step=0.01, mode="slider")
selector.NumberSelectorConfig(min=0.1, max=6, step=0.01, mode="slider")
),
vol.Required(CONF_LENGTH_AWNING, default=2.1): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=6, step=0.01, mode="slider")
selector.NumberSelectorConfig(min=0.3, max=6, step=0.01, mode="slider")
),
vol.Required(CONF_AWNING_ANGLE, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=45, mode="slider")
Expand All @@ -124,10 +124,10 @@
TILT_OPTIONS = vol.Schema(
{
vol.Required(CONF_TILT_DEPTH, default=3): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=15, step=0.1, mode="slider")
selector.NumberSelectorConfig(min=0.1, max=15, step=0.1, mode="slider")
),
vol.Required(CONF_TILT_DISTANCE, default=2): selector.NumberSelector(
selector.NumberSelectorConfig(min=0, max=15, step=0.1, mode="slider")
selector.NumberSelectorConfig(min=0.1, max=15, step=0.1, mode="slider")
),
vol.Required(CONF_TILT_MODE, default="mode2"): selector.SelectSelector(
selector.SelectSelectorConfig(
Expand Down
8 changes: 7 additions & 1 deletion custom_components/adaptive_cover/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -101,6 +101,12 @@ def __init__(
self._device_name = self.type[self.config_entry.data[CONF_SENSOR_TYPE]]
self._device_id = unique_id

@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
self.data = self.coordinator.data
self.async_write_ha_state()

@property
def name(self):
"""Name of the entity."""
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0440e3

Please sign in to comment.