#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start ReGaHss service
# ==============================================================================
# Wait until interfaces are initialized
bashio::log.info "Wait until HMServer is setup"
bashio::net.wait_for 9292

# Reset Regahss
if bashio::config.true "regahss_reset"; then
    bashio::log.warning "Reset ReGaHss"
    rm -f /data/homematic.regadom
    touch /data/homematic.regadom
fi

# Start Regahss
bashio::log.info "Starting ReGaHss..."
exec "${HM_HOME}/bin/ReGaHss" -c -f /etc/config/rega.conf
