homeassistant-ssh icon indicating copy to clipboard operation
homeassistant-ssh copied to clipboard

Execution failed (Value of required sensor network_interface is None)

Open Yngve0 opened this issue 6 months ago • 5 comments

I try to set up a Unifi Express 7 with this plugin. I have done it earlier with Unifi Express and Unifi Dreamrouter without any issues.

But when I know to try set up a new unifi Express 7 it reports:

Execution failed (Value of required sensor network_interface is None)

I have the errormessage when I try to reconfigure one of my existing Unifi units.

How can this be solved?

Yngve0 avatar Jun 18 '25 18:06 Yngve0

Same issue for me

johntdyer avatar Jun 20 '25 16:06 johntdyer

Turns out this was the Default commands setting, changing this to None allowed me to create the integration

Image

johntdyer avatar Jun 20 '25 18:06 johntdyer

Hi, thanks a lot for reporting this! You are right, it would be better to allow the setup to complete, even if one of the default commands fails. I will change this in the next update. As a workaround you can select None as default commands and then copy the following commands into your device config (probably you want to modify/delete the network_interface and wake_on_lan sensor commands):

Action commands

- command: /sbin/shutdown -h now
  name: Turn off
  key: turn_off
- command: /sbin/shutdown -r now
  name: Restart
  key: restart

Sensor commands

- command: >-
    x=$(/sbin/ip route show default 2>/dev/null) && echo "$x" | awk '{print $5}'
    || x=$(/sbin/route -n 2>/dev/null) && echo "$x" | awk '/^0.0.0.0/ {print
    $NF}'
  sensors:
    - type: text
      name: Network interface
      key: network_interface
- command: cat /sys/class/net/&{network_interface}/address
  sensors:
    - type: text
      name: MAC address
      key: mac_address
- command: cat /sys/class/net/&{network_interface}/device/power/wakeup
  sensors:
    - type: binary
      name: Wake on LAN
      key: wake_on_lan
- command: uname -n
  sensors:
    - type: text
      name: Hostname
      key: hostname
- command: uname -m
  sensors:
    - type: text
      name: Machine type
      key: machine_type
- command: uname -s
  sensors:
    - type: text
      name: OS name
      key: os_name
- command: uname -r
  sensors:
    - type: text
      name: OS version
      key: os_version
- command: (. /etc/os-release && echo "$PRETTY_NAME")
  sensors:
    - type: text
      name: OS release
      key: os_release
- command: >-
    x=$(/sbin/dmidecode -t system 2>/dev/null) && echo "$x" | awk -F ": "
    '/Product Name:/ {a=$2} /Version:/ {b=$2} /Manufacturer:/ {c=$2} /Serial
    Number:/ {d=$2} END {print a"\n"b"\n"c"\n"d}'
  sensors:
    - type: text
      name: Device name
      key: device_name
    - type: text
      name: Device model
      key: device_model
    - type: text
      name: Manufacturer
      key: manufacturer
    - type: text
      name: Serial number
      key: serial_number
- command: >-
    cat /proc/cpuinfo | awk -F ": " '/^model name/ {a=$2} /^processor/ {b=$2+1}
    /^Hardware/ {c=$2} /^Model/ {d=$2} END {print a"\n"b"\n"c"\n"d}'
  sensors:
    - type: text
      name: CPU name
      key: cpu_name
    - type: number
      name: CPU cores
      key: cpu_cores
    - type: text
      name: CPU hardware
      key: cpu_hardware
    - type: text
      name: CPU model
      key: cpu_model
- command: cat /proc/meminfo | awk '/MemTotal/ {print $2}'
  sensors:
    - type: number
      name: Total memory
      key: total_memory
      unit_of_measurement: KiB
- command: cat /proc/meminfo | awk '/MemFree/ {print $2}'
  scan_interval: 30
  sensors:
    - type: number
      name: Free memory
      key: free_memory
      unit_of_measurement: KiB
- command: >-
    x=$(df -k) && echo "$x" | awk '/^\/dev\// {b=$4; $1=$2=$3=$4=$5=""; gsub(/^
    +/, ""); print $0"|"b}'
  scan_interval: 60
  separator: "|"
  sensors:
    - type: number
      name: Free disk space
      key: free_disk_space
      dynamic: true
      unit_of_measurement: KiB
- command: >-
    read _ u n s i w q o t _ < /proc/stat; i1=$((i+w)); t1=$((u+n+s+q+o+t+i1));
    sleep 1; read _ u n s i w q o t _ < /proc/stat; i2=$((i+w));
    t2=$((u+n+s+q+o+t+i2)); id=$((i2-i1)); td=$((t2-t1)); echo
    $((100*(td-id)/td))
  scan_interval: 30
  sensors:
    - type: number
      name: CPU load
      key: cpu_load
      unit_of_measurement: "%"
- command: >-
    for x in /sys/class/thermal/thermal_zone*; do echo "$(cat $x/type),$(($(cat
    $x/temp)/1000))"; done
  scan_interval: 60
  separator: ","
  sensors:
    - type: number
      name: Temperature
      key: temperature
      dynamic: true
      unit_of_measurement: °C
- command: printf '%s\n' /proc/[0-9]* | wc -l
  scan_interval: 60
  sensors:
    - type: number
      name: Processes
      key: processes

zhbjsh avatar Jun 22 '25 06:06 zhbjsh

happened to me as well, target machine runs nixos, which is non-FHS, meaning the seemingly hardcoded lookup for the e.g. /sbin/shutdown binary will not find it, and therefore error.

that's why we have trusted, reliable /usr/bin/env

maybe that'll fix it

martyTF avatar Jul 09 '25 03:07 martyTF

additionally, it probably assumes that bash is the default shell, many of the sensor commands don't work for me, as fish has different syntax, especially with variables

- command: >-
    set x (/usr/bin/env ip route show default 2>/dev/null) && echo "$x" | awk '{print $5}' ||
    set x (/usr/bin/env route -n 2>/dev/null) && echo "$x" | awk '/^0.0.0.0/ {print $NF}'
  sensors:
    - type: text
      name: Network interface
      key: network_interface

is what got the first sensor working for me, using fish on nixos

martyTF avatar Jul 09 '25 03:07 martyTF