I want my automation to be started by a trigger (numeric value <1) during a timespan between 1 hour before sunset and sunset. i.e. at any time during that period. However the automation should start even if the value is above 1 at sunset. What is wrong with the logic of the following condition, it doesn’t seem to work.
condition:
- condition: and
conditions:
- condition: sun
before: sunset
- condition: sun
after: sunset
after_offset: '-01:00:00'`
I think you need to get rid of the before: The offset function modifies only the portion of the timespan proximal to your reference point (sunset or sunrise). For sunset, before: allows timespans from midnight to a time before sunset or a time after sunset. On the other hand after: allows timespans from before sunset or after sunset until midnight. Your original condition boils down to “from midnight to sunset and from sunset until midnight”… it is always true.
condition:
- condition: sun
after: sunset
after_offset: '-01:00:00'
- condition: not
conditions:
- condition: sun
after: sunset
Because I find the sun condition’s offset function annoying I would probably use a Template condition: