TOD inverse

I finally found out what the problem was with my TOD helpers (I think…! :slight_smile:

I want the outddor light to turn on 17 minutes before sunset, and turn off 17 minutes after sunrice.
I started with:

  • platform: tod
    name: outdoorlight
    after: sunset
    after_offset: “-00:17”
    before: sunrise
    before_offset: “00:17”

In sometimes rather odd behaviour.
So I finally came to the conclusion do do the oposite go for when light should be turned off!

  • platform: tod
    name: outdoorlightinverse
    after: sunrise
    after_offset: “00:17”
    before: sunset
    before_offset: “-00:17”

and then used:

  • platform: template
    sensors:
    outdoorlight:
    friendly_name: “outdoorlight”
    value_template: >-
    {% set tmpvaluel = is_state(‘binary_sensor.outdoorlightinverse’,‘off’) %}
    {{ tmpvaluel }}

This solutiion is steady as a rock, but confusing, is there a simpler solution, or possible to get an inverse parameter which defaults to ‘no’?
Like:

  • platform: tod
    name: outdoorlight
    inverse: yes
    after: sunset
    after_offset: “-00:17”
    before: sunrise
    before_offset: “00:17”

And then swaps parameters and returns the inverse?

Through the year sunrise varies a bit… from about 2.00 am in summer to 10.00 am in winter.
Sorry about the indentaitions…