Hey guys,
I have been tinkering a while with hass and I am trying to find a solution to detect the status of my setupbox through netcat and the commandline sensor. So when I SSH into my pi (with HASSbian) I can run the following code with succes:
nc -zv [ip adress] [port] &> /dev/null; echo $?
When the setupbox is in standby it returns 1 and when it’s on it returns 0, all working like it should!
Now when I use this command in a commandline sensor, it always returns the value 0… I have tried several other parameters with the netcat command and value templating, but I can’t get it to work.
Commandline sensor:
`#Will output 0 if port x is open, and 1 if it’s closed.
- platform: command_line
name: Horizonbox netcat echo
command: nc -zv 192.168.2.12 62137 &> /dev/null; echo $?
scan_interval: 10`
Do you guys have any idea what is going wrong? If there is a better solution to this problem than with netcat, I would love to hear that too!
Best regards,
Nick