Season sensor Broken?

Is the season sensor (sensor.season) broken, I have the following error in my log over 2000 times since yesterday?

    2018-11-14 17:27:55 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.season fails
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
        await self.async_device_update()
      File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
        await self.hass.async_add_executor_job(self.update)
      File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
        yield self  # This tells Task to wait for completion.
      File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
        future.result()
      File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
        raise self._exception
      File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/season.py", line 122, in update
        self.season = get_season(self.datetime, self.hemisphere, self.type)
      File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/season.py", line 67, in get_season
        import ephem
      File "/srv/homeassistant/lib/python3.5/site-packages/ephem/__init__.py", line 5, in <module>
        import ephem._libastro as _libastro
    AttributeError: module 'ephem' has no attribute '_libastro'
1 Like

yeah, I have this also… My investigation continues;

AttributeError: module 'ephem' has no attribute '_libastro'

and it fails in the module code:

File "/srv/homeassistant/lib/python3.5/site-packages/ephem/__init__.py", line 5, in <module>
    import ephem._libastro as _libastro

The current version has not changed in a long time; https://github.com/brandon-rhodes/pyephem/releases/tag/v3.7.6.0

but in the pypi.org project, it does not support python 3.5… only 3.4.

Is it displaying correctly? Mine is showing correctly and I’m not seeing sensor.season in your logs?

I have both types setup, one is working one is not… Hard to tell which one is which because the sensor does not support a custom name.

- name: season astronomical
  platform: season
  type: astronomical

- name: season meteorological
  platform: season
  type: meteorological

maybe OP can mention which one he is using.

I have this in one package:

  - platform: season

and this in another:

sensor:
  - platform: template
    sensors:
      seasonname:
        entity_id: sensor.season
        friendly_name: 'Season'
        value_template: >
          {{ states('sensor.season').title() }} 
        entity_picture_template: >-
          {% set state = states('sensor.season'.title()) %}
          {{ '/local/icons/season/{}.png'.format(state) }}

No issues here. I think the default is astronomical?

yeah.

So meteorological is the issue. I will disable and confirm.

@DavidFW1960

It’s the very first line.

Oops! Sorry I missed that.

Somebody any news on this matter?

  - platform: season
    type: meteorological
    icon_template: >
      '{% if is_state("sensor.season", "autumn") %}
        mdi:leaf
      {% elif is_state("sensor.season", "winter") %}
        mdi:snowflake
      {% elif is_state("sensor.season", "spring") %}
        mdi:flower
      {% elif is_state("sensor.season", "summer") %}
        mdi:sunglasses
      {% else %}
        mdi:cloud
      {% endif %}'
  - platform: season
    type: astronomical
    icon_template: >
      '{% if is_state("sensor.season", "autumn") %}
        mdi:leaf
      {% elif is_state("sensor.season", "winter") %}
        mdi:snowflake
      {% elif is_state("sensor.season", "spring") %}
        mdi:flower
      {% elif is_state("sensor.season", "summer") %}
        mdi:sunglasses
      {% else %}
        mdi:cloud
      {% endif %}'

Tried both the type and the both show an error on the sensor.season doesn’t exists.
Very strange…

don’t use the quotes around the multiline templates…

the season sensor should work as expected, sure does here.

using this as a customization though, not in the sensor itself:

    sensor.season:
      templates:
        friendly_name_template: return state
        icon: >
          if (state === 'spring') return 'mdi:flower';
          if (state === 'summer') return 'mdi:sunglasses';
          if (state === 'autumn') return 'mdi:leaf';
          if (state === 'winter') return 'mdi:snowflake';
          return 'mdi:cloud';
        icon_color: >
          if (state === 'spring') return 'green';
          if (state === 'summer') return 'yellow';
          if (state === 'autumn') return 'orange';
          if (state === 'winter') return 'blue';
          return 'grey';
        _stateDisplay: >
          function capitalizeFirstLetter(string) {return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();}
          string = state;
          return capitalizeFirstLetter(string);

Where does the above go? I currently have been adding all my devices to HA and am allowing the configuration to auto create elements on the default view. Is this something I would have to switch to manual configuration and edit the lovelace file directly?

Thanks.

JR

As said, the above is a customization, so goes in the customize section.
Forget about the _stateDisplay part, since that isn’t supported any longer with nowadays HA.

for icon_color, you need the custom_ui, which is still supported fine, and prevents a lot of tinkering in Lovelace cards… :wink: check here how to install https://github.com/andrey-git/home-assistant-custom-ui/blob/5274c9b1e51d8a4ba409cbf510d286472d42c328/docs/installing.md