Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rgc99 committed Aug 30, 2024
1 parent 9a88bb2 commit 65b1917
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 1 addition & 3 deletions custom_components/irrigation_unlimited/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ def _clear_cache(self) -> None:

def _today_duration(self, stime: datetime, data: list[State]) -> timedelta:
"""Return the total on time"""
# pylint: disable=no-self-use

elapsed = timedelta(0)
front_marker: State = None
start = midnight(stime)
Expand Down Expand Up @@ -167,7 +165,7 @@ def _today_duration(self, stime: datetime, data: list[State]) -> timedelta:

def _run_history(self, stime: datetime, data: list[State]) -> list:
"""Return the on/off series"""
# pylint: disable=no-self-use
# pylint: disable=unused-argument

def create_record(item: State, end: datetime) -> dict:
result = OrderedDict()
Expand Down
28 changes: 19 additions & 9 deletions custom_components/irrigation_unlimited/irrigation_unlimited.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
ICON_BLOCKED,
ICON_CONTROLLER_OFF,
ICON_CONTROLLER_ON,
ICON_CONTROLLER_PAUSED,
ICON_CONTROLLER_DELAY,
ICON_DISABLED,
ICON_SUSPENDED,
Expand Down Expand Up @@ -1182,6 +1181,7 @@ def read_sensor(self, stime: datetime) -> Decimal:
self._flow_rates.append(rate)
if len(self._flow_rates) > IUVolume.SMA_WINDOW:
self._flow_rate_sum -= self._flow_rates.pop(0)
# pylint: disable=invalid-unary-operand-type
self._flow_rate_sma = (
self._flow_rate_sum / len(self._flow_rates)
).quantize(Decimal(10) ** -self._flow_rate_precision)
Expand All @@ -1199,6 +1199,7 @@ def event_hook(self, event: HAEvent) -> HAEvent:
return event

async def sensor_state_change(self, event: HAEvent):
"""Callback for when the sensor has changed"""
event = self.event_hook(event)
stime = event.time_fired
try:
Expand Down Expand Up @@ -1281,6 +1282,7 @@ def status(
return IURunStatus.RUNNING
if stime >= end_time:
return IURunStatus.EXPIRED
return IURunStatus.UNKNOWN


class IURun(IUBase):
Expand Down Expand Up @@ -2537,22 +2539,22 @@ def zones(self) -> list[IUZone]:

@property
def duration(self) -> timedelta:
"""Returns the duration for this sequence"""
"""Returns the duration for this sequence zone"""
return self._duration

@property
def delay(self) -> timedelta:
""" "Returns the post delay for this sequence"""
""" "Returns the post delay for this sequence zone"""
return self._delay

@property
def repeat(self) -> int:
"""Returns the number of repeats for this sequence"""
"""Returns the number of repeats for this sequence zone"""
return self._repeat

@property
def volume(self) -> float:
"""Return the volume limit for this sequence"""
"""Return the volume limit for this sequence zone"""
return self._volume

@property
Expand Down Expand Up @@ -2687,7 +2689,7 @@ def zone_runs() -> list[IURun]:
def start_time(runs: list[IURun]) -> datetime:
result: datetime = None
for run in runs:
if result == None or run.start_time < result:
if result is None or run.start_time < result:
result = run.start_time
return result

Expand Down Expand Up @@ -2837,7 +2839,8 @@ def paused(self) -> bool:

@property
def active_zone(self) -> IUSequenceZoneRun:
"""Return the active zone in the sequence"""
"""Return the active zone in the sequence. Maybe None
if sequence is in a delay state"""
return self._active_zone

@property
Expand Down Expand Up @@ -3107,6 +3110,7 @@ def run_state(run: IURun) -> int:
6 = postamble (negative)
7 = future
"""
# pylint: disable=too-many-return-statements
if run.expired and run.master_run.expired:
return 1
if run.future and run.master_run.running:
Expand Down Expand Up @@ -3207,6 +3211,7 @@ def cancel(self, stime: datetime) -> None:
async def update_volume(
self, stime: datetime, zone: IUZone, volume: Decimal, rate: Decimal
) -> None:
"""Notification for when the volume has changed"""
# pylint: disable=unused-argument
if self._active_zone not in self._volume_stats:
self._volume_stats[self._active_zone] = {}
Expand All @@ -3217,7 +3222,7 @@ async def update_volume(
if (limit := self._active_zone.sequence_zone.volume) is not None:
current_vol = sum(self._volume_stats[self._active_zone].values())
if current_vol >= limit:
await self._coordinator._hass.services.async_call(
await self._coordinator.hass.services.async_call(
DOMAIN,
SERVICE_SKIP,
{ATTR_ENTITY_ID: self._sequence.entity_id},
Expand Down Expand Up @@ -4596,7 +4601,7 @@ def muster_sequence(
schedule: IUSchedule,
total_time: timedelta = None,
) -> IURQStatus:
# pylint: disable=too-many-locals, too-many-statements
# pylint: disable=too-many-locals, too-many-statements, too-many-arguments
"""Muster the sequences for the controller"""

def init_run_time(
Expand Down Expand Up @@ -6091,6 +6096,11 @@ def __init__(self, hass: HomeAssistant) -> None:
self._restored_from_configuration: bool = False
self._finalised = False

@property
def hass(self) -> HomeAssistant:
"""Return the HomeAssistant object"""
return self._hass

@property
def entity_id(self) -> str:
"""Return the entity_id for the coordinator"""
Expand Down
1 change: 1 addition & 0 deletions custom_components/irrigation_unlimited/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ async def load_schedule_service_handler(call: ServiceCall) -> None:
@callback
async def get_info_service_handler(call: ServiceCall) -> ServiceResponse:
"""Return configuration"""
# pylint: disable=unused-argument
data = {}
data[ATTR_VERSION] = "1.0.0"
data[ATTR_CONTROLLERS] = [
Expand Down

0 comments on commit 65b1917

Please sign in to comment.