Why does my temperature automation not work?

I would like to trigger the powerbutton of my pelletheater when it is above 23°(powering of turning off) and below 21°. It does not work

It triggers and works without “below” and “above” conditions.

This is my automation:

- id: '1608322452545'
  alias: Pellet_thermostaat
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.trapmotion_temperature
  condition:
  - condition: or
    conditions:
    - condition: numeric_state
      entity_id: sensor.trapmotion_temperature
      attribute: unit_of_measurement
      below: 21
    - condition: numeric_state
      entity_id: sensor.trapmotion_temperature
      attribute: unit_of_measurement
      above: 23
  action:
  - type: turn_on
    device_id: f70a99d3b46ecd83bf0a6db3869bd5fa
    entity_id: switch.70116356840d8e5c4814
    domain: switch
  mode: single

Remove the two lines starting with “attribute: …”
What you are currently doing is checking if the unit_of_measurement is above/below a value, but the unit of measurement is not a number it’s just °F or °C

This seems a strange way of doing it?

Do you intend that this will fire every time the temperature value changes and that temperature is above or below those temps?

E.g. If the update rate of the temperature sensor is every 10 seconds and the conditions are met, it will keep on turning on that switch every 10 seconds?

That is right, I already thought so too.
I have a solution for that, but did not program that in yet ;-).
Good notice