Creation of a sensor that changes state based on the consumption value

good evening, I can’t create a sensor that changes based on consumption: I have a heat pump and resistance boiler, and I installed a meter sensor, I wanted it to create an icon based on its operation, if its consumption is between 100w and 300w indicate heat pump on, higher than 301w must display resistor on. I tried with the following listing but it doesn’t seem to work.

- platform: template
  sensors:
    stato_scaldabagno_pompa_di_calore:
      friendly_name: "scaldabagno_p_d_c"
      icon_template: 'mdi:heat-pump-outline'
      value_template: >-
        {{ 'on' if states('sensor.smart_plug_power') | int >= 100 <= 300 else 'off' }}

- platform: template
  sensors:
    stato_scaldabagno_resistenza:
      friendly_name: "scaldabagno_resistenza"
      icon_template: 'mdi:heat-wave'
      value_template: >-
        {{ 'on' if states('sensor.smart_plug_power') | int > 301 else 'off' }}