#Detect PC enabled using ssh banner fetching using netcat

1 messages · Page 1 of 1 (latest)

fading peak
#
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Include automations, scripts, and scenes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Enable Wake-on-LAN integration
wake_on_lan:

binary_sensor:
  - platform: command_line
    name: "johpc_online"
    command: 'nc -w 3 192.168.178.165 22'
    value_template: >-
      {{ 'SSH' in value }}
    scan_interval: 30


# Template switch to control the PC
switch:
  - platform: template
    switches:
      johpc:
        friendly_name: "johpc"
        value_template: "{{ is_state('binary_sensor.johpc_online', 'on') }}"
        turn_on:
          service: wake_on_lan.send_magic_packet
          data:
            mac: "9C:6B:00:8E:1C:88"
        turn_off:
          service: pyscript.shutdown_pc

Manually running the command does work.

runic ocean
#

Note that you're executing this command in the context of the File Editor addon, not HA. Test in inside the HA container. Perhaps also test a full path to the binary.
I'm not totally sure but that syntax might also be outdated.