Skip to content

Latest commit

 

History

History
143 lines (106 loc) · 3.98 KB

File metadata and controls

143 lines (106 loc) · 3.98 KB
description title
Instructions for setting up tracking the sun position in ESPHome.
Sun

import { Image } from 'astro:assets'; import sunSensorUiImg from './images/sun-sensor-ui.png'; import sunTextSensorUiImg from './images/sun-text_sensor-ui.png'; import APIRef from '@components/APIRef.astro';

The sun component allows you to track the sun's position in the sky. Calculations are done every 60 seconds.

Component/Hub

# Example configuration entry
sun:
  latitude: 48.8584°
  longitude: 2.2945°
  offset: 1d

# At least one time source is required
time:
  - platform: homeassistant

Configuration variables

  • latitude (Required, float): The latitude for performing the calculation.
  • longitude (Required, float): The longitude for performing the calculation.
  • offset (optional, time period): A time duration to offset the current time for sunrise/sunset calculations. Must be 1 second or more, and may be negative.
  • id (Optional, ID): Manually specify the ID used for code generation.

Triggers

# Example configuration entry
sun:
  latitude: 48.8584°
  longitude: 2.2945°

  on_sunrise:
    - then:
        - logger.log: Good morning!
    # Custom elevation, will be called shortly after the trigger above.
    - elevation: 
      then:
        - logger.log: Good morning 2!

  on_sunset:
    - then:
        - logger.log: Good evening!
  • on_sunrise (Optional, Automation): An automation to perform at sunrise when the sun crosses a specified angle.

    • elevation (Optional, float): The elevation to cross. Defaults to -0.833° (the horizon, slightly less than 0° to compensate for atmospheric refraction).
  • on_sunset (Optional, Automation): An automation to perform at sunset when the sun crosses a specified angle.

    • elevation (Optional, float): The elevation to cross. Defaults to -0.833° (the horizon, slightly less than 0° to compensate for atmospheric refraction).

Sensor

Additionally, the sun component exposes its values over a sensor platform.

# Example configuration entry
sensor:
  - platform: sun
    name: Sun Elevation
    type: elevation
  - platform: sun
    name: Sun Azimuth
    type: azimuth

Configuration variables

  • type (Required, string): The type of value to track. One of elevation and azimuth.

  • All other options from Sensor.

Text Sensor

Other properties like the next sunset time can be read out with the sun text_sensor platform.

# Example configuration entry
text_sensor:
  - platform: sun
    name: Sun Next Sunrise
    type: sunrise
  - platform: sun
    name: Sun Next Sunset
    type: sunset
- platform: sun
    name: Sun Time
    type: time
    format: "%c"

Configuration variables

  • type (Required, string): The type of value to track. One of sunrise, sunset, or time.

  • elevation (Optional, float): The elevation to calculate the next sunrise/sunset event for. Defaults to -0.833° (the horizon, slightly less than 0° to compensate for atmospheric refraction).

  • format (Optional, string): The format to format the time value with, see strftime for more information. Defaults to %X.

  • All other options from Text Sensor.

sun.is_above_horizon / sun.is_below_horizon Conditions

The sun.is_above_horizon and sun.is_below_horizon conditions allow you to check if the sun is currently above or below the horizon.

on_...:
  - if:
      condition:
        - sun.is_above_horizon:
      then:
        - logger.log: Sun is above horizon!

See Also