Enhanced Sun component

you really should give Splitting up the configuration - Home Assistant some reading time. Your problem has nothing to so with this specific Sun component, but with your misunderstanding of the ways HA allows you to split up your configuration files

You cant just mix it like you do, and you need to follow the instructions in this link.

1 Like

I have no argument with that… my initial setup was done by a good friend of mine and as I learn and go on I’ve been changing things.

Thank you!! I’ve added the all the other monitored_conditions and everything is showing up!!!

Well, that’s interesting. Must be a timing thing. Do you happen to have debug set for homeassistant.core? If not, could you? (I know that would probably create a LOT more messages on your system.) If you could, then could you capture these sun2 messages as well as the homeassistant_started event and any core_config_updated events? I’d be curious to know their order (and relative timing) on your system.

FWIW, there just may not be a good way to deal with this if the system is going to generate multiple core_config_updated events even when the config really isn’t changing.

sorry for the delay, I missed your post completely…

this is what I filtered out of the startup log:

2022-07-16 23:51:44 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event core_config_updated[L]>
2022-07-16 23:51:44 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_start[L]>

2022-07-16 23:51:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event core_config_updated[L]>
2022-07-16 23:51:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_started[L]>

2022-07-16 23:51:55 WARNING (MainThread) [custom_components.sun2.binary_sensor] Astral Above Astronomical Dawn: Sun elevation will not reach -18.000000 again until 2022-07-22

2022-07-16 23:51:57 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: name=custom_components.sun2.binary_sensor, message=['Astral Above Astronomical Dawn: Sun elevation will not reach -18.000000 again until 2022-07-22'], level=WARNING, source=['custom_components/sun2/binary_sensor.py', 258], timestamp=1658008315.511665, exception=, count=1, first_occurred=1658008315.511665>

2022-07-16 23:51:59 WARNING (MainThread) [custom_components.sun2.binary_sensor] Astral Above Astronomical Dawn: Sun elevation will not reach -18.000000 again until 2022-07-22

2022-07-16 23:52:00 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: name=custom_components.sun2.binary_sensor, message=['Astral Above Astronomical Dawn: Sun elevation will not reach -18.000000 again until 2022-07-22'], level=WARNING, source=['custom_components/sun2/binary_sensor.py', 258], timestamp=1658008319.2892756, exception=, count=1, first_occurred=1658008319.2892756>

Before I forget …
my calendar instructed me to remind you

NOTE: A failure scenario has been experienced with the sun_phase sensor. I’m sure it affects the deconz_daylight sensor as well. See Issue #68 for more details.

This sensor does a batch of calculations basically twice a day (at solar midnight & solar noon.) Those calculations determine when it should update (and what the new states should be) until it does the next batch of calculations. Depending on your location and time of year, it’s possible for those calculations to fail, resulting in error messages & no updates until the next batch of calculations.

I’ve released a fix as version 2.1.3b0. If anyone has experienced this issue, please try the beta version and let me know if that fixes the problem for you.

Released 2.1.3

As noted above, fixes failures when calculating when sensor should update.

Hi,

I tried to install the integration via HACS by adding the custom repository as described. It’s then listed as imported repo, but even after a HA restart there’s no new “sun2” integration available to add in HA.

Unfortunately, also the logs didn’t output any error related to this. Was anyone successful with a HACS installation and can maybe help?

I’m not absolutely sure but i think that this integration is only configured via yaml.

Did you follow the instructions in the repo for configuration?

So maybe I misunderstood your question in the issue you created. When you say you searched for the integration but couldn’t find it, did you mean you searched in HACS (after adding the repo) and couldn’t find it to install it in HA? Or did you mean you were able to successfully install it in HA via HACS, but then you couldn’t find it on HA’s Integrations page?

I assumed you meant the former.

If you meant the latter, then @finity is correct, it doesn’t support configuration via HA’s Integrations page, only via YAML. Please see the doc page for details.

Well, this integration could use some love! :heart:

I’ve had some requests to implement unique IDs so that the entities can be reconfigured via the Entities page. I started a PR with a quick, simple mod to test out the idea. It seems to work. If anyone wants to give it a try via the PR/branch, I’d love feedback.

Also, this integration is getting pretty old and is in need of some serious updating. I plan (hope) to spend some time doing just that, too, as part of this PR. And I’ll probably release an “official” (HACS compliant) beta at some point.

4 Likes

HI Phil, a bit late, but I can indeed confirm the functionality to be live:

great you are updating the integration, thanks for that

1 Like

The last commit to the PR branch has updated the integration as of HA 2021.12 (which, don’t tell anyone, is the version I’m using in my “production” system. :wink: ) I plan, for now, to support HA versions 2021.12 or newer (with most, if not all, of my custom integrations.)

I suppose I should cut an “official” beta release.

Next, I’ll update per HA’s dev branch, to take advantage of newer HA features, while maintaining compatibility with 2021.12 or newer.

Released 2.2.0b0

Add unique IDs.

This allows entities to be managed via HA’s Entities page.

Requires HA version 2021.12 or newer.

Released 2.2.0b1

Update per new features in HA dev branch.

2 Likes

thanks Phil, update went without any issue.

please add some info on that those new features entail? or is it this:

Now the attribute is a list as it’s supposed to be, and the order of the values matches the order in which the sensors’ states will change.

I just meant I updated the integration to take advantage of new features and code structure in the HA code base since the 2021.12 release. It’s mostly just implementation details, but the new features you might notice are:

  • “Period of time” sensors will have a device_class of duration for HA versions 2022.5 or newer.
  • Phase sensors (i.e., deconz_daylight & sun_phase) will have a device_class of enum, and a corresponding options attribute, for HA versions 2023.1 or newer.

EDIT:

I might also add, the state of “point in time” sensors used to be given in the configured time zone, but now the core code base makes all entities with a device_class of timestamp (which these are) show their value in UTC. However, the today attribute will still be in the configured time zone (and, as before, is a Python datetime as opposed to the state, which is always a string.)

thanks , will check whether the Utc time causes the entities to show different now, or that the frontend auto translates those to local time.

the new device_classes are nice, though I have yet to discover their usecase.

sun phase showing:

and device_class is filtered by the Frontend, but dev tools states shows is correctly:

now have to figure out what device_class: enum actually means…

btw, we can select the Sun2 integration in the integrations page:

but clicking the integration there results in an error:

saying we can not use the UI for this and have to use the yaml configuration.

suppose this is a work in progress? or shouldn’t it show up at all just yet

That’s not an error, it is an informational message. That’s how the system works when an integration does not support “configuration flow”, which this one does not.