Comments (13)
@travisghansen my suggestions!
from hass-opensprinkler.
I'll check them out and see if I have other suggestions.
from hass-opensprinkler.
Just having fun..thoughts?
diff --git a/custom_components/opensprinkler/binary_sensor.py b/custom_components/opensprinkler/binary_sensor.py
index 75581a5..790b9c1 100755
--- a/custom_components/opensprinkler/binary_sensor.py
+++ b/custom_components/opensprinkler/binary_sensor.py
@@ -79,6 +79,14 @@ class ProgramIsRunningBinarySensor(OpenSprinklerBinarySensor, BinarySensorEntity
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._entry_id}_{self._entity_type}_program_running_{self._program.index}"
+ @property
+ def icon(self) -> str:
+ """Return icon."""
+ if self._program.is_running:
+ return "mdi:timer"
+
+ return "mdi:timer-off"
+
def _get_state(self) -> bool:
"""Retrieve latest state."""
return bool(self._program.is_running)
@@ -107,6 +115,14 @@ class StationIsRunningBinarySensor(OpenSprinklerBinarySensor, BinarySensorEntity
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._entry_id}_{self._entity_type}_station_running_{self._station.index}"
+ @property
+ def icon(self) -> str:
+ """Return icon."""
+ if self._station.is_running:
+ return "mdi:water"
+
+ return "mdi:water-off"
+
def _get_state(self) -> bool:
"""Retrieve latest state."""
return bool(self._station.is_running)
diff --git a/custom_components/opensprinkler/sensor.py b/custom_components/opensprinkler/sensor.py
index e2b873b..bddf338 100755
--- a/custom_components/opensprinkler/sensor.py
+++ b/custom_components/opensprinkler/sensor.py
@@ -64,7 +64,7 @@ class WaterLevelSensor(OpenSprinklerSensor, Entity):
@property
def icon(self) -> str:
"""Return icon."""
- return "mdi:water"
+ return "mdi:water-percent"
@property
def name(self) -> str:
diff --git a/custom_components/opensprinkler/switch.py b/custom_components/opensprinkler/switch.py
index 44257c4..aba66a3 100755
--- a/custom_components/opensprinkler/switch.py
+++ b/custom_components/opensprinkler/switch.py
@@ -78,6 +78,16 @@ class ControllerOperationSwitch(OpenSprinklerBinarySensor, SwitchEntity):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._entry_id}_{self._entity_type}_controller_operation_enabled"
+ @property
+ def icon(self) -> str:
+ """Return icon."""
+ if self._controller.operation_enabled:
+ #return "mdi:circle-outline"
+ return "mdi:toggle-switch"
+
+ #return "mdi:circle-off-outline"
+ return "mdi:toggle-switch-off"
+
def _get_state(self) -> str:
"""Retrieve latest state."""
return bool(self._controller.operation_enabled)
@@ -111,6 +121,14 @@ class ProgramEnabledSwitch(OpenSprinklerBinarySensor, SwitchEntity):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._entry_id}_{self._entity_type}_program_enabled_{self._program.index}"
+ @property
+ def icon(self) -> str:
+ """Return icon."""
+ if self._program.enabled:
+ return "mdi:calendar-clock"
+
+ return "mdi:calendar-remove"
+
def _get_state(self) -> str:
"""Retrieve latest state."""
return bool(self._program.enabled)
@@ -148,6 +166,17 @@ class StationEnabledSwitch(OpenSprinklerBinarySensor, SwitchEntity):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self._entry_id}_{self._entity_type}_station_enabled_{self._station.index}"
+ @property
+ def icon(self) -> str:
+ """Return icon."""
+ if self._station.is_master:
+ if self._station.enabled:
+ return "mdi:water-pump"
+
+ return "mdi:water-pump-off"
+ else:
+ return "mdi:sprinkler"
+
def _get_state(self) -> bool:
"""Retrieve latest state."""
return bool(self._station.enabled)
from hass-opensprinkler.
I like them all except the toggle switch, looks too much like a toggle you can click.
Did you test it, does HA UI actually change the icon with the different states?
from hass-opensprinkler.
Agreed. What did you think of the commented circle variant for that one?
hass will change the icon on state change but only state change. So the example using is master won’t trigger an update if you only change that value behind the scenes...if that makes any sense.
I haven’t looked at the station sensor yet. Plan on playing with that one a bit today.
from hass-opensprinkler.
The circle is better but might still look too much like a radio button initially
I tried looking at a few core integration and couldn't find one which changed based on state and I never seen one before so I wonder if HA will allow it. It's cool but that's my concern.
from hass-opensprinkler.
Not sure, but several of the icons do change in core. I see several tutorials mentioning this in templates as well: https://www.home-assistant.io/integrations/template/#change-the-icon
Agreed on the circle and the toggle. Back to lightning?
from hass-opensprinkler.
from hass-opensprinkler.
Yeah, I'll mess around with them a bit more and see what I like and commit something. We can review and go from there.
from hass-opensprinkler.
OK, I've made that change (not committed yet). The only one I'm still torn on currently is if the StationStatusSensor
stuff is too convoluted :( Should we just do the same setup as the binary sensor (pump on/off and valve on/off)?
from hass-opensprinkler.
simple is always good
from hass-opensprinkler.
OK, I'll change those and commit.
from hass-opensprinkler.
OK, review and merge..
from hass-opensprinkler.
Related Issues (20)
- Issue upgrading to Home Assistant Core 2023.8.0 HOT 8
- Getting 504 error when adding integration HOT 10
- Unable to install integration - Error: Config flow could not be loaded HOT 18
- 1.2.0 Update rendered implementation unusable HOT 14
- Integration calls 'OpenSprinkler Current Time changed to xxxx' Infinite Loop every 5 seconds HOT 3
- Service to set rain delay HOT 4
- Error adding entities for domain time with platform opensprinkler when using sunrise/sunset offsets HOT 3
- OpenSprinkler not working since update to HA2023.10.2 HOT 5
- After core update opensprinkler failed to load HOT 5
- OpenSprinkler Firmware 2.2.0 (2) unexpected error HOT 2
- Current Time Logging HOT 1
- Valve entities?
- Update readme for new services HOT 1
- Getting lots of exceptions with latest verstion HOT 2
- Pause changes to off on second call HOT 3
- Calling Service fails HOT 5
- Inappropriate entities listed when configuring services HOT 1
- Rain delay not working from automation HOT 3
- Run service in template switch doesn't work HOT 2
- Everything unavailable in 2024.5.1 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hass-opensprinkler.