Remote-command_line: relieve some pains of command_line and shell_command

This is an “extension” of the builtin command_line integration.

Besides the functionalities of the hereabove, it also:

  • allow to disable polling altogether, relying on homeassistant.update_entity to trigger updates of the sensors
  • helps for remote connections via SSH

Additionally, it implements the functionalities of the shell_command service, with the added capability to specify a timeout value.

The integration is configured via YAML only.

Examples:

- platform: remote_command_line
  name: HA image version
  scan_interval:
    days: 1
  ssh_user: user
  command: >
    IMAGE=`docker inspect home-assistant | jq -r '.[0].Config.Image'`; docker image inspect ${IMAGE} | jq -r '.[0].ContainerConfig.Labels["io.hass.version"]'

- platform: remote_command_line
  name: Fetch HA Image
  ssh_user: user
  command_timeout: 900
  polling: false
  command: >
    IMAGE=`docker inspect home-assistant | jq -r '.[0].Config.Image'`; docker pull -q ${IMAGE} > /dev/null

Example of service:

remote_command_line:
  fetch_ha_image:
    ssh_user: user
    command_timeout: 900
    command: >
        IMAGE=`docker inspect home-assistant | jq -r '.[0].Config.Image'`; docker pull -q ${IMAGE}

See GitHub - koying/ha-remote-command-line: HA: Remote version of command_line (SSH) for more

2 Likes