homeassistant-ssh: No longer able to pull data from OpenWRT

With the commands before 1.3.0, everything worked fine. After upgrading and resetting commands, this is how it shows up:

Image

This is what I found in logs:

2025-05-29 14:55:44.171 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): x=$(/sbin/ip route show default 2>/dev/null) && awk '{print $5}' <<<$x || x=$(/sbin/route -n 2>/dev/null) && awk '/^0.0.0.0/ {print $NF}' <<<$x => [], ['sh: syntax error: unexpected redirection'], 2
2025-05-29 14:55:44.171 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): network_interface => None
2025-05-29 14:55:44.172 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): cat /sys/class/net/&{network_interface}/address => Execution failed (Value of required sensor network_interface is None)
2025-05-29 14:55:44.172 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): mac_address => None
2025-05-29 14:55:44.227 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): x=$(/sbin/ip route show default 2>/dev/null) && awk '{print $5}' <<<$x || x=$(/sbin/route -n 2>/dev/null) && awk '/^0.0.0.0/ {print $NF}' <<<$x => [], ['sh: syntax error: unexpected redirection'], 2
2025-05-29 14:55:44.227 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): network_interface => None
2025-05-29 14:55:44.227 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): cat /sys/class/net/&{network_interface}/device/power/wakeup => Execution failed (Value of required sensor network_interface is None)
2025-05-29 14:55:44.227 DEBUG (MainThread) [custom_components.ssh] Camera do portão (SSH): wake_on_lan => None
2025-05-29 14:55:44.227 DEBUG (MainThread) [custom_components.ssh] Finished fetching Camera do portão (SSH) state data in 0.081 seconds (success: True)

Note that OpenWRT uses Busybox.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 29 (13 by maintainers)

Most upvoted comments

@felipecrs Thanks, that looks a lot cleaner then my CPU script! Didn’t have time to test it yet, but will do so the next days and then release the new version @tryingbe

@felipecrs Yes, the integration uses these sensors for the device info page and executes the commands every time SSH reconnects. They are disabled by default, as they are not very useful to show in the UI. If you don’t want them to ever execute, simply delete the commands from the configuration.

@felipecrs I added some more columns from /proc/stat to match the answer of this post:

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)) If something doesn’t work, let me know, otherwise I will use it like this. Thanks for the help!

This seems to be working great for me!

Also this one is great, will use it from now on!

printf '%s\n' /proc/[0-9]* | wc -l

You can also simplify the thermal one:

for d in /sys/class/thermal/thermal_zone*; do echo “$(cat $d/type),$(($(cat $d/temp)/1000))”; done

(there’s no need for ls)

Thanks, didn’t see that!

Thanks for the ideas man! I quite like the second one, let me do some tests… Probably I can release a fixed version on the weekend.