Turn light off if sunny otherwise on

At sunrise if sunny, turn light off, otherwise, on. I think I have the proper code, however, how do I make this fit into the existing Automation below?

New line of code (replace existing value_template):

'{% if is_state("weather.home", "sunny")%}light.turn_off{%else%}light.turn_on{%endif%}'

Existing Automation:

# Check sunny or not at sunrise
- id: '1572100349280'
  alias: Weather-Not Sunny at Sunrise
  trigger:
  - event: sunrise
    offset: +00:01:00
    platform: sun
  condition:
  - condition: template
    value_template: '{{ states("weather.home") != "sunny" }}'
  action:
  - service: homeassistant.turn_on
    entity_id: light.living_room_shelf_lamp
    data:
      brightness_pct: 50
      transition: 3
  - data:
      message: Weather-Not Sunny at sunrise
    service: notify.notify

Your title says the opposite of your requirement?

Thanks :grinning:, changed it

Would this be appropriate?

# Check sunny or not at sunrise
- id: '1572100349280'
  alias: Weather-Not Sunny at Sunrise
  trigger:
  - event: sunrise
    offset: +00:01:00
    platform: sun
  action:
  - value_template: '{% if is_state ("weather.home", "sunny") %} light.turn_off {%else%} light.turn_on {%endif%}'
    entity_id: light.living_room_shelf_lamp
    data:
      brightness_pct: 50
      transition: 3

No. You are templating a service. Use a service template:

  action:
  - service_template: '{% if is_state ("w...

Thank you. I’ll give this a try.