Vmware + when clause in Ansible

Hi

I am not able to use the Vm Poweredoff status in my when clause.

Can anyone tell me how to fix it.

- name: "Collecting Vmware Guest Facts"
  hosts: localhost

  vars:
    msg: |
         {{ value.instance.hw_power_status }}

  tasks:
    - name: Gathering Facts
      vmware_guest_facts:
        hostname: 192.168.119.129
        username: root
        password: xxxxxxx
        datacenter: vntgautvol-64.localdomain
        uuid: 564d6556-765a-d5eb-dcc9-711988d1e157
        validate_certs: no

      register: value

    - debug:
        msg: "Vm_Power_status: {{ msg[:-1] }}"

    - name: Checking some value
      command: echo vm is "{{ msg }}"
      register: val

      when: msg == "poweredOff"

Error::-

TASK [Checking some value] *************************************************************************************
task path: /root/ansible/facts.yml:27
skipping: [localhost] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}

output ::-
-----------
TASK [debug] ***************************************************************************************************
task path: /root/ansible/facts.yml:24
ok: [localhost] => {
    "msg": "Vm_Power_status: poweredOff"
}


 ],
        "hw_is_template": false,
        "hw_memtotal_mb": 1024,
        "hw_name": "Test",
        "hw_power_status": "poweredOff",
        "hw_processor_count": 1,
        "hw_product_uuid": "564d6556-765a-d5eb-dcc9-711988d1e157",
        "hw_version": "vmx-14",
        "instance_uuid": "52d54b23-b8c1-3a2f-e9e3-7fb1424f40a8",
        "ipv4": null,
        "ipv6": null,
        "module_hw": true,
        "snapshots": []