Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
da986bc
Make phase and deCONZ daylight sensors use observer elevation
pnbruckner Nov 9, 2025
54c6503
Bump version to 3.4.4b0
pnbruckner Nov 9, 2025
9cff809
Fix deCONZ daylight sensor's elevation for just above sunrise/sunset
pnbruckner Nov 9, 2025
f4ba5f4
Bump version to 3.4.4b1
pnbruckner Nov 9, 2025
fa5ceb0
Reimplement phase & deCONZ daylight sensors
pnbruckner Nov 24, 2025
c9ecc27
Make _ph_params a cached_property
pnbruckner Nov 25, 2025
a36d2b9
Bump version to 3.4.4b2
pnbruckner Nov 26, 2025
51a2fbb
Update README.md
pnbruckner Dec 2, 2025
1351bac
Change sunrise & sunset elevation to -0.267 per astral 2.0+
pnbruckner Dec 2, 2025
7cbab52
Move elevation adjustment calculations into new class & misc cleanup
pnbruckner Dec 4, 2025
12362c5
Simplify elevation binary sensor & make it use observer elevation
pnbruckner Dec 5, 2025
50b7fed
Simplify elevation sensor by using time_at_elevation
pnbruckner Dec 5, 2025
88ea8a5
Update README.md
pnbruckner Dec 5, 2025
cec481a
Use previously calculated next elevation target as sensor value
pnbruckner Dec 8, 2025
43b15cb
Refactor elevation binary sensor _update method
pnbruckner Dec 8, 2025
0dfc3fe
Bump version to 4.0.0b0
pnbruckner Dec 8, 2025
91fe54c
Remove outdated manual entity name translations
pnbruckner Dec 8, 2025
003e058
Bump version to 4.0.0b1
pnbruckner Dec 8, 2025
01020a5
Fix first update of elevation binary sensor if sun is setting
pnbruckner Dec 9, 2025
c67e685
Bump version to 4.0.0b2
pnbruckner Dec 9, 2025
9da6f60
Make point in time sensors show next time it occurs within the next year
pnbruckner Dec 10, 2025
3e3092d
Reorganize & clean up class structure and make updates atomic
pnbruckner Dec 11, 2025
4ca4e7d
Make _update async & yield in long running implementations
pnbruckner Dec 11, 2025
9bc3826
Fix "point in time" sensors when next change is in the future
pnbruckner Dec 11, 2025
ef527cb
Optimize Sun2SensorEntityWithUpdate & Sun2PointInTimeSensor _update m…
pnbruckner Dec 12, 2025
5306bba
Move code for changing sun direction to base class
pnbruckner Dec 15, 2025
3eafd70
Use observer elevation when determining azimuth sensor update rate
pnbruckner Dec 15, 2025
677017f
Provide list of available time zones in config flow
pnbruckner Dec 16, 2025
8e0c029
Cache results of Location.midnight & Location.noon
pnbruckner Dec 18, 2025
a9c7561
Bump version to 4.0.0b3
pnbruckner Dec 18, 2025
3b2f73e
Properly handle homeassistant.update_entity action
pnbruckner Dec 18, 2025
cfd530f
Use self._as_tz instead of astral's local option
pnbruckner Dec 22, 2025
4de74f7
Fix homeassistant.update_entity handling
pnbruckner Dec 23, 2025
ca822b1
Bump version to 4.0.0b4
pnbruckner Dec 26, 2025
4a4d526
Update README.md
pnbruckner Dec 26, 2025
7c84292
Drop support for HA versions before 2024.12.0
pnbruckner Dec 26, 2025
d7e728b
Bump version to 4.0.0b5
pnbruckner Dec 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ After it has been downloaded you will need to restart Home Assistant.

### Versions

This custom integration supports HomeAssistant versions 2024.8.3 or newer.
This custom integration supports HomeAssistant versions 2024.12.0 or newer.

## Services

Expand Down Expand Up @@ -142,7 +142,7 @@ A list of one or more of the following.

#### `elevation`

`'on'` when sun's elevation is above threshold, `'off'` when at or below threshold.
`'on'` when sun rises to or above threshold, `'off'` when sets to or below threshold.

Key | Optional | Description
-|-|-
Expand All @@ -161,7 +161,7 @@ Would be equivalent to:

```yaml
- unique_id: bs1
elevation: -0.833
elevation: -0.267
name: Above horizon
```

Expand All @@ -183,20 +183,20 @@ For example, this:

```yaml
- unique_id: s1
time_at_elevation: -0.833
time_at_elevation: -0.267
```

Would be equivalent to:

```yaml
- unique_id: s1
time_at_elevation: -0.833
time_at_elevation: -0.267
direction: rising
icon: mdi:weather-sunny
name: Rising at minus 0.833 °
name: Rising at minus 0.267°
```

#### Elevation at Time Sensor
#### Elevation at Time Sensor [^1]

