How can I convey switching times?

It do not work.

  - sensor:
      - name: "GrowBox On"
        state: "{{ state_attr('sun.sun', 'next_noon')|as_datetime|as_local - timedelta(hours=8) }}"
        device_class: timestamp
      - name: "GrowBox Off"
        state: "{{ state_attr('sun.sun', 'next_noon')|as_datetime|as_local + timedelta(hours=8) }}"
        device_class: timestamp

alias: Pflanzenlampe einschalten
description: ''
trigger:
  - platform: sun
    event: sunrise
    offset: '0'
  - platform: time
    at: sensor.growbox_on
condition: []
action:
  - type: turn_on
    device_id: ff0670171d477db7db7417d1508d1314
    entity_id: switch.shelly_wallplug
    domain: switch
mode: single


What the hell am I doing wrong?

The sensor state appears to be missing the timezone info (+00:00). So unless you are in the UTC+0 trimezone, try this instead:

  - sensor:
      - name: "GrowBox On"
        state: "{{ state_attr('sun.sun', 'next_noon')|as_datetime - timedelta(hours=8) }}"
        device_class: timestamp
      - name: "GrowBox Off"
        state: "{{ state_attr('sun.sun', 'next_noon')|as_datetime + timedelta(hours=8) }}"
        device_class: timestamp

Yesterday I did another test automation:

alias: '! Test'
description: ''
trigger:
  - platform: time
    at: sensor.growbox_on
condition: []
action:
  - service: notify.mobile_app_pixel_6_pro
    data:
      message: Test erfolgreich
mode: single

Oddly enough, it worked


Executed: 27. Februar 2022, 04:38:40
this:
  entity_id: automation.test
  state: 'on'
  attributes:
    last_triggered: null
    mode: single
    current: 0
    id: '1645872800259'
    friendly_name: '! Test'
  last_changed: '2022-02-26T19:23:45.474078+00:00'
  last_updated: '2022-02-26T19:23:45.474078+00:00'
  context:
    id: 3cc9d7042b9c6d96f2814b28f07f13c2
    parent_id: null
    user_id: null
trigger:
  id: '0'
  idx: '0'
  platform: time
  now: '2022-02-27T04:38:40+01:00'
  description: time set in sensor.growbox_on
  entity_id: sensor.growbox_on

Why does it work for one but not for the other?

Impossible to say with the limited information provided.