Command line

Does anybody know if you can display the results of a command line command as a text card or sensor data in the HA front end? Basically I am trying to display the results of a filtered netstat command to see what if any foreign IP addresses are connected to my system. I tried the command line sensor component without success.

What exactly did you try? Can you post the YAML code?

Like any entity, its state is limited to 255 characters. Is it possible that you tried to grab too much output? Were there any errors that might shed light on what went wrong?

I tried the following code where column 5 is the foreign IP address column.

  • platform: command_line
    name: Pi Netstat
    command: watch -n 5 “netstat -ntu | awk ‘{print $5}’ | grep -v 10.0.1”
1 Like

There is no need to use watch, as HA calls the command periodically.

Also, can you explain how it didn’t work for you? Did you get errors, and if so, what were they? Did it just not display useful data?

But it seems likely the problem is due to using watch as @gpbenton suggests.