Key | Optional | Description
-|-|-
Expand All @@ -213,7 +213,7 @@ Also in this case, the `sensor` entity will not have `yesterday`, `today` and `t

Besides the sensors described above, the following will also be created automatically. Simply enable or disable these entities as desired.

### Point in Time Sensors
### Point in Time Sensors [^1] [^2]

Some of these will be enabled by default. The rest will be disabled by default.

Expand All @@ -223,14 +223,14 @@ Solar Midnight | yes | The time when the sun is at its lowest point closest to 0
Astronomical Dawn | no | The time in the morning when the sun is 18 degrees below the horizon
Nautical Dawn | no | The time in the morning when the sun is 12 degrees below the horizon
Dawn | yes | The time in the morning when the sun is 6 degrees below the horizon
Rising | yes | AKA Sunrise. The time in the morning when the sun is 0.833 degrees below the horizon. This is to account for refraction.
Rising | yes | AKA Sunrise. The time in the morning when the sun is 0.267 degrees below the horizon.
Solar Noon | yes | The time when the sun is at its highest point
Setting | yes | AKA Sunset. The time in the evening when the sun is 0.833 degrees below the horizon. This is to account for refraction.
Setting | yes | AKA Sunset. The time in the evening when the sun is 0.267 degrees below the horizon.
Dusk | yes | The time in the evening when the sun is a 6 degrees below the horizon
Nautical Dusk | no | The time in the evening when the sun is a 12 degrees below the horizon
Astronomical Dusk | no | The time in the evening when the sun is a 18 degrees below the horizon

### Length of Time Sensors (in hours)
### Length of Time Sensors (in hours) [^1]

These are all disabled by default.

Expand All @@ -252,11 +252,11 @@ These are also all disabled by default.
Type | Description
-|-
Azimuth | The sun's azimuth (degrees)
Rising Azimuth | The sun's azimuth at sunrise (degrees)
Setting Azimuth | The sun's azimuth at sunset (degrees)
Rising Azimuth [^1] | The sun's azimuth at sunrise (degrees)
Setting Azimuth [^1] | The sun's azimuth at sunset (degrees)
Elevation | The sun's elevation (degrees)
Minimum Elevation | The sun's elevation at solar midnight (degrees)
maximum Elevation | The sun's elevation at solar noon (degrees)
Minimum Elevation [^1] | The sun's elevation at solar midnight (degrees)
maximum Elevation [^1] | The sun's elevation at solar noon (degrees)
deCONZ Daylight | Emulation of [deCONZ Daylight Sensor](https://www.home-assistant.io/integrations/deconz/#deconz-daylight-sensor)
Phase | See [Sun Phase Sensor](#sun-phase-sensor)

Expand All @@ -269,8 +269,8 @@ State | Description
Night | Sun is below -18°
Astronomical Twilight | Sun is between -18° and -12°
Nautical Twilight | Sun is between -12° and -6°
Civil Twilight | Sun is between -6° and -0.833°
Day | Sun is above -0.833°
Civil Twilight | Sun is between -6° and -0.267°
Day | Sun is above -0.267°

###### Attributes

Expand Down Expand Up @@ -316,7 +316,7 @@ sun2:
elevation: 0
binary_sensors:
- unique_id: bs1
elevation
elevation: horizon
- unique_id: bs2
elevation: 3
- unique_id: bs3
Expand All @@ -341,3 +341,7 @@ sun2:
All "simple" sensor options (e.g., `dawn`, `daylight`, etc.) will be created automatically.
Some will be enabled by default, but most will not.
Simply go to the Settings -> Devices & services page, click on Sun2, then entities, and enable/disable the entities as desired.

[^1]: These sensors usually have `yesterday`, `today` & `tomorrow` attributes that indicate what the state of the sensor was, is or will be, on these days, and usually are "raw" values (i.e., represented in Python types such as a `datetime` instead of a string, and are typically not rounded.)

[^2]: The `yesterday`, `today` & `tomorrow` attributes will be `None`/`null` if the event does not occur on the corresponding day. If the event does not occur today, the main state will show the next time the event does happen, if it does within the next year. If it doesn't happen today or anytime within the next year, the main state will be `unknown`.
4 changes: 3 additions & 1 deletion custom_components/sun2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def handle_core_config_update(event: Event) -> None:
if ha_loc_data_changed := new_ha_loc_data != s2data.ha_loc_data:
s2data.ha_loc_data = new_ha_loc_data

if not any(key in event.data for key in ("location_name", "language")):
if "location_name" not in event.data:
if ha_loc_data_changed:
async_dispatcher_send(hass, SIG_HA_LOC_UPDATED)
return
Expand Down Expand Up @@ -210,6 +210,7 @@ async def entry_updated(hass: HomeAssistant, entry: ConfigEntry) -> None:
config_data = sun2_data(hass).config_data[entry.entry_id]
if (
entry.title == config_data.title
and entry.pref_disable_polling == config_data.pref_disable_polling
and entry.options.get(CONF_BINARY_SENSORS, []) == config_data.binary_sensors
and entry.options.get(CONF_SENSORS, []) == config_data.sensors
):
Expand All @@ -231,6 +232,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up config entry."""
sun2_data(hass).config_data[entry.entry_id] = ConfigData(
entry.title,
entry.pref_disable_polling,
entry.options.get(CONF_BINARY_SENSORS, [])[:],
entry.options.get(CONF_SENSORS, [])[:],
await async_get_loc_data(hass, entry.options),
Expand Down
Loading