SSH Integration - Connect your servers to Home Assistant

Hi,

Just wanted to say that this is a great add-on. I have been trying to perform actions and update sensors from my ZFS Server to no avail.
Then I stumbled upon this and had my sensors up and running within minutes.

Fantastic,
Much appreciated

Yay, this is exactly what I was looking for! Thanks a lot for the add-on, I love it! :slight_smile:

This integration really hits a sweet spot! I’m using it for some parent work - checking and setting TimeKPR time budgets for my kids’ laptops and workstations (okay, typically “play”-stations).

One thing I didn’t get to work out: I’ve got a controllable sensor for “time left”. However, timekpr gives me times in seconds - and I’d like (my wife) to be able to enter times in minutes. I tried using @{value * 60} and tinkered with templates but to no real avail. There’s probably a simple solution… could anyone help?

Just discovered this integration and I’m very excited to use it, as it will solve one of my long lasting problems - quick turning on/off port forwarding on my router, that can only be done either via GUI (requires to expose it to internet :frowning: ) or via SSH CLI, that is troublesome due to login requirement…
So I installed integration and configured my router as first device… and got stuck. Not really sure how to configure properly this integration to perform what I want.

Command to turn on appropriate open port policy on my router is:
srv nat openport 1 1 -a 1

To turn it it off:
srv nat openport 1 1 -a 0

To get state of policy I use:
srv nat openport 1 1 -v

and it provides output:

%% Status: Disable
%% Comment: Remote Desktop
%% WAN Interface: WAN1
%% Private IP address: 192.168.52.32
%% Source ip type: 0
%% Source ip idx: 0
Index   Protocal        Start Port      End Port
*****************************************************************
  1.    TCP/UDP         3389            3389
  2.    TCP/UDP         0               0
  3.    TCP/UDP         0               0
  4.    TCP/UDP         0               0
  5.    TCP/UDP         0               0
  6.    TCP/UDP         0               0
  7.    TCP/UDP         0               0
  8.    TCP/UDP         0               0
  9.    TCP/UDP         0               0
  10.   TCP/UDP         0               0

So based on this information I created following configuration for my router, within SSH integration:
Action commands:

- command: srv nat openport 1 1 -a 1
  name: Turn RDP On
- command: srv nat openport 1 1 -a 0
  name: Turn RDP Off

and sensor command:

- command: srv nat openport 1 1 -v
  sensors:
    - type: text
      name: RDP State
      value_template: "{{ value.split(': ')[1] }}"

Value template might require some tuning, but for now should be sufficient to get Disable or Enable values.
But none of these does not work. As I look for Router device state it shows all of these entities unavailable:


So seems that while network connection and SSH connection to Router works fine, none of defined actions works… Waht am I doing wrong here?

Have you tried the full path to the srv command?

What you mean by full path? This is exactly what I enter in router console, when connecting from terminal.

If you type find / -name srv what path does it say. Probably /usr/sbin/srv or something

This is not Linux based router, but using custom operating system (DrayOS), so its CLI does not accept any commands, but these defined to manage device… Nor, it accepts path in commands. I’m limited to:

HOME-ROUTER> ?
% Valid commands are:
csm           ddns          dos           exit          internet      ip
ipf           log           ldap          tacacsplus    mngt          msubnet
object        port          portmaptime   ppa           hwaccswap     prn
qos           hwqos         quit          show          smb           srv
switch        sys           testmail      fs            upnp          usb
vigbrg        fullbrg       vlan          vpn           wan           hsportal
radius        local_8021x   wol           user          appqos        nand
apm           sfp           ethoam        ha            swm           fw_backupmode
cert          service       dmn