Help to turn on/off according to the specific sensor

I am trying to set the automation to turn on/off according to the sensor of dust.

I have 2 dust sensors and the each sensor can detect the pm2.5 and pm10.
I wanna put the automation like below

  1. The one of the 4 figure from 4 dust sensor will be more than 30, the 2 air purifier will be turned on

  2. The all 4 figure will be less than 5, the 2 air purifier will be turn off.
    And the script I made is like below. But it does not work. Is there anyone who can provide me the information?

- alias: Dust_airpurifier_ONOFF
  initial_state: True
  trigger:
    - platform: template
      value_template: "{% if states.sensor.pm10_1.state | float > 30 or states.sensor.pm10_2.state | float > 30 or states.sensor.pm25_1.state | float > 30 or states.sensor.pm25_2.state | float > 30 %} true {% endif %}"    
    - platform: template
      value_template: "{% if states.sensor.pm10_1.state | float < 10 and states.sensor.pm10_2.state | float < 10 and states.sensor.pm25_1.state | float < 10 and states.sensor.pm25_2.state | float < 10 %} true {% endif %}" 
  action:
    service_template: >
      {% if states.sensor.pm10_1.state | float > 30 or states.sensor.pm10_2.state | float > 30 or states.sensor.pm25_1.state | float > 30 or states.sensor.pm25_2.state | float > 30 %}
        switch.turn_on
      {% elif states.sensor.pm10_1.state | float < 10 and states.sensor.pm10_2.state | float < 10 and states.sensor.pm25_1.state | float < 10 and states.sensor.pm25_2.state | float < 10 %}
        switch.turn_off
      {% endif %}
      entity_id: switch.sonoff1_airpurifier1
      entity_id: switch.sonoff2_airpurifier2
      

please have a look at the top of the page and format your code correctly so we can see what you’ve done so far

Thank you. It is my first time to ask it here. And didn’t how to format the code but I did it. Thank you for your comment.

simply paste the code here, select it, and click the </>

Thanks. I did it before I saw your additional comment. But I really thank you for your comment.

YW and NP.

let me ask first: do all the templates work in dev-template?
always a great tool to see if no errors are made syntactically and entity wise