pnbruckner/ha-sun2

Sun2 not working after update

Spartacus68 opened this issue · 12 comments

Hi,

what has changed with the new version, all my configurend sensors are not working anymore! How can I fix it?

sun2:
  - unique_id: xxxxx
    location: home
    latitude: 51.xxxxx
    longitude: 7.xxxxx
    elevation: 135
    time_zone: Europe/Berlin
    #binary_sensors:
    #  - unique_id: sun.gartenlicht
    #    elevation: -3
    #  - unique_id: sun.buergerlich
    #    elevation: -6
    sensors:
      - unique_id: su1
        time_at_elevation: -2.5
        direction: setting
        name: su1
        icon: mdi:weather-sunset-down
      - unique_id: su2
        time_at_elevation: -2.0
        direction: setting
        name: su2
        icon: mdi:weather-sunset-down        
      - unique_id: su3
        time_at_elevation: -1.5
        direction: setting
        name: su3
        icon: mdi:weather-sunset-down
      - unique_id: su4
        time_at_elevation: -0.9
        direction: setting
        name: su4
        icon: mdi:weather-sunset-down
      - unique_id: su5
        elevation_at_time: '00:00'
        name: Elevation at Datum

#
      - unique_id: sa1
        time_at_elevation: -4.0
        direction: rising
        name: sa1
        icon: mdi:weather-sunset-up
      - unique_id: sa2
        time_at_elevation: -1.5
        direction: rising
        name: sa2
        icon: mdi:weather-sunset-up
      - unique_id: sa3
        time_at_elevation: 0
        direction: rising
        name: sa3
        icon: mdi:weather-sunset-up

image
image

I downgraded to 3.2.1 and now everything is working again. Can you please explain, why my sensors are not working with 3.3?

What HA Core version are you using? Any error or warning messages?

Never mind. I see what's wrong. I'll have a fix out shortly.

HA Version:

image

I cannot find anything in the system log, but it looks like, that the sun2.yaml was not loaded by your new version. There was a blank configuration unter "integrations"

What I can do within the next days: I can clone the Homeassistant VM and can check it again

The setup:
image
image

sun2:
  - unique_id: home
    location: home
    latitude: 51.xxxxxxxxx
    longitude: 7.xxxxxxxxxxxxx
    elevation: 135
    time_zone: Europe/Berlin
    #binary_sensors:
    #  - unique_id: sun.gartenlicht
    #    elevation: -3
    #  - unique_id: sun.buergerlich
    #    elevation: -6
    sensors:
      - unique_id: su1
        time_at_elevation: -2.5
        direction: setting
        name: su1
        icon: mdi:weather-sunset-down
      - unique_id: su2
        time_at_elevation: -2.0
        direction: setting
        name: su2
        icon: mdi:weather-sunset-down        
      - unique_id: su3
        time_at_elevation: -1.5
        direction: setting
        name: su3
        icon: mdi:weather-sunset-down
      - unique_id: su4
        time_at_elevation: -0.9
        direction: setting
        name: su4
        icon: mdi:weather-sunset-down
      - unique_id: su5
        elevation_at_time: '00:00'
        name: Elevation at Datum

#
      - unique_id: sa1
        time_at_elevation: -4.0
        direction: rising
        name: sa1
        icon: mdi:weather-sunset-up
      - unique_id: sa2
        time_at_elevation: -1.5
        direction: rising
        name: sa2
        icon: mdi:weather-sunset-up
      - unique_id: sa3
        time_at_elevation: 0
        direction: rising
        name: sa3
        icon: mdi:weather-sunset-up

I recreated the problem using your config (with the latitude & longitude changed to real numbers.) You should have seen the following in the logs:

This error originated from a custom integration.

Logger: custom_components.sun2
Source: helpers/config_validation.py:924
integration: Sun2 (documentation, issues)
First occurred: 2:06:28 PM (1 occurrences)
Last logged: 2:06:28 PM

The 'elevation' option is deprecated, please replace it with 'observer_elevation'

and

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:356
integration: Sensor (documentation, issues)
First occurred: 2:06:28 PM (1 occurrences)
Last logged: 2:06:28 PM

Error while setting up sun2 platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/sun2/helpers.py", line 513, in async_setup_entry
    cls(hass, entry, async_add_entities)
  File "/config/custom_components/sun2/helpers.py", line 417, in __init__
    self._entities = list(self._get_entities())
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sun2/sensor.py", line 1217, in _config_sensors
    raise ValueError(f"Unexpected sensor config: {config}")
ValueError: Unexpected sensor config: {'unique_id': 'sa3', 'time_at_elevation': 0.0, 'direction': 'rising', 'name': 'sa3', 'icon': 'mdi:weather-sunset-up'}

@Spartacus68 let me know if 3.3.1 fixes the problem for you.

I will do tomorrow with a VM clone!

btw. My logfile starts on 5/11/ at 8:30pm and this is after the downgrade to the old version.

But the fix works now without changing my configuration correct?

Yes, it should work without changing your configuration. But I think you might want to reconsider the location elevation.

What exactley to you mean with "reconsidering the location elevation", this line here?
elevation: 135

What is wrong with it? the location is 135m above see level or what exactley is ment with it?or do you mean the height of the object on which the "viewer" is standing.

and btw. 3.3.1 seems not to be available:
image

What exactley to you mean with "reconsidering the location elevation", this line here? elevation: 135

What is wrong with it? the location is 135m above see level or what exactley is ment with it?or do you mean the height of the object on which the "viewer" is standing.

Yes, that line. Please see Observer Elevation.

HA's elevation configuration option has been wrong. It should not be height above sea level, it should be height above ground level.

I.e., for an area with flat land, if you are standing on land, then your elevation is zero (or maybe a couple of meters, if you want to account for the height of your eyes above the ground.) If, however, you're in a tall building, or on a hill, then it's the height of that place above the otherwise flat land.

So, maybe if you're in a 40-story building, then 135m would seem reasonable. Otherwise, zero or two seem more appropriate.

3.3.1 seems not to be available

That's because HACS doesn't check very often. You can either wait until it updates itself, or you can go to HACS -> Integrations -> Sun2, then click on the three-dot menu in the top-right and select "Update information." Now when you go back to the Integrations page, it will show an update available for Sun2.

Hi Phil,

thanks for clarification. I understood it now!

Have a nice day,
Spartacus

Hi @pnbruckner,

sun2 V3.3.1 is working with my configuration. Thank you very much for your support!
Regards,
Spartacus