When is state trigger fired: before or after the state changes?

So if I create an automation when the event fires, what will be the value of the device state when I check that in my condition? I am asking this because my automation looks like this. This basically sets my brightness level at a certain level when the light is turned off, or when the ‘nightmode’ boolean changes.

The side effect is that the brightness changes automatically when nightmode goes to true, when the light is already turned on.

I could add a condition saying that light.shelly_dimmer should be off, but I’m not sure if this conflicts with the trigger. If this trigger is running because the state of the light changed from on to off; what would be the value of the state at that point. On or off?

- id: bdk_to_default
  alias: Badkamer naar default waarde
  trigger:
  - platform: state
    entity_id: light.shelly_dimmer_d45fd4_light_0
    to: 'off'
  - platform: state
    entity_id: input_boolean.nightmode
  action:
  - service: script.badkamer_default_brightness
  - service: timer.cancel
    entity_id: timer.badkamer_nacht_bezoek

To avoid ambiguity, perhaps using trigger.from_state and trigger.to_state would be helpful in an action template rather than relying on the condition?

Off.

The trigger is caused by the sate changing to off. Therefore the sate is off once triggered.