Automation with MQTT switch as condition

This is the configuration for an automation i want to create, based on battery status (being full >99%), therefore turning off the switch for that charger. The charger switch is set from MQTT, so on startup it might not be defined i think.
Manual ‘EXECUTE’ works though, and iv checked the data types for batter_pers is converted fine to float. If i remove the condition part, it works, but if i uncomment it it does not trigger, what to do about that condition?

- alias: 4G router Battery Charging TURN OFF Control
  id: '123456i8765432'
  initial_state: true
    platform: template
    value_template: '{{  ((states.sensor.generic4g.attributes["battery_pers"])) | int * 100/4 | round(2) > 99  }}'
    - condition: state
      entity_id: switch.chargerplug
      state: 'on'
    - entity_id: switch.chargerplug
      service: switch.turn_off

iv checked that {{states.switch.chargerplug.state == 'on' }} is true in the Templates under developer tools, im not sure what else to try.