Enhanced Sun component

In theory it already was, multiple times (even going back to custom_updater on some of my custom integrations.) Actually I have plans to remove all references to HACS from all of my custom integrations. I’m tired of trying to keep up with it.

1 Like

It’s able to be installed as a custom repo in HACS.

Please don’t remove it Phil.

1 Like

Error is gone. All good. Thanks.

Using:

binary_sensor:
  - platform: sun2
    monitored_conditions:
      - elevation
      - elevation:
          above: 25
          name: Sun Above 25
1 Like

I only removed a reference to the HACS info from my custom integration’s README.md file. I haven’t done anything to make the integration any less (or more) compatible with HACS. People keep telling me that my custom integrations don’t work with HACS, and I’m tired of dealing with those claims, true or false.

2 Likes

Released as version 1.7.0.

1 Like

FWIW
image

1 Like

HI Phil,

As of late, all of a sudden the sensors for sensor.astral_astronomical_daylight and sensor.astral_astronomical_night are no longer created (unknown).

I don’t see any logging going on, so could this have to do with other circumstances? Or would it be this again:

fwiw, I am using this config since forever:

sensor:
# https://github.com/pnbruckner/ha-sun2
  - platform: sun2
    monitored_conditions:
# point in time
      - solar_midnight
      - astronomical_dawn
      - nautical_dawn
      - dawn
      - sunrise
      - solar_noon
      - sunset
      - dusk
      - nautical_dusk
      - astronomical_dusk

# length of time
      - daylight
      - civil_daylight
      - nautical_daylight
      - astronomical_daylight
      - night
      - civil_night
      - nautical_night
      - astronomical_night

# other
      - elevation
      - max_elevation
    entity_namespace: astral

Can’t replicate

I’m sure it wasn’t all of a sudden; you probably just missed noticing that one day the “tomorrow” attributes changed to none/null, and then “today”, and then “yesterday.” I believe you are simply in that period of the year in your location where the sun does not go below 18 degrees below the horizon, and hence these “astronomical” sensors indicate such is the case. And they are created (as you can see in your states page), they just have values that indicate there is no astronomical dawn/dusk currently.

yes, im sure too…
and I suspected the -18 degrees to be the case, just wasn’t sure.

What would be the best automation and trigger, to have a notification popup, indicating this is the case for this period in the year?

Id like to be prepared next time round :wink:

Well, the state of a “point in time” sensor (like sensor.astral_astronomical_dawn) will be 'none', or the state of a “length of time” sensor (like sensor.astral_astronomical_daylight) will be 'unknown', so…

You could also configure a binary sensor like this:

binary_sensor:
  - platform: sun2
    entity_namespace: astral
    monitored_conditions:
      - elevation:
          above: -18
          name: Above Astronomical Dawn

When you get into the time period where the sun doesn’t go below -18 degrees you’ll get a warning (when it first happens, or if you restart HA), and the sensor’s next_change attribute will indicate the next time the sun does finally go below -18 degrees.

please forgive me, but I dont fully grasp this yet. Also, since I am not on either Poles, nor any where close, I don’t understand why this would happen in my region in the first place. But that’s another issue on my side…leading to ask you this: where can I see the suns elevation for my region during the year? Found sites showing it for ‘now’ but of course I am interested in the -18 change.

still, given the fact you test on above: -18 which the elevation is right now, how come this binary_sensor would be ‘on’, and the astral sensors show none/unknown?

I don’t really know where you’re located (or I don’t remember :sweat_smile:), but for Amsterdam, e.g.:

At least it shows when, througout the year, the sun gets to Astronomical twilight, Nautical …

The binary sensor would be 'on' because the sun is currently above -18. The sensors related to Astronomical Dawn/Dusk show 'none'/'unknown' because the sun was not, and will not be, below -18 today in your location. And, BTW, the binary sensor will not change to 'off' today, and won’t until the sun does finally go below -18. And its next_change attribute will tell you when that will happen. EDIT: Which, according to your updated post, will not be until July 20. And, BTW, did you see the corresponding warning in the log?

Right! It was the other way round… thanks, that explained it. So sorry.
Longest day, as I seem te recall Petro remind me before, its coming back now. Not longest day, that’s 06-21, not 07. hmm.

thanks…

No? nothing in the logs. But I don’t have logger watch it, should I set it to a certain level (debug) to see that?

1 Like

It’s a warning, and as I understand it, you can’t suppress warnings from the LOGS tab of the Developer Tools page. You can suppress them in home-assistant.log, though.

No there was none, in the LOGS tab.
After I added

  custom_components.sun2: warning

to logger, this is logged:

2020-05-25 17:21:06 WARNING (MainThread) [custom_components.sun2.binary_sensor] Sun elevation will not reach -18.000000 again until 2020-07-20

I just tried it myself. I created one with a -30 threshold, which the sun does not reach now.

With logger set to default:

logger:

I got the warning on the LOGS tab:

Log Details (WARNING)
Logger: custom_components.sun2.binary_sensor
Source: custom_components/sun2/binary_sensor.py:284
Integration: sun2 (documentation)
First occurred: 10:38:16 AM (1 occurrences)
Last logged: 10:38:16 AM

Sun elevation will not reach -30.000000 again until 2020-07-30

and in home-assistant.log:

2020-05-25 10:38:16 WARNING (MainThread) [custom_components.sun2.binary_sensor] Sun elevation will not reach -30.000000 again until 2020-07-30

Then I set logger to:

logger:
  default: info
  logs:
    custom_components.sun2: error

then tried it again. This time I still got the warning on the LOGS tab:

Log Details (WARNING)
Logger: custom_components.sun2.binary_sensor
Source: custom_components/sun2/binary_sensor.py:284
Integration: sun2 (documentation)
First occurred: 10:42:31 AM (1 occurrences)
Last logged: 10:42:31 AM

Sun elevation will not reach -30.000000 again until 2020-07-30

but it was not in home-assistant.log.

It doesn’t make sense that you don’t see it in the LOGS tab.

I use:

default: error

in logger, so that would explain why I didn’t see it I guess? Explicitly setting the CC to warning revealed it.

No, it doesn’t explain it.

then I can’t explain it I am afraid. All I can say is it wasn’t showing, and has never done, not until I added the CC to the logger.

Knowing you might not want to add anything to the CC, please let me ask if I could create a sensor for min_elevation based on any of the other sensors you already provide. I’d be interested to see the reason for the binary sensor being on or not, and the next change, in a min_elevation sensor showing that today it won’t go below -18…

would that be feasible?

btw, do you set the icon in the CC for the binary_sensor at all?:

I set the color because it is ‘on’, but a sun would be somewhat odd…

nm: I see it now:

ABOVE_ICON = 'mdi:white-balance-sunny'
BELOW_ICON = 'mdi:moon-waxing-crescent'