Help sending manipulated sensor value to MQTT payload as if just a number

Hi, I’m trying to send a payload value over MQTT to control a device. This works absolutely fine if I simply specify an integer for the payload (e.g. payload: 8), but if I try and supply that integer via json so I can take the value from a sensor and manipulate it, it does not work.

Working code extract:

automation:
  - alias: Some name
    id: some_id
    initial_state: false
    trigger:
      platform: state
      entity_id: input_boolean.some_switch
      to: 'on'
    action:
      - service: mqtt.publish
        data:
          topic: 'openevse/rapi/in/$FS'
          retain: false
          payload: 8

What I want to do which does not work:

automation:
  - alias: Some name
    id: some_id
    initial_state: false
    trigger:
      platform: state
      entity_id: input_boolean.some_switch
      to: 'on'
    action:
      - service: mqtt.publish
        data:
          topic: 'openevse/rapi/in/$FS'
          retain: false
          payload: >-
           {{((states('sensor.some_sensor') | float) / ('0.25' | float)) | int}}

Any advice?!

Thanks,
Paul

OK, I’ve got it to work, but just through playing about other than understanding what it is doing!

This works:

    action:
      - service: mqtt.publish
        data_template:
          payload: "{{((states('sensor.some_seensorr')|float) / (('0.250')|float))|int}}"
          topic: openevse/rapi/in/$FS