Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Apr 9, 2024
1 parent f9960c5 commit 48e39a8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions wideboy/systems/scene/entity_tiles.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import Optional

from ...sprites.tile_grid import VerticalCollapseTileGridCell, TallGridCell
Expand Down Expand Up @@ -47,6 +48,11 @@ def convert_ms_to_mph(ms: Optional[int] = None):
return round(ms * 2.237)


def days_until(end: float):
start = datetime.now().timestamp()
return int(abs(int(start - end) / 60 / 60 / 24))


# CUSTOM COLUMNS

rainbox_colors = [
Expand Down Expand Up @@ -146,7 +152,7 @@ def label(self):

@property
def open(self):
return is_defined(self.value_quality) and self.value_quality > 2
return is_defined(self.value_quality) and self.value_quality > 3

@property
def cell_color_background(self):
Expand Down Expand Up @@ -250,7 +256,7 @@ def label(self):
class CellDS920VolumeUsage(GridCell):
entity_id = "sensor.ds920plus_volume_used"
icon_codepoint = FontAwesomeIcons.ICON_FA_HARD_DRIVE
limit = 70
limit = 80

@property
def open(self):
Expand Down Expand Up @@ -354,7 +360,7 @@ def open(self):
class CellElectricityDemand(GridCell):
entity_id = "sensor.octopus_energy_electricity_current_demand"
icon_codepoint = FontAwesomeIcons.ICON_FA_BOLT
limit = 600
limit = 1000

@property
def label(self):
Expand Down Expand Up @@ -619,6 +625,11 @@ class CellDateDogsFleaTreatment(GridCell):
entity_id = "input_datetime.dogs_flea_treatment"
icon_codepoint = FontAwesomeIcons.ICON_FA_BUG

@property
def open(self):
days = days_until(float(self.entity_state.get("timestamp", 0)))
return days < 7

@property
def label(self):
if "day" not in self.entity_state or "month" not in self.entity_state:
Expand All @@ -630,6 +641,11 @@ class CellDateDogsWormTreatment(GridCell):
entity_id = "input_datetime.dogs_worm_treatment"
icon_codepoint = FontAwesomeIcons.ICON_FA_WORM

@property
def open(self):
days = days_until(float(self.entity_state.get("timestamp", 0)))
return days < 14

@property
def label(self):
if "day" not in self.entity_state or "month" not in self.entity_state:
Expand Down

0 comments on commit 48e39a8

Please sign in to comment.