Coder Social home page Coder Social logo

Icons Audit about hass-opensprinkler HOT 13 CLOSED

vinteo avatar vinteo commented on August 20, 2024
Icons Audit

from hass-opensprinkler.

Comments (13)

vinteo avatar vinteo commented on August 20, 2024

@travisghansen my suggestions!

from hass-opensprinkler.

travisghansen avatar travisghansen commented on August 20, 2024

I'll check them out and see if I have other suggestions.

from hass-opensprinkler.

travisghansen avatar travisghansen commented on August 20, 2024

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.

vinteo avatar vinteo commented on August 20, 2024

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.

travisghansen avatar travisghansen commented on August 20, 2024

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.

vinteo avatar vinteo commented on August 20, 2024

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.

travisghansen avatar travisghansen commented on August 20, 2024

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.

vinteo avatar vinteo commented on August 20, 2024

from hass-opensprinkler.

travisghansen avatar travisghansen commented on August 20, 2024

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.

travisghansen avatar travisghansen commented on August 20, 2024

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.

vinteo avatar vinteo commented on August 20, 2024

simple is always good

from hass-opensprinkler.

travisghansen avatar travisghansen commented on August 20, 2024

OK, I'll change those and commit.

from hass-opensprinkler.

travisghansen avatar travisghansen commented on August 20, 2024

OK, review and merge..

from hass-opensprinkler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.