Command Line Binary Sensor

The command_line binary sensor platform issues specific commands to get data.

To use your Command binary sensor in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
  - platform: command_line
    command: cat /proc/sys/net/ipv4/ip_forward

Configuration variables:

  • command (Required): The action to take to get the value.
  • name (Optional): Let you overwrite the the name of the device. By default name from the device is used.
  • sensor_class (Optional): The type/class of the sensor to set the icon in the frontend.
  • payload_on (Optional): The payload that represents enabled state. Default is “ON”.
  • payload_off (Optional): The payload that represents disabled state. Default is “OFF”.
  • value_template (Optional): Defines a template to extract a value from the payload.


In this section you find some real life examples of how to use this sensor.


Check the state of an SickRage instance.

# Example configuration.yaml entry
  - platform: command_line
    command: netstat -na | find "33322" | find /c "LISTENING" > nul && (echo "Running") || (echo "Not running")
    name: 'sickragerunning'
    sensor_class: moving
    payload_on: "Running"
    payload_off: "Not running"

Check RasPlex

Check if RasPlex is online.

  - platform: command_line
    command: 'ping -c 1 rasplex.local | grep "1 received" | wc -l'
    name: 'is_rasplex_online'
    sensor_class: connectivity
    payload_on: 1
    payload_off: 0

An alternative solution could look like this:

  platform: command_line
  name: Printer
  command: ping -c 1 &> /dev/null && echo success || echo fail
  sensor_class: connectivity
  payload_on: "success"
  payload_off: "fail"