Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheSnowfield/8181049a4d29525b1792e5e9ac510d90 to your computer and use it in GitHub Desktop.
Save TheSnowfield/8181049a4d29525b1792e5e9ac510d90 to your computer and use it in GitHub Desktop.
Home Assistant: configuring command line sensor using yaml has moved.

Configuring command line sensor using yaml has moved, after Home Assistant 2023 update.
This gist is guiding you how to perform a quick fix.

The old style

configuration.yml:

binary_sensor: !include sensors.yaml

sensors.yml

- platform: command_line
  name: "Port Open"
  command: '/usr/bin/nmap -p<port> <ip> | /bin/grep open > /dev/null && (echo true) || (echo false)'
  device_class: connectivity
  payload_on: "true"
  payload_off: "false"

The quick fix

Just change 'binary_sensor' section to 'command_line' in your configuration.yml.

configuration.yml:

command_line: !include sensors.yaml

besides, replace 'platform: command_line' to 'binary_sensor:' the your sensors.yaml.

sensors.yaml

- binary_sensor:
  name: "Port Open"
  command: '/usr/bin/nmap -p<port> <ip> | /bin/grep open > /dev/null && (echo true) || (echo false)'
  device_class: connectivity
  payload_on: "true"
  payload_off: "false"

Every thing should be restored again. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment