Hi
Here are the sensors I have created. The code below is from the storage to HA, but you have to use the sun2 configuration to create them
{
“entry_id”: “be87d11dcd1a9aa7d4de8fd1b2e7d4eb”,
“version”: 1,
“minor_version”: 1,
“domain”: “sun2”,
“title”: “phone”,
“data”: {},
“options”: {
“elevation”: 0.0,
“time_zone”: “Europe/Oslo”,
“latitude”: 58.737857,
“longitude”: 5.6400118,
“sensors”: [
{
“time_at_elevation”: -6.0,
“direction”: “rising”,
“icon”: “mdi:weather-sunset-down”,
“name”: “blue hour starts in the morning”,
“unique_id”: “dcf3e30175de6772cf298682ec037045”
},
{
“time_at_elevation”: -4.0,
“direction”: “rising”,
“icon”: “mdi:weather-sunset-down”,
“name”: “golden hour starts in the morning”,
“unique_id”: “1b08550a104a4140818439ee6f8500c6”
},
{
“time_at_elevation”: 6.0,
“direction”: “rising”,
“icon”: “mdi:weather-sunset-down”,
“name”: “golden hour ends in the morning”,
“unique_id”: “3e888eb383f9ae6ec949aa3a7d365616”
},
{
“time_at_elevation”: 6.0,
“direction”: “setting”,
“icon”: “mdi:weather-sunset-down”,
“name”: “golden hour starts in the evening”,
“unique_id”: “a2e734f5e58222825d46dde64ee6c9f7”
},
{
“time_at_elevation”: -4.0,
“direction”: “setting”,
“icon”: “mdi:weather-sunset-down”,
“name”: “golden hour ends in the evening”,
“unique_id”: “48b4b258edfbacaa41cbf2e470341a9f”
},
{
“time_at_elevation”: -6.0,
“direction”: “setting”,
“icon”: “mdi:weather-sunset-down”,
“name”: “blue hour ends in the evening”,
“unique_id”: “d6db91cbedab062536d361294e7694f6”
}
],
“observer_elevation”: [
0.0,
0.0
]
},
Here is the card (in norwegian)
type: entities
entities:
- entity: sensor.phone_sun_bla_time_slutter_kveld
icon: mdi:weather-sunset-down
type: custom:multiple-entity-row
state_header: Blå
name: Gylden time kveld
format: time
entities:
- entity: sensor.phone_sun_gylden_time_starter_kveld
name: Start
format: time
- entity: sensor.phone_sun_gylden_time_slutter_kveld
name: Stopp
format: time
- type: divider
- entity: sensor.phone_sun_gylden_time_slutter_morgen
attribute: tomorrow
icon: mdi:weather-sunset-up
type: custom:multiple-entity-row
state_header: Stopp
name: Gylden time morgen
format: time
entities:
- entity: sensor.phone_sun_bla_time_starter_morgen
name: Blå
format: time
attribute: tomorrow
- entity: sensor.phone_sun_gylden_time_starter_morgen
name: Start
format: time
attribute: tomorrow
- type: divider
- entity: sensor.phone_sun_setting_azimuth
format: precision0
state_header: Ned
name: Sol, retning
icon: mdi:sun-compass
type: custom:multiple-entity-row
entities:
- entity: sensor.phone_sun_rising_azimuth
format: precision0
name: Opp
- entity: sensor.phone_sun_daylight
attribute: tomorrow_hms
state_header: I morgen
icon: mdi:sun-clock
name: Daglengde
type: custom:multiple-entity-row
entities:
- entity: sensor.phone_sun_daylight
name: I dag
attribute: today_hms
- entity: sensor.pixel_7_geocoded_location
name: ' '
title: Fototid
And here is the automation for setting a new location when on travel
alias: Ny posisjon til sun2
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.pixel_7
attribute: latitude
condition: []
action:
- service: sun2.get_location
data:
location: phone
response_variable: location
- if:
- condition: template
value_template: >-
{{ distance(location.latitude, location.longitude,
'device_tracker.pixel_7') > 10 }}
then:
- service: sun2.update_location
metadata: {}
data:
location: phone
latitude: "{{ state_attr('device_tracker.pixel_7', 'latitude') }}"
longitude: "{{ state_attr('device_tracker.pixel_7', 'longitude') }}"
time_zone: "{{ state_attr('sensor.pixel_7_current_time_zone', 'time_zone_id') }}"
mode: single