Zodiac Sign Sensor

For this simple Template Sensor, you aren’t obligated to create an automation to update it. You can simply add sensor.date to the template and it will be automatically assigned a listener (in other words, it will behave like in previous versions where you used entity_id: sensor.date).

- platform: template
  sensors:
    zodiac:
      friendly_name: Zodiac Sign
      value_template: >-
        {% set x = states('sensor.date') %}
        {% set yday = now().timetuple().tm_yday %}
        {% if yday < 20 %} Capricorn
        {% elif yday < 50 %} Aquarius
        {% elif yday < 80 %} Pisces
        {% elif yday < 110 %} Aries
        {% elif yday < 141 %} Taurus
        {% elif yday < 172 %} Gemini
        {% elif yday < 204 %} Cancer
        {% elif yday < 235 %} Leo
        {% elif yday < 266 %} Virgo
        {% elif yday < 296 %} Libra
        {% elif yday < 326 %} Scorpio
        {% elif yday < 356 %} Sagittarius
        {% elif yday < 366 %} Capricorn
        {% else %} Error
        {% endif %}
      icon_template: >
        {% set sign = states('sensor.zodiac') %}
        {% if sign in ['Error', 'unavailable', 'unknown'] %}
          mdi:alert-circle
        {% else %}
          mdi:zodiac-{{ sign | lower}}
        {% endif %}


EDIT

Corrected typo; changed mid to mdi.

3 Likes