Command Line Sensor + Sensor Value as variable

Hi,

I am trying to Implement a command line sensor which checks if a specific port of my external IP is open or closed.

I already implemented the following command line sensor which checks it for an internal IP and it works great:

  - platform: command_line
    name: linxdot_portcheck
    command: /bin/bash -c "(echo > /dev/tcp/192.168.178.39/44158) > /dev/null 2>&1 && echo ON || echo OFF"
    value_template: '{{ value }}'

The external IP get via:

  - platform: dnsip
    name: externalip

which also works great. No I would like to combine the two with somethings like this where the IP is replaced by the value of sensor.externalip:

  - platform: command_line
    name: linxdot_portcheck
    command: /bin/bash -c "(echo > /dev/tcp/SENSOR.EXTERNALIP/44158) > /dev/null 2>&1 && echo ON || echo OFF"
    value_template: '{{ value }}'

Is this even possible? If yes, does anybody know how I need to quote it that it will work?

Thanks,
Thomas