This commit is contained in:
Hans Karlinius
2024-12-01 05:20:27 +01:00
parent ce84af66b0
commit e56df7db03
3 changed files with 11 additions and 11 deletions

View File

@@ -3,8 +3,7 @@
if bashio::config.has_value 'autofind'; then
autofind=($(bashio::config 'autofind'))
bashio::log.info "Set AUTOFIND hub to ${autofind}"
#if [ "${autofind}" = "true" ]; then
if $autofind; then
if [ "${autofind}" = "true" ]; then
/usr/bin/vh_edit_config General AutoFind 1
else
/usr/bin/vh_edit_config General AutoFind 0
@@ -19,13 +18,12 @@ fi
if bashio::config.has_value 'manualhub'; then
manualhub=($(bashio::config 'manualhub'))
bashio::log.info "Set HUB to ${manualhub}"
bashio::log.info "MANUAL HUB ADD,${manualhub}"
/usr/bin/vhclient -t "MANUAL HUB ADD,${manualhub}"
fi
if bashio::config.has_value 'autouse'; then
autouse=($(bashio::config 'autouse'))
bashio::log.info "Set AUTOUSE all devices to ${autouse}"
if [ "${autouse}" = "true" ]; then
bashio::log.info "AUTO USE ALL"
/usr/bin/vhclient -t "AUTO USE ALL"

View File

@@ -2,7 +2,7 @@
#set -x
bashio::log.info "Adding selected devices"
#bashio::log.info "Adding selected devices"
if bashio::config.has_value 'usbdevices'; then
#usbdevices=($(bashio::config 'usbdevices'))
@@ -12,19 +12,21 @@ if bashio::config.has_value 'usbdevices'; then
usbdevices_json=$(echo $options | jq -c '.usbdevices[]')
readarray -t usbdevices < <(echo "$usbdevices_json")
bashio::log.info "Devices: ${usbdevices[@]}"
mapfile -t devices < <(/usr/bin/vh_list_inuse_devices)
mapfile -t inuse_devices < <(/usr/bin/vh_list_inuse_devices)
bashio::log.info "Inuse devices: ${inuse_devices[@]}"
for usbdevice in "${usbdevices[@]}"; do
use=$(echo $usbdevice | jq '. | if .use then true else false end')
device=$(echo $usbdevice | jq '.device | tostring')
deviceid=$(echo $device | sed 's/.*(\(.*\)).*/\1/g')
bashio::log.info "Use: ${use} Device: ${device} Deviceid: ${deviceid}"
#bashio::log.info "Use: ${use} Device: ${device} Deviceid: ${deviceid}"
if $use; then
bashio::log.info "AUTO USE DEVICE,${deviceid}"
/usr/bin/vhclient -t "AUTO USE DEVICE,${deviceid}"
else
bashio::log.info "STOP USING,${deviceid}"
#/usr/bin/vhclient -t "STOP USING,${deviceid}"
if [[ "${inuse_devices[@]}" =~ "$device" ]]; then
bashio::log.info "STOP USING,${deviceid}"
#/usr/bin/vhclient -t "STOP USING,${deviceid}"
fi
fi
done
fi