Homecoordinates off - sunset/sunrise problem

I’m running 2021.10.6 on Pi4.
While calculating sunset/sunrise i think my home location is not correct.
The location on the map is ok, i’m trying to add the location in the config:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
http:
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem

# configuration.yaml entry
homeassistant:
allowlist_external_dirs:
- “/config”
# name
name: Home
latitude: 51.1322
longitude: 6.1260
elevation: 40

# Example configuration.yaml entry
sensor:

  • platform: filesize
    file_paths:

When checking the configuration, i get these errors:
Integration error: elevation - Integration ‘elevation’ not found.
Integration error: name - Integration ‘name’ not found.
Integration error: longitude - Integration ‘longitude’ not found.
Integration error: latitude - Integration ‘latitude’ not found.

Where do i go wrong?

Difficult to tell because what you posted is unformatted but it might simply be incorrect indentation. The first few lines after homeassistant: should be indented.

Refer to the example in the documentation: Setup basic information

Thanks Taras,
I made a combination of space and tab indentations.
Solved!

I think the “lat-lon-alt” in the configuration wasn’t the real problem:
After defining an automation (lights on after sunset, with an offset), it didn’t work out the way i suspected. I removed the “lat-lon-alt” from the configurations-file and set my location on the Map again (with the same result).

The main problem is that the time displayed in the Automations-stepdetails-tab (after removing the time-offset) is not what i expected:

Executed: October 28, 2021, 09:57:18
Result:

result: true

## conditions/0

Executed: October 28, 2021, 09:57:18
Result:

wanted_time_before: '2021-10-28T16:16:08.670076+00:00' result: true

At my place Sunset is at 18:18, so i expect the “wanted_time” displayed above in GMT also because of +00:00 in the datetime-line.
This is very confusing, is this an error or is there something i can change to show the right (local) time?

BTW i purposely changed it to “before_sunset” for testing purposes.

Post the yaml of your automation.

I picked out the part regarding this problem…

- id: '1634648211862'
  alias: Office - Light on when motion
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 7e41b99c4606185c6cdb62413b0dd7c9
    entity_id: binary_sensor.tz1800_fcdjzz3s_ty0202_ias_zone
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  condition:
  - condition: or
    conditions:
    - condition: sun
      before: sunset
    - condition: sun
      after: sunrise
  action:
  - type: turn_on
    device_id: c98b37426d92b4900242205a621c809b
    entity_id: switch.tz3000_kdi2o9m6_ts011f_on_off
    domain: switch
  mode: single

Try this, I had a similar problem and found this condition worked

condition:
  - condition: template
    value_template: '{{ state_attr(''sun.sun'', ''elevation'') < 4 }}'

Of course use whatever elevation suits.

Thanks for your workaround nickrout!
I’ll find out if it works tonight at 4° before sunset :slight_smile:

Anyway, it would be nice if the problem (?) is solved at the root.

Yes that is for sure.

Before sunset = between midnight and the time the sun goes under
After sunrise = between midnight and the sun comes up

The or is useless, since the first condition enclosed the second.

I think you want an and.

The automation can be simplified like this:

- id: '1634648211862'
  alias: Office - Light on when motion
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.tz1800_fcdjzz3s_ty0202_ias_zone
    to: 'on'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.tz3000_kdi2o9m6_ts011f_on_off
  mode: single

For testing purposes during day time, change below_horizon to above_horizon.

You can also add a second condition to prevent sending a command to turn on the switch if it’s already on. In this example, both conditions are presented as Template Conditions in shorthand notation.

- id: '1634648211862'
  alias: Office - Light on when motion
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.tz1800_fcdjzz3s_ty0202_ias_zone
    to: 'on'
  condition:
  - "{{ is_state('sun.sun', 'below_horizon') }}"
  - "{{ is_state('switch.tz3000_kdi2o9m6_ts011f_on_off', 'off') }}"
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.tz3000_kdi2o9m6_ts011f_on_off
  mode: single