pnbruckner / ha-sun2

Home Assistant Sun2 Sensor
The Unlicense
235 stars 22 forks source link

observer_elevation error #130

Closed flyize closed 3 weeks ago

flyize commented 3 months ago

The docs say this is optional, but I see this error every time it starts. Did I miss something?

This error originated from a custom integration.

Logger: custom_components.sun2.config
Source: custom_components/sun2/config.py:224
integration: Sun2 (documentation, issues)
First occurred: 9:08:10 AM (1 occurrences)
Last logged: 9:08:10 AM

New config option observer_elevation missing @ data[sun2][0], will use system general elevation setting
pnbruckner commented 3 months ago

@flyize, what version of this integration are you using, and what version of HA?

Are you using UI or YAML config? Please provide details of the configuration that leads to this error.

flyize commented 3 months ago

Looks like I'm using 3.3.3. And 2024.8.2 of HA.

I'm using the UI config, but do have one configured via YAML.

pnbruckner commented 3 months ago

I believe the warning stems from your YAML configuration. It would be nice if you could provide a copy of that configuration as requested, but I guess that's probably not necessary after all.

This is probably a documentation issue. observer_elevation is optional, but when not provided, the default is not zero, but rather the system's elevation configuration is used. This was done so that existing installations wouldn't change when upgrading. However, a warning is issued because using the system's elevation configuration is not recommended. The problem is, that setting is defined as elevation above sea level, where the sun2 integration (and the built-in sun integration, for that matter) wants elevation above ground level. This has actually been an issue in HA for years that has never been noticed or fixed.

So, yes, observer_elevation is optional, but not providing it results in a warning (not an error) so that you are aware that the integration may be getting the wrong value. If your system's elevation configuration is set to distance above ground level, then the sun2 integration will work correctly. If not, then it's probably best to add observer_elevation to your sun2 YAML configuration and set it to the appropriate value above ground level (which will also cause the warning to go away.)

I'll leave this open for now to remind me to update the docs. Feel free to comment further if you disagree or some of that doesn't make sense.

flyize commented 3 months ago

Oh! That makes much more sense. Thank you!

pnbruckner commented 3 weeks ago

README.md updated accordingly.