Hours of Daylight

So I had the daylengthchange set to hidden as I didn’t want the actual sensor to be displayed at all - just wanted the graph. Removed hidden and now it’s showing a history (blank)

Interesting. I’d have to check the code, but (maybe?) it makes sense that history is not recorded for an entity that is hidden. Don’t know. Now that you’ve un-hidden it, it will be interesting to see if you get history (I guess starting at tonight’s midnight. Or, actually, at the next sun elevation change, which should cause sun.sun to have a state change.) FWIW, I use group views, so I define what is displayed, so I don’t have to set things to hidden.

Well, you could have created a template sensor that is daylight converted to floating point hours (with unit_of_measurement set to hr.) That probably would create a reasonable graph, too. Something like {{ (state_attr('sun.sun', 'daylight') / (60*60)) | round(2) }}.

1 Like

I use group views as well but use customize out of habit I guess from before I had views defined and I didn’t want random sensors in the header bar. I certainly didn’t expect hiding it to remove the history. That is an unwanted consequence.

Thanks for that… This has been a good learning exercise and I really appreciate your help Phil @pnbruckner

1 Like

Ha ha ha!!! This is EXACTLY how I feel about it except I have implemented it and still have no idea why!

Except that it is quite cool. But then a lot of stuff I do / want to do in HA has no real actual compelling reason to implement it except to be cool :wink:

2 Likes

Of course. I don’t actually NEED anything… some is just for my interest. This is just something I’m interested in watching and seeing how the day length changes as the seasons change and it’s all at a total cost of $0.

1 Like

HI,
please allow me to jump in here, if I’d need a separate thread tell me.

I’ve been trying to template the offset to the previous (or last if you will) sunset.
My aim is to use that given offset in automations for triggering outside lights and other presence logic.

had this conversation Read sunset offset at a given time? - #11 by tom_l with @tom_l, end ended up with me asking if this could be done with, or added to your CC…
please have a look?
thx!

@pnbruckner
I’m back again with another feature request :wink::roll_eyes:
Is it possible to calculate the maximium sun elevation for ‘today’? And if it is could this be included in your sensor?

I believe that is possible. It would just be the elevation at solar noon I think. That could be calculated at midnight along with the other values that don’t change throughout the day. I’ll add a new feature request, but I probably won’t get to it for a bit.

EDIT: https://github.com/pnbruckner/homeassistant-config/issues/66

1 Like

Well, it’s been a while, but I have a beta available that should do this. Let me know how it works for you (assuming you’re still interested! :slight_smile:)

It has been a while and to be honest I have no idea now why I asked for this! :blush:

I’m more than happy to see test it and see how it works though. It’s the least I can do given all the effort you put into your components (and perhaps my reason for asking will come back to me).

EDIT: Well it seems to work fine. Today it gives an elevation that matches within 0.04 deg with another source on the internet.

1 Like

@klogg

Oops, made a mistake. I used the date of the next solar noon when calculating today’s maximum elevation. I was supposed to use today’s solar noon. Fixed in 1.1.0b2.

Today I have for my lat/lon

Your sun.sun - 26.36
suncalc.org - 26.18

Thanks. But it’s not the values themselves so much as if max_elevation changes only at midnight and agrees with the actual max value of elevation throughout that day, especially at the time indicated by next_noon. (Note I mean the value of next_noon before that time, because like the other next_xxx attributes, they change at the time they indicate.)

The fact that this doesn’t match a value provided by another source isn’t surprising. HA’s sun component (which, of course, my custom version is based on), uses astral from PyPI.

Yes, I most certainly wasn’t ‘complaining’ in any way that the values don’t match.

I hadn’t realised this was useful information for you though…

I’ll try to have a look in the next few days but it won’t be tomorrow as I won’t be around at noon.

Ok, so I was here at noon at it looks spot on…

Here are my sun.sun attributes today at 12:15

2 Likes

@klogg

Version with new max_elevation option now released as 1.1.0.

1 Like

Custom Updater only shows version 1.0 - did you update the version json yet?

Yes, I did. You probably need to run the custom_updater.check_all service manually to see it, because I think that only runs automatically at startup, then once a day after that.

Yeah I think the card takes up yo an hour to show it and I realise now 2 minutes is not an hour lol/ I only just got a bunch of updates so I’m sure sun will show soon.

He also made a change in the way it works I think. Something about some process that updates his own json file once an hour from individual json files rather than having the component use the individual json files directly as it used to. Honestly, I’m not sure I like the change, and I haven’t updated custom_updater myself in quite a while. In fact, I’m thinking of removing it from my system because the only custom components I’m using are my own and the only reason I installed custom_updater in the first place was to make sure it worked with my custom components. :slight_smile: