Skip to content
SSH Generic Sensor
Python
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
custom_components/ssh Moved requirements to manifest.json Jul 23, 2019
LICENSE Initial commit Oct 26, 2018
README.md Update README.md Jul 23, 2019
info.md Update info.md Jul 23, 2019
resources.json Create resources.json May 21, 2019

README.md

sensor.ssh

Generic SSH based sensor for Home Assistant

Version mantained forum

Login to a remote server via ssh, execute a command and retrieve the result as sensor value

To get started download

/custom_components/ssh/__init__.py
/custom_components/ssh/sensor.py

into

<config directory>/custom_components/ssh/

Example configuration.yaml:

sensor:
  - platform: ssh
      host: !secret proxmox_host
      name: 'NUC CPU Temp'
      username: !secret proxmox_user
      password: !secret proxmox_pass
      command: "sensors | grep 'Package id 0:' | cut -c17-20"
      value_template: >-
        {%- set line = value.split("\r\n") -%}
        {{ line[1] }}
      unit_of_measurement: "ºC"

Configuration Variables

name

(string)(Optional) Friendly name of the sensor

host

(string)(Required) The hostname or IP address of the remote server

username

(string)(Required) A user on the remote server

password

(string)(Required) The password for the account

port

(integer)(Optional) The port to ssh to Default value: 22

command

(string)(Required) The command to execute on the remote server

Considerations

The sensor utilises the pexpect library https://pexpect.readthedocs.io/en/stable/ which mimics a user logging into the remote server via ssh. This results in the output being formatted as output from a tty terminal. Check out the pexecpt documentation for the oddities this causes.

A sensor value can only by a maximum of 256 characters in length, therefore make use of the value_template to parse data larger than this.

You can’t perform that action at this time.