Prevent reusing of events when MQTT device becomes available

I have an issue where Home Assistant reuse events when a device becomes available.

I have an external motion sensor that reports motion as events. This is the configuration it posts to MQTT:

   "name":"Hall events",

Here is an automation I have to detect the event:

- id: 'movement_hall_0x00'
  alias: 'Hall movement: On Motion'
  mode: restart
  - platform: state
    entity_id: event.hall_events
  - condition: state
    entity_id: event.hall_events
    attribute: "event_type"
    state: "motion"
    - choose:
        # If light is off and its dark, turn on.
        - conditions:
            - condition: template
              value_template: "{{ state_attr('event.hall_events', 'brightness') < states('input_number.hall_dark_when_below')|float }}"
            - service: scene.turn_on
              entity_id: scene.hall_low
            - service: switch.turn_on
              entity_id: switch.mirror
    - delay: 00:02:00
    - service: switch.turn_off
      entity_id: switch.mirror
    - service: light.turn_off
      entity_id: light.hallway
        transition: 2

This works well. On movement, the device publish an non retained message to hall/event/events/state which trigger the automation. The message looks like this: {"brightness":0.02442002482712269,"event_type":"motion"}

If this device drops connection or restarts, without sending any new data except for publishing “online” again on the availability topic, home assistant will trigger the automation again as it detects an event.
I can simulate this by just publishing offline → online on the availability topic. The HA configuration and the state topic data is unchanged. Note that HA and MQTT are still running in this case, the only thing that changes is the value of the availability topic.

How can I prevent HA from reusing events in this case when a device becomes available?

  - platform: state
    entity_id: event.hall_events
      - unavailable
      - unknown
      - unavailable
      - unknown

That works, thanks! But it does feel like a workaround? I was expecting events to be momentary, and adding this guard across all automations is a bit messy. What causes HA to reuse values in the first place when a device comes online? E.g. can one configure to not reuse a value for a MQTT sensor.

It doesn’t “reuse”.
Those states are states like any other as far as HA is concerned, so if your trigger is “trigger on any state change whatsoever” (and even attribute changes with this notation), it does your bidding.

Right, I understand, it make sense.