ESP Home deep sleep mqtt

Hi how do I configure deep sleep based on a certain condition.

I have a global variable called version.

globals:
   - id: version
     type: int
     restore_value: yes
     initial_value: '1'

And this is my mqtt setup:

mqtt:
  id: mqtt_client
  broker: !secret mqtt_broker
  username: !secret mqtt_user
  password: !secret mqtt_pass
  on_message:
    - topic: system/version
      then:
        - if:
            condition:
              lambda: |-
                return id(version) != atoi(x.c_str());
            then:
              - lambda: id(mqtt_client).publish("system/esp_log", x);
              - deep_sleep.prevent: deep_sleep_1
            else:
              - lambda: id(mqtt_client).publish("system/esp_log", x);
              - deep_sleep.enter:  deep_sleep_1
  birth_message:
    topic: soil_sensor/birthdisable
    payload: disable
  will_message:
    topic: soil_sensor/willdisable
    payload: disable

I have confirmed that system/version will return a string.

Also, nothing gets published to system/esp_log