Skip to content

Commit

Permalink
Polishing...
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaud Quette <[email protected]>
  • Loading branch information
aquette committed Dec 16, 2023
1 parent a04f50c commit aac4540
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion smartnut/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ For now:
* just start SmartNUT (for USB) and/or use enable enable_simulated_device,
* check the Journal tab for the startup sequence,
* listen on MQTT topic 'homeassistant/nut/#' using MQTT integration (FIXME),
* and have fun :D
* and have fun :smile:

## Configuration

Expand Down
13 changes: 8 additions & 5 deletions smartnut/rootfs/etc/cont-init.d/smartnut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if bashio::config.true 'autoconf_usb_devices' ;then

bashio::log.info "Autodetecting and configuring USB devices"
nut-scanner -U > "${UPS_CONF}"
bashio::log.info "=> OK"
fi

if bashio::config.true 'manual_edit_devices' ;then
Expand All @@ -33,7 +34,6 @@ if bashio::config.true 'manual_edit_devices' ;then
# FIXME: process manual edits
fi


if bashio::config.true 'enable_simulated_device' ;then
# https://networkupstools.org/docs/developer-guide.chunked/dev-tools.html

Expand All @@ -45,6 +45,7 @@ if bashio::config.true 'enable_simulated_device' ;then
echo -e "\tport = smartnut-dummy.seq"
} >> "${UPS_CONF}"

bashio::log.info "=> OK"
fi

# MQTT config
Expand Down Expand Up @@ -73,12 +74,14 @@ if [ -z "$MQTT_HOST"]; then
MQTT_PASSWORD=$(bashio::services mqtt "password")
fi

# FIXME: sanity check (-n MQTT_HOST MQTT_USER MQTT_PASSWORD) and error catching
# FIXME
# - ca: str?
# - key: str?
# - cert: str?

# FIXME: MQTT sanity check (-n MQTT_HOST MQTT_USER MQTT_PASSWORD) and error catching
bashio::log.info "=> OK"

# FIXME: get config...
{
echo "MQTT_HOST=$MQTT_HOST"
Expand All @@ -92,13 +95,13 @@ bashio::log.info "${UPS_CONF}"
cat "${UPS_CONF}"
bashio::log.info "/etc/nut/libnutdrv_mqtt.conf"
cat /etc/nut/libnutdrv_mqtt.conf
# FIXME: -s sanity check
bashio::log.info "=> OK"

bashio::log.info "---------------------"
bashio::log.info "Starting the SmartNUT Driver(s)..."
upsdrvctl -u root start
#/usr/lib/nut/usbhid-ups -u root -a nutdev1
sleep 5
bashio::log.info "Driver(s) started..."
bashio::log.info "=> OK"

bashio::log.info "---------------------"
bashio::log.info "Starting the SmartNUT2MQTT Adapter..."
Expand Down
7 changes: 3 additions & 4 deletions smartnut/rootfs/usr/bin/dstate-nut2mqtt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# File: dstate-nut2mqtt
# Version: 0.4
# Description
# Script that queries and parses data from NUT drivers Unix sockets (using netcat)
# Script that queries and parses data from NUT drivers Unix sockets (using netcat),
# then transform these into MQTT payload to publish (using mosquitto_pub)
# This technic:
# * just requires standard public NUT versions (source or binary packages)
Expand Down Expand Up @@ -148,9 +148,8 @@ process_dump()
}

# Main
echo "Starting `basename $0`"
echo "------------------------"
echo "CWD: `pwd`"
debug "Starting `basename $0`"
debug "------------------------"

# Setup context
# Cleanup
Expand Down

0 comments on commit aac4540

Please sign in to comment.