Enhanced Sun component

Love this. I recently stumbled upon your component because of daylight savings time and an automation I have.

I have an automatic (smart) door on my chicken coop that closes 30 minutes after sunset everyday. How ever it uses tomorrows sunset since the trigger happens after sunset. This caused my chicken coop door to stay open an hour later than it should have.

I came to forum looking at how I can store todays sunset as a sensor until midnight but I think your component might be better.

Sad that they wouldn’t let you merge this in.

1 Like

Thanks for your work on this. I’ve been using the daylight attribute to calculate on/off times for my plant lighting to ensure they get at least x hours of light a day.

Now I just need to set up a light sensor so I can turn on the lights when its dark and cloudy during the day and I’ll be all set! Thanks again :slight_smile:

1 Like

Released 1.1.1

Apparently HA 0.92 will require all custom components to have a manifest.json file.

1 Like

I’m not sure if it used to but your sun component (only) isn’t showing in my custom updater card. Is there anything special that prevents it?

image

I’m currently on __version__ = '1.1.0'

You’ll have to ask @ludeeus. (I don’t use the card, just the custom updater.) I recently made a bunch of changes to all my custom components to deal with a change coming in 0.92, while still trying to make sure they work with current and older HA versions. It’s getting pretty hard to do that.

Ok, I decided to reinstall all three of your components manually from scratch (Composite, Life360 and Sun) and now I have some weirdness which I don’t know who to direct at :wink:

I get double warnings at start up for your two of you updated components (plus the breaking changes component which has not changed and neither for the unchanged smartweather or rpi_power) but none for sun

I totally appreciate everything you say, (especially 'It’s getting pretty hard to do that.') I just wondered if any of this should be directed at you or @ludeeus?

Also, I added this back which I thought we no longer needed(?) and sun appeared back on the card - interestingly Life360 and Composite used to appear without it.

  component_urls:
    - https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components.json

The reason for that is that name is bypassed by the tool generating the “master” list
https://github.com/ludeeus/customjson/blob/master/customjson/defaults.py#L4

Why did you think that was no longer needed?

I seem to get the warnings in the logs twice as well but I think it only does that for custom_components that have a ‘normal’ py file AND the __init__.py

Huh? Why? Whatever.

It tracks mine but I have always had this:

custom_updater:
  hide_sensor: false
  track:
    - components
    - cards
    - python_scripts
  component_urls:
    - https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components.json

I didn’t realise that we didn’t need to have that component URL (which is what @klogg is saying) but apparently we still do and I have always had this in my config so it’s always worked.

1 Like

Perhaps because ‘everyone’ knows that it should be the core sun component?
:stuck_out_tongue_winking_eye: :smiling_imp: :roll_eyes: :grin:

2 Likes

FWIW, I considered moving this code to its own repository to make it compatible with the new HACS custom component. But I figured if I did then I should probably update it to incorporate the recent changes to the standard sun component. But they have diverged so much that would be a lot of work. So in the end I decided I wouldn’t.

But now that there is a new code owner of the standard sun component it might be worth making a request to add the desired new attributes (e.g., sunrise and/or sunset) if you feel strongly about it.

So, although I won’t delete this from my repo, at this point it should be considered dead (i.e., no new updates) and effectively unsupported.

How do we make a request to that person specifically?

Well, the official way to make a feature request is to create a new topic in this forum in the Feature Requests category. And the component’s owner can be found here. That name is a github username, which doesn’t always translate to usernames on this forum. So the official answer to your question, I think, is, you can’t.

Yeah, I know of the “feature request” section. I also know that the feature request is fairly useless to actually get features implemented. I can see it being doubly useless on a request for a feature addition to a component that already exists, and has existed for a long time. I guess it can’t hurt to try tho.

Hopefully nothing changes in HA to cause your existing component to break. :wink:

BTW, I looked at the current sun component compared to yours and I’m not sure what (if any) recent changes there have been to the regular component. The only thing I see looking at the code that’s in the regular component that’s not in yours is “rising”. But I don’t know if that was in there before or not either. Obviously the way everything is calculated looks pretty different, too.

Is that what you are referring to or is there something else?

Yes, I’m referring to the way things are calculated, not the new attribute.

One of the main new behaviors is how it decides when to update (mostly for elevation/azimuth.) It updates much less often during the times of day when these values don’t change as quickly. This is definitely a better approach than my simplistic method of being able to configure the (fixed) update period. I think they also recently fixed an issue where the (above/below horizon) state was wrong near the poles when the sun never sets or rises for a period of time.

Yes, I understand that making a feature request on this forum seems to be almost useless, but that’s how it’s supposed to work. Unless you want to submit a PR… :wink:

BTW, not sure how the person that took ownership somehow has missed the fact that people really need the sun entity to have sunrise & sunset attributes that stay constant throughout the day. Must be new or maybe doesn’t monitor this forum much. :man_shrugging:

I chatted with Penny on discord and she said Balloob needs to be convinced and that your enhancements are an edge case…

It would be great if you were able to add the missing attributes. In the meantime I’m looking for other easy to get that information from other sources.

I guess I don’t understand that mindset at all.

there are tons of components that could easily be considered (and literally are) “edge cases” that are a part of the HA core.

I’m not sure why it would be such a big deal to add a couple of extra attributes to an existing component that anyone would have to convince balloob that it needed to be done.

Unless I’m missing something it’s not like it would likely even be a breaking change. It would just be that suddenly you would have a couple of extra attributes pop up. Even if it was, breaking changes literally happen every release even on components that have a way bigger impact on peoples systems than that.

I don’t get it.

Phil actually submitted this component as a PR way back but got beaten down. I’m tempted to say he wasn’t part of the ‘club’ but he has now had a component accepted (life360). At the time Balloob said he wanted the component fully rewritten to follow some vision or other and would not accept this incremental change… Anyway, I doubt we’ll ever see it in the core component.

@DavidFW1960 @finity

I found the conversation you had on discord. I think Penny didn’t understand that there are good use cases for at least today’s sunset/sunrise. There were definitely many requests for help on this forum on how to do certain things (automations, templates, etc.) that needed the day’s sunrise and/or sunset (which stayed constant throughout the day.) The current sun component definitely is deficient to fill these needs. (We’re not making this stuff up people! :slight_smile:) Penny seemed to think it would be a never ending addition of a zillion attributes rather than filling existing, real needs. Of course one could argue that some of the existing attributes (e.g., next_noon & next_midnight, which are the next “solar” noon and midnight, really?!) are superfluous. But, hey, they’re already there, so they must be good.

But seriously, I understand why balloob preferred not to accept what I submitted. And I wasn’t up for taking another stab at it. But it probably wouldn’t take too much effort to add, say, sunrise & sunset. Given my history with it, I should probably take a pass. But if someone else wanted to do the work and make the case, as long as it was somewhat limited in scope, who knows.