State pause washing machine after 30 seconds

Hi guys, I have created a sensor template for the washing machine states, I would like it to indicate the pause status after 30 seconds, if the sensor active power is less than or equal to 6w.
Is this correct or do some modifications need to be made? Thanks

  - sensor:
      - name: stati lavatrice
        state: >
          {% if states("sensor.lavatrice_active_power")|float == 0 %}
          off
          {% elif states("sensor.lavatrice_active_power")|float <= 6 %}
          pausa
          {% elif as_timestamp(now()) - as_timestamp(states.sensor.lavatrice_active_power.last_changed) >= 30 %}
          pausa
          {% else %}
          on
          {% endif %}

Some help please.