Skip to content

Commit

Permalink
add entity_pictures property
Browse files Browse the repository at this point in the history
  • Loading branch information
liangleslie committed May 30, 2022
1 parent faf1941 commit b0203f8
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions custom_components/nea_sg_weather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,29 @@ def state(self):
"""Return the weather condition."""
return self.coordinator.data.rain.data[self._rain_sensor_id]["value"]

@property
def entity_picture(self):
"""Return the entity picture url to display rainfall quantity"""
rainfall_quantity = (
0
if self.state == 0
else 0.2
if self.state < 0.35
else 0.5
if self.state < 0.75
else 1
if self.state < 1.5
else 2
if self.state < 2.5
else 3
if self.state < 3.5
else 4
if self.state < 4.5
else 5
)

return "/local/weather/" + str(rainfall_quantity) + ".png"

@property
def extra_state_attributes(self) -> dict:
"""Return dict of additional properties to attach to sensors."""
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b0203f8

Please sign in to comment.