Skip to content

Commit

Permalink
Merge pull request #43 from dfigus/fix-lat-long-replacements
Browse files Browse the repository at this point in the history
Fix latitude & longitude replacements
  • Loading branch information
dfigus authored Dec 20, 2024
2 parents 29509e0 + 89507aa commit 6c82a32
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare mqtt_host
declare mqtt_port
declare mqtt_user
declare mqtt_password
declare mqtt_escaped_password

declare dtu_base_topic
declare sf_inverter_channels
Expand Down Expand Up @@ -83,7 +84,8 @@ sed -i "s|<mqtt_port>|$mqtt_port|g" /solarflow/config.ini
mqtt_user=$(bashio::config 'mqtt_user')
sed -i "s|<mqtt_user>|$mqtt_user|g" /solarflow/config.ini
mqtt_password=$(bashio::config 'mqtt_password')
sed -i "s|<mqtt_password>|$mqtt_password|g" /solarflow/config.ini
mqtt_escaped_password=$(printf '%s\n' "$mqtt_password" | sed 's/[]\/$*.^[]/\\&/g')
sed -i "s|<mqtt_password>|$mqtt_escaped_password|g" /solarflow/config.ini

dtu_base_topic=$(bashio::config 'dtu_base_topic')
sed -i "s|<dtu_base_topic>|$dtu_base_topic|g" /solarflow/config.ini
Expand Down Expand Up @@ -148,11 +150,19 @@ sed -i "s|<max_inverter_input>|$max_inverter_input|g" /solarflow/config.ini
discharge_during_daytime=$(bashio::config 'discharge_during_daytime')
sed -i "s|<discharge_during_daytime>|$discharge_during_daytime|g" /solarflow/config.ini

latitude=$(bashio::config 'latitude' ' ')
sed -i "s|<latitude>|$latitude|g" /solarflow/config.ini

longitude=$(bashio::config 'longitude' ' ')
sed -i "s|<longitude>|$longitude|g" /solarflow/config.ini
if bashio::config.has_value 'latitude'; then
latitude=$(bashio::config 'latitude' ' ')
sed -i "s|<latitude>|$latitude|g" /solarflow/config.ini
else
sed -i "/<latitude>/c\#latitude" /solarflow/config.ini
fi

if bashio::config.has_value 'longitude'; then
longitude=$(bashio::config 'longitude' ' ')
sed -i "s|<longitude>|$longitude|g" /solarflow/config.ini
else
sed -i "/<longitude>/c\#longitude" /solarflow/config.ini
fi

sunrise_offset=$(bashio::config 'sunrise_offset')
sed -i "s|<sunrise_offset>|$sunrise_offset|g" /solarflow/config.ini
Expand Down

0 comments on commit 6c82a32

Please sign in to comment.