Skip to content

Commit

Permalink
Merge branch 'main' into async_event
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss authored Apr 28, 2024
2 parents 524a56a + 8cd96ad commit 9e4c83f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hacs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.1.2
uses: actions/checkout@v4.1.3

- name: 🚀 Run HACS validation
uses: hacs/action@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hassfest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.1.2"
uses: "actions/checkout@v4.1.3"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
id-token: write
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.1.2"
uses: "actions/checkout@v4.1.3"

- name: 🔢 Adjust version number
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions custom_components/adaptive_cover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.event import (
async_track_state_change_event,
async_track_state_change,
)

from .const import (
Expand Down Expand Up @@ -48,15 +48,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_entities.append(entity)

entry.async_on_unload(
async_track_state_change_event(
async_track_state_change(
hass,
_entities,
coordinator.async_check_entity_state_change,
)
)

entry.async_on_unload(
async_track_state_change_event(
async_track_state_change(
hass,
_cover_entities,
coordinator.async_check_cover_state_change,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/adaptive_cover/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
),
vol.Required(CONF_DEFAULT_HEIGHT, default=60): selector.NumberSelector(
selector.NumberSelectorConfig(
min=1, max=100, step=1, mode="slider", unit_of_measurement="%"
min=0, max=100, step=1, mode="slider", unit_of_measurement="%"
)
),
vol.Optional(CONF_MAX_POSITION, default=100): selector.NumberSelector(
Expand Down
17 changes: 9 additions & 8 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SERVICE_SET_COVER_POSITION,
SERVICE_SET_COVER_TILT_POSITION,
)
from homeassistant.core import Event, EventStateChangedData, HomeAssistant, State
from homeassistant.core import HomeAssistant, State
from homeassistant.helpers.template import state_attr
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

Expand Down Expand Up @@ -120,21 +120,20 @@ async def async_config_entry_first_refresh(self) -> None:
await super().async_config_entry_first_refresh()
_LOGGER.debug("Config entry first refresh")

async def async_check_entity_state_change(self) -> None:
async def async_check_entity_state_change(
self, entity: str, old_state: State | None, new_state: State | None
) -> None:
"""Fetch and process state change event."""
_LOGGER.debug("Entity state change")
self.state_change = True
await self.async_refresh()

async def async_check_cover_state_change(
self, event: Event[EventStateChangedData]
self, entity: str, old_state: State | None, new_state: State | None
) -> None:
"""Fetch and process state change event."""
_LOGGER.debug("Cover state change")
data = event.data
self.state_change_data = StateChangedData(
data["entity_id"], data["old_state"], data["new_state"]
)
self.state_change_data = StateChangedData(entity, old_state, new_state)
self.cover_state_change = True
self.process_entity_state_change()
await self.async_refresh()
Expand Down Expand Up @@ -304,7 +303,9 @@ def get_blind_data(self):
def after_start_time(self):
"""Check if time is after start time."""
if self.start_time_entity is not None:
time = get_datetime_from_state(get_safe_state(self.start_time_entity))
time = get_datetime_from_state(
get_safe_state(self.hass, self.start_time_entity)
)
now = dt.datetime.now(dt.UTC)
if now.date() == time.date():
return now >= time
Expand Down
38 changes: 19 additions & 19 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ hass-nabucasa = "0.75.1"
pre-commit = "3.7.0"
pre-commit-hooks = "4.6.0"
pylint = "3.1.0"
ruff = "0.3.7"
ruff = "0.4.1"

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/basbruss/adaptive-cover/issues"
Expand Down

0 comments on commit 9e4c83f

Please sign in to comment.