Reuse sensor value result in command_line - Variable


I am looking for a way to store the output of externalip (see below) in a variable I can reuse in the below command line to exchange the dynamic external ip with what is currently hardcoded as

Or even better to somehow use externalip as a variable in command:

Is there an easy solution for this?


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

Well, you have a sensor.externalip

You can do

    command: /bin/bash -c "(echo > /dev/tcp/{{ states('sensor.externalip') }}/44158) > /dev/null 2>&1 && echo ON || echo OFF"

1 Like