Enhanced Sun component

Yes, get a copy of https://raw.githubusercontent.com/home-assistant/home-assistant/0.88.1/homeassistant/components/automation/sun.py (adjust the link if you’re using a different version of HA) and put it in custom_components/sun, renaming it from sun.py to automation.py.

For custom components, this is now how it’s “supposed to be.” They purposely decided to make using custom components more complicated. They thought it was a good idea, but I suspect they didn’t realize how much of an effect this would have. But, it is what it is, and hopefully it will be better in the long run (which I’m sure was the thinking.)

First, I tried to update the standard sun component, but it was rejected. They don’t want to update it anymore. They want to replace it, but nobody has signed up to do that AFAIK. (Look back in this topic and you’ll see what I’m talking about.)

But, if you ever want to go back to the standard sun component, simply delete the custom_components/sun folder and restart. Presto magico, you’re back to the standard sun component!

I know this isn’t a great situation, but it’s due to the “great migration”, and there’s not much I can do about it, other than try to figure out how to deal with it.

It’s case sensitive I believe, and you need to use an event trigger, not a homeassistant trigger:

trigger:
  - platform: event
    event_type: DELAYED_HOMEASSISTANT_START

If you want to use it lower case, then change it in both places.

1 Like

Sorry to labour the point but if it is important which version of HA I am on, what will happen when I next upgrade (he says, wondering if it is sometimes a misnomer :rofl: )?

Don’t worry, it’s been interesting!

1 Like

thanks for your understanding :wink: I’ve learned a lot in this thread, one of them being I won’t update to 0.88 just yet…

1 Like

Well, if you used a symbolic link…

The funny (“funny” as in “sad”) part of this is the automation sun platform doesn’t actually use the sun component! Both the sun component, and the automation sun platform, use the sun helper (homeassistant/helpers/sun.py). So this is all “make work” for no good reason.

Yeah… I said that too, but I just couldn’t resist the rounded corners on Lovelace cards. Ha HA!!

1 Like

Just be aware that this all started in 0.86.

ahem… [whispers] how can I do that in hassio?

Stop using hassio. :wink: But seriously, I have no idea; I don’t use hassio.

yes, I am aware of that now. My main system is still on 84.3 while my other is on 87.1 . The first doesnt ‘know’ yet, the second is lenient …so no issues just yet, not even a warning at all. Even when using the Check Homeassistant Configuration add-on, there are no warnings whatsoever. I wonder why that add-on even exists…

Yes, I know :wink:

I’m going to stick with it not giving me a warning message and be aware that I shouldn’t use any automations based on sun.

Wish me luck…

You can still use the sun.sun entity in template triggers and conditions if you want. They have nothing to do with trigger platform: sun or condition: sun.

Good luck!!

1 Like

right, I am tempted too… But for what I am experiencing just now already, Lovelace has a huge impact on front-end processing, especially with history graphs and the likes. where regular HA took its toll with my Hue setup rendering the constant Unavailable for lights and Hub, Lovelace is much worse in that department. reason alone for me to be very very careful with my Homeautomation setup, and not rendering it useless for the family…

1 Like

So I don’t understand why I don’t have any errors with this and made no changes at all. I use the sun elevation in an automation…

Phil, can you give installation instructions for this custom component as you see them at the moment. I am also using hassio but it’s Home Assistant so should be generic anyway?

I haven’t figured that out myself yet. E.g., I have a checkout of the dev branch and copied my sun.py right into custom_components. It seemed to work in general, but depending on what I did I might see errors and/or notifications, and then again, I might not. But what I never saw on the Info page was the warning about using a custom component. (Weird, especially since it was in home-assistant.log!)

As far as I can tell, the instructions are … posted above.

But klogg said he couldn’t implement them all on hassio. Since I don’t use it I can’t comment on how it constrains a user. Checkout the instructions above and let me know what you think!

Well it’s hard to do the 3rd command with Hass.io as Klogg mentioned.

I get the warning about sun being a custom component. My automation using sun works… I don’t know what else to say.

I guess I’ll spend some more time trying to figure out how the changes to the loader work. Maybe I can figure out why it seems to be so random, and what is absolutely necessary to make it (i.e., the custom sun component) work correctly. It all seems, well…

Regarding hassio, wow, seems ridiculously limited. I suppose there must be advantages to offset the downsides.

using generic hass, never had the issue

ERROR (MainThread) [homeassistant.setup] Error during setup of component sun
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 154, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
AttributeError: module 'custom_components.sun' has no attribute 'setup'

What version of HA are you using?