Skip to content

Commit

Permalink
update run.sh of main ha addon to include the update interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Andreas committed Apr 14, 2024
1 parent 867f31c commit 2aa0480
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
22 changes: 11 additions & 11 deletions ha-hoymiles-wifi-addon-nightly/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ DEBUG_LOGGING=${DEBUG_LOGGING:-'false'}

# Check if the required configs are provided
if [[ -z "$INVERTER_HOST" ]]; then
echo "The inverter_host is not configured."
exit 1
echo "The inverter_host is not configured."
exit 1
fi

if [[ -z "$MQTT_BROKER_HOST" ]]; then
echo "The mqtt_broker_host is not configured."
exit 1
echo "The mqtt_broker_host is not configured."
exit 1
fi

# print a warning if update interval is > 30500
if [[ "$UPDATE_INTERVAL" -gt 30500 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "The update_interval is set to a value greater than 30500."
echo "This is not recommended and may cause the inverter to become unresponsive."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
# print a warning if update interval is < 60500
if [[ "$UPDATE_INTERVAL" -lt 60500 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "The update_interval is set to a value lower than 60500."
echo "This is not recommended and may cause the inverter to become unresponsive."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi

# Create the configuration file
Expand All @@ -56,7 +56,7 @@ EOF

# if DEBUG_LOGGING is true, set the RUST_LOG=debug environment variable to enable debug logging
if [[ "$DEBUG_LOGGING" == "true" ]]; then
export RUST_LOG=debug
export RUST_LOG=debug
fi

# Execute the application
Expand Down
20 changes: 15 additions & 5 deletions ha-hoymiles-wifi-addon/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MQTT_BROKER_HOST=$(bashio::config 'mqtt_broker_host')
MQTT_USERNAME=$(bashio::config 'mqtt_username')
MQTT_PASSWORD=$(bashio::config 'mqtt_password')
MQTT_PORT=$(bashio::config 'mqtt_port')
UPDATE_INTERVAL=$(bashio::config 'update_interval')
DEBUG_LOGGING=$(bashio::config 'debug_logging')

# Use bashio::config values if they are defined, otherwise fall back to bashio::services values
Expand All @@ -24,18 +25,27 @@ DEBUG_LOGGING=${DEBUG_LOGGING:-'false'}

# Check if the required configs are provided
if [[ -z "$INVERTER_HOST" ]]; then
echo "The inverter_host is not configured."
exit 1
echo "The inverter_host is not configured."
exit 1
fi

if [[ -z "$MQTT_BROKER_HOST" ]]; then
echo "The mqtt_broker_host is not configured."
exit 1
echo "The mqtt_broker_host is not configured."
exit 1
fi

# print a warning if update interval is < 60500
if [[ "$UPDATE_INTERVAL" -lt 60500 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "The update_interval is set to a value lower than 60500."
echo "This is not recommended and may cause the inverter to become unresponsive."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi

# Create the configuration file
cat <<EOF > ./config.toml
inverter_host = "$INVERTER_HOST"
update_interval = $UPDATE_INTERVAL
[home_assistant]
host = "$MQTT_BROKER_HOST"
Expand All @@ -46,7 +56,7 @@ EOF

# if DEBUG_LOGGING is true, set the RUST_LOG=debug environment variable to enable debug logging
if [[ "$DEBUG_LOGGING" == "true" ]]; then
export RUST_LOG=debug
export RUST_LOG=debug
fi

# Execute the application
Expand Down

0 comments on commit 2aa0480

Please sign in to comment.