diff --git a/sources/inverter-mqtt/entrypoint.sh b/sources/inverter-mqtt/entrypoint.sh index 2bd26c5..f613421 100755 --- a/sources/inverter-mqtt/entrypoint.sh +++ b/sources/inverter-mqtt/entrypoint.sh @@ -7,9 +7,44 @@ echo "" # Configuration paths CONF_FILE="/etc/inverter/inverter.conf" +MQTT_CONF="/etc/inverter/mqtt.json" DISCOVERY_FLAG="/etc/inverter/.discovery_done" TEMP_CONF="/tmp/inverter_discovered.conf" +# Ensure config files exist (copy defaults if missing due to empty volume mount) +if [ ! -f "$CONF_FILE" ]; then + echo "⚠ inverter.conf not found, creating default..." + cat > "$CONF_FILE" << 'EOF' +# Basic configuration options for the actual inverter polling process... +device=/dev/ttyUSB0 +run_interval=120 +amperage_factor=1.0 +watt_factor=1.01 +qpiri=103 +qpiws=40 +qmod=5 +qpigs=110 +EOF +fi + +if [ ! -f "$MQTT_CONF" ]; then + echo "⚠ mqtt.json not found, creating default..." + cat > "$MQTT_CONF" << 'EOF' +{ + "server": "192.168.1.37", + "port": "1883", + "topic": "homeassistant", + "devicename": "voltronic", + "username": "", + "password": "", + "clientid": "voltronic_default", + "influx": { + "enabled": "false" + } +} +EOF +fi + # Environment variables with defaults INVERTER_DEVICE="${INVERTER_DEVICE:-/dev/ttyUSB0}" FORCE_DISCOVERY="${FORCE_DISCOVERY:-false}"