Skip to content

Commit

Permalink
Tile update
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Nov 21, 2023
1 parent 3757d3a commit 8d85965
Showing 1 changed file with 93 additions and 21 deletions.
114 changes: 93 additions & 21 deletions wideboy/scenes/default/tile_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def format_watts(watts: int):

class CellElectricityDemand(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_BOLT
limit_high = 500

@property
def value(self):
Expand All @@ -43,7 +44,7 @@ def value(self):

@property
def open(self):
return self.value > 500
return self.value > self.limit_high

@property
def label(self):
Expand All @@ -53,17 +54,22 @@ def label(self):
def cell_color_background(self):
return (
CommonColors.COLOR_RED_DARK
if self.value > 1000
if self.value > self.limit_high
else CommonColors.COLOR_GREY_DARK
)

@property
def icon_color_background(self):
return CommonColors.COLOR_RED if self.value > 1000 else CommonColors.COLOR_GREY
return (
CommonColors.COLOR_RED
if self.value > self.limit_high
else CommonColors.COLOR_GREY
)


class CellElectricityRate(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_HOURGLASS
limit_high = 0.30

@property
def value(self):
Expand All @@ -75,6 +81,22 @@ def value(self):
def label(self):
return f"£{self.value:.2f}"

@property
def cell_color_background(self):
return (
CommonColors.COLOR_RED_DARK
if self.value > self.limit_high
else CommonColors.COLOR_GREY_DARK
)

@property
def icon_color_background(self):
return (
CommonColors.COLOR_RED
if self.value > self.limit_high
else CommonColors.COLOR_GREY
)


class CellElectricityAccumulativeCost(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_CLOCK
Expand Down Expand Up @@ -144,14 +166,15 @@ def label(self):

class CellSpeedTestDownload(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_CIRCLE_ARROW_DOWN
limit_low = 500

@property
def value(self):
return int(self.state.get("sensor.speedtest_download_average", 0))

@property
def open(self):
return self.value > 500
return self.value < self.limit_low

@property
def label(self):
Expand All @@ -160,14 +183,15 @@ def label(self):

class CellSpeedTestUpload(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_CIRCLE_ARROW_UP
limit_low = 500

@property
def value(self):
return int(self.state.get("sensor.speedtest_upload_average", 0))

@property
def open(self):
return self.value > 500
return self.value < self.limit_low

@property
def label(self):
Expand All @@ -176,14 +200,15 @@ def label(self):

class CellSpeedTestPing(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_HEART_PULSE
limit_high = 10

@property
def value(self):
return int(self.state.get("sensor.speedtest_ping_average", 0))

@property
def open(self):
return self.value > 25
return self.value > self.limit_high

@property
def label(self):
Expand All @@ -192,20 +217,72 @@ def label(self):

class CellDS920VolumeUsage(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_HARD_DRIVE
limit_high = 70

@property
def value(self):
return int(self.state.get("sensor.ds920plus_volume_used", 0))

@property
def open(self):
return self.value > 60
return self.value > self.limit_high

@property
def label(self):
return f"{self.value}%"


# Temperature Tiles


class CellTemperatureOutside(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_HOUSE

@property
def value(self):
return float(self.state.get("sensor.openweathermap_temperature", 0))

@property
def label(self):
return f"{self.value:.1f}°"


class CellTemperatureLounge(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_COUCH

@property
def value(self):
return float(self.state.get("sensor.hue_motion_sensor_1_temperature", 0))

@property
def label(self):
return f"{self.value:.1f}°"


class CellTemperatureBedroom(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_BED

@property
def value(self):
return float(self.state.get("sensor.bedroom_temperature_sensor_temperature", 0))

@property
def label(self):
return f"{self.value:.1f}°"


class CellTemperatureKitchen(GridCell):
icon_codepoint = FontAwesomeIcons.ICON_FA_SINK

@property
def value(self):
return float(self.state.get("sensor.kitchen_temperature_sensor_temperature", 0))

@property
def label(self):
return f"{self.value:.1f}°"


# Test Tiles


Expand Down Expand Up @@ -265,30 +342,26 @@ class GridColumnHomeLab(HorizontalCollapseTileGridColumn):
]


class GridColumnBattery(HorizontalCollapseTileGridColumn):
border_width = 1
border_color = rainbox_colors[1]
cells = [
CellBatteryLevel,
CellBatteryACInput,
CellBatteryACOutput,
]


class GridColumnElectricity(HorizontalCollapseTileGridColumn):
border_width = 1
border_color = rainbox_colors[2]
cells = [
CellElectricityDemand,
CellElectricityRate,
CellElectricityAccumulativeCost,
CellBatteryLevel,
]


class GridColumnTest(HorizontalCollapseTileGridColumn):
class GridColumnTemperature(HorizontalCollapseTileGridColumn):
border_width = 1
border_color = rainbox_colors[3]
cells = [CellTestRandom, CellSwitchLoungeFan]
cells = [
CellTemperatureOutside,
CellTemperatureLounge,
CellTemperatureKitchen,
CellTemperatureBedroom,
]


# CUSTOM GRID
Expand All @@ -297,7 +370,6 @@ class GridColumnTest(HorizontalCollapseTileGridColumn):
class CustomTileGrid(TileGrid):
columns = [
GridColumnHomeLab,
GridColumnTest,
GridColumnBattery,
GridColumnTemperature,
GridColumnElectricity,
]

0 comments on commit 8d85965

Please sign in to comment.