Enhanced Sun component

I got it to install 1.5.0 by poking the reinstall button. Doing the normal upgrade did what you are seeing.

I never could get it to update. Neither thru the update or thru reinstalling it.

I ended up just manually updating by copying the files from the repo.

HACS still shows me on v1.4.0 tho.

I guess i’ll try posting a bug on the HACS repo…

That sounds like what I ran into with the previous version. I had to hand edit the HACS files to fix it. The entry for the sun2 component seemed to have gotten out of phase and it showed the git hash for latest version (installed_commit) but the prior version number (version_installed) and it would fail to update. Updating after manually installing the updated files would install the prior version. IIRC, uninstalling and reinstalling did not fix it, which is why I ended up editing the files.

The hacs.repositores file in the .storage folder should look like this for the latest version:

"192782243": {
            "authors": [
                "@pnbruckner"
            ],
            "category": "integration",
            "description": "Home Assistant Sun2 Sensor",
            "full_name": "pnbruckner/ha-sun2",
            "hide": false,
            "installed": true,
            "installed_commit": "f5c5c54",
            "last_commit": "f5c5c54",
            "last_release_tag": "1.5.0",
            "name": "Sun2",
            "new": false,
            "repository_manifest": {},
            "selected_tag": "1.5.0",
            "show_beta": true,
            "topics": [
                "sensor",
                "sun"
            ],
            "version_installed": "1.5.0"
        },
1 Like

Hmm, maybe the cause is that I’ve made a commit to the master branch after the latest release tag. Tag 1.5.0 corresponds to c6b2cf3, but the last commit is f5c5c54. Probably another HACS bug.

That seems to have fixed the installed/available mismatch.

Thanks! :slightly_smiling_face:

Hopefully from here on out everything will sort itself out.

hello,im trying to install your component sun2 from HACS but its not avaiable from there
i guess i should agree it copying it to custom_component folder manually
regards

You can add it as an “external” (or whatever HACS calls it these days) repository. See the HACS docs.

i tried it but dont let me

Im adding this
https://github.com/pnbruckner/ha-sun2.git

I assume you should enter the following for the repository:

https://github.com/pnbruckner/ha-sun2
1 Like

thanks a lot master :heart_eyes: :blush:

If you use releases it ignores the commit tags

In theory. Yet commit hashes are in the .storage/hacs.repositories file, as noted above. I wouldn’t put it past HACS to improperly make assumptions about tags & commit hashes. I’ve been fixing and fighting bugs in custom_updater & HACS for so long…

Indeed. Perhaps raise an issue with @ludeeus HACS is very popular and makes things much easier (usually) for an end user at least. I’m sure there are issues.

I’m not having a problem, because I don’t use it. But those that are using it and having problems, maybe they should. If it comes down to something that I need to change, and it’s relatively easy, I don’t mind doing it. But I’m done trying to keep up with it on my own.

Released sun2 1.6.0

Adds icon for elevation binary sensor that indicates above/below state. (Uses same icons used for original sun component.)

1 Like

How can i make a template sensor which just shows the times in HH:mm or how do i address just the time in a template? As this one has the date etc in it not just time.

Im using this but this is the original sun which as soon as sunset/sunrise happens the times change.

      sunset_with_offset:
        friendly_name: 'Sunset Time'
        value_template: '{{ (as_timestamp(states.sun.sun.attributes.next_setting) - (states("input_number.sunset_offset") | int)  * 60)  | timestamp_custom("%H:%M") }}'
       
      sunrise_with_offset:
        friendly_name: 'Sunrise Time'
        value_template: '{{ (as_timestamp(states.sun.sun.attributes.next_rising) + (states("input_number.sunrise_offset") | int)  * 60)  | timestamp_custom("%H:%M") }}'

Either of these should work:

{{ states('sensor.sunrise')|regex_findall_index('T(\d\d:\d\d)') }}
{{ state_attr('sensor.sunrise', 'today').strftime('%H:%M') }}

So version 0.110.0
Getting warnings in the log about binary_sensor.
I had to reconfigure the sensor as follows:

binary_sensor:
# - platform: sun2
#   monitored_conditions:
#     - elevation
#     - elevation:
#         above: 25
#         name: Sun Above 25
  - platform: template
    sensors:
      sun_above_25:
        friendly_name: "Sun Above 25"
        value_template: >-
          {{ states('sensor.solar_elevation')|float >25 }}

I only use the >25 one…

It’s only a warning. It should still work until they remove backwards compatibility.

But I went ahead and modified the custom integration to be compatible with >= 0.110 (and also maintain backwards compatibility.) You can find a beta copy here. If you give it a try, let me know how it works for you. I tested it on my production system (0.104.0), as well as with a relatively recent dev checkout (which contains the change that caused the warning), and it seems to work ok for me.

2 Likes

any plans to integrate this with hacs?

1 Like