Help passing variables to a condition template in a script

I am have trouble with the following script in which I try to pass variables to it. The condition value_template line is giving invalid config. Any suggestions would be helpful, thanks…

  offevents:
    sequence:
      - condition: template
        data_template:
          value_template: "{% if is_state( ~ newstate ~ ,  ~ senstate ~ ) %}"
      - service: mqtt.publish
        data_template:
          topic: "mac/[num]/state"
          payload_template: |
            {{ states.sensor.e[num].state}}{{ states.sensor.time.state}}

SOLVED: this doesn’t give errors

  offevents:
    sequence:
      - condition: template
        value_template: '{{ [ newstate ] == [ senstate ] }}'

I am now having problem with the mqtt publish part of the script receiving the variables. Does anyone know how to write this part to pass the num variable.

  - service: mqtt.publish
    data_template:
      topic: "mac/[num]/state"
      payload_template: |
        {{ states.sensor.e[num].state}}{{ states.sensor.time.state}}