Skip to content

Commit

Permalink
Tweak invalid timeslot display (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdpuk committed Jul 9, 2024
1 parent 8d88c23 commit b30335f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions custom_components/givenergy_local/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,12 @@ def is_on(self) -> bool | None:
now: time = dt.now().time()
is_on: bool = slot.start <= now < self.slot.end
return is_on
return None
return False

@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Attach charge slot configuration."""
if slot := self.slot:
return {
"start": slot.start.strftime("%H:%M"),
"end": slot.end.strftime("%H:%M"),
}
return None
return {
"start": self.slot.start.strftime("%H:%M") if self.slot else None,
"end": self.slot.end.strftime("%H:%M") if self.slot else None,
}

0 comments on commit b30335f

Please sign in to comment.