Skip to content

Commit

Permalink
Add configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dfigus committed Aug 30, 2024
1 parent 2b3c5ec commit 2daf998
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 1 deletion.
56 changes: 56 additions & 0 deletions solarflow-control/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,59 @@ arch:
map:
- addon_config:rw
- share:rw
options:
dtu_type: "OpenDTU"
smartmeter_type: "Smartmeter"
full_charge_interval: 32
control_bypass: true
mqtt_host: ""
mqtt_user: ""
mqtt_password: ""
dtu_base_topic: "solar"
inverter_max_power: 2000
ahoydtu_inverter_id: "0"
sm_rapid_change_diff: 500
sm_zero_offset: 20
sm_shelly3em_base_topic: "shellies/shellyem3/"
min_charge_power: 125
max_discharge_power: 150
limit_inverter: true
max_inverter_limit: 800
min_inverter_limit: 10
discharge_during_daytime: false
sunrise_offset: 60
sunset_offset: 60
schema:
dtu_type: list(OpenDTU|AhoyDTU)
smartmeter_type: list(Smartmeter|PowerOpti|ShellyEM3)
product_id: str
device_id: str
full_charge_interval: int
control_bypass: bool
mqtt_host: str
mqtt_port: port?
mqtt_user: str?
mqtt_password: password?
dtu_base_topic: str
sf_inverter_channels: str
inverter_max_power: int?
opendtu_inverter_serial: str?
ahoydtu_inverter_id: int?
sm_rapid_change_diff: int?
sm_zero_offset: int?
sm_generic_base_topic: str?
sm_generic_cur_accessor: str?
sm_generic_total_accessor: str?
sm_poweropti_user: str?
sm_poweropti_password: password?
sm_shelly3em_base_topic: str?
min_charge_power: int?
max_discharge_power: int?
limit_inverter: bool?
max_inverter_limit: int?
min_inverter_limit: int?
discharge_during_daytime: bool?
latitude: float?
longitude: float?
sunrise_offset: int?
sunset_offset: int?
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/command/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: Solarflow Control
# Configures the config.ini for Solarflow Control
# ==============================================================================

declare dtu_type
declare smartmeter_type

declare product_id
declare device_id
declare full_charge_interval
declare control_bypass

declare mqtt_host
declare mqtt_port
declare mqtt_user
declare mqtt_password

declare dtu_base_topic
declare sf_inverter_channels
declare inverter_max_power

declare opendtu_inverter_serial
declare ahoydtu_inverter_id

declare sm_rapid_change_diff
declare sm_zero_offset
declare sm_generic_base_topic
declare sm_generic_cur_accessor
declare sm_generic_total_accessor

declare sm_poweropti_user
declare sm_poweropti_password

declare sm_shelly3em_base_topic

declare min_charge_power
declare max_discharge_power
declare limit_inverter
declare max_inverter_limit
declare min_inverter_limit
declare discharge_during_daytime
declare latitude
declare longitude
declare sunrise_offset
declare sunset_offset

bashio::log.info 'Updating Solarflow Control configuration...'

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

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

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

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

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

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

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

mqtt_port=$(bashio::config 'mqtt_port' '1883')
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

min_inverter_limit=$(bashio::config 'min_inverter_limit')
sed -i "s|<min_inverter_limit>|$min_inverter_limit|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

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

sunset_offset=$(bashio::config 'sunset_offset')
sed -i "s|<sunset_offset>|$sunset_offset|g" /solarflow/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-solarflow-control/run
Empty file.
1 change: 0 additions & 1 deletion solarflow-control/rootfs/solarflow/config.ini

This file was deleted.

91 changes: 91 additions & 0 deletions solarflow-control/rootfs/solarflow/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[global]
# DTY Type: either OpenDTU or AhoyDTU
dtu_type = <dtu_type>
# Smartmeter Type: either Smartmeter (generic, Tasmota, Hichi, ...), PowerOpti, ShellyEM3
smartmeter_type = <smartmeter_type>

[solarflow]
# The product ID specifies the model of Solarflow hub to use: Hub-1200: "73bkTV" Hub-2000: "A8yh63"
# defaults to 73bkTV
product_id = <product_id>
# The device ID of your Solarflow Hub (typically 8 characters), you can get these either with solarflow-bt-manager or the solarflow-statuspage
device_id = <device_id>

# The time interval in hours that solarflow-control will try to ensure a full battery
# (i.e. no discharging if battry hasn't been at 100% for this long)
full_charge_interval = <full_charge_interval>

# Let solarflow-control take over enabling/disabling the bypass of the hub (direct solarinput to hub output when battery is full)
# this overrides the automatic switching by the hub's firmware, which is sometimes a bit wierd
control_bypass = <control_bypass>

[mqtt]
# Your local MQTT host configuration
mqtt_host = <mqtt_host>
mqtt_port = <mqtt_port>
mqtt_user = <mqtt_user>
mqtt_pwd = <mqtt_password>

[opendtu]
# The MQTT base topic your OpenDTU reports to (as configured in OpenDTU UI)
base_topic = <dtu_base_topic>
# your Inverters serial number
inverter_serial = <opendtu_inverter_serial>

# List of indices of the inverter channels/ports (as reported in the DTU) that the Solarflow Hub is connected to
# typically the index starts at 1 as 0 is the output channel of the inverter
# e.g. 1,3 or 3 or [1,3]
sf_inverter_channels = <sf_inverter_channels>

[ahoydtu]
# The MQTT base topic your AhoyDTU reports to (as configured in AhoyDTU UI)
base_topic = <dtu_base_topic>
# The inverter ID in AhoyDTU: typically 1 for the first inverter
inverter_id = <ahoydtu_inverter_id>
# List of indices of the inverter channels/ports (as reported in the DTU) that the Solarflow Hub is connected to
# typically the index starts at 1 as 0 is the output channel of the inverter
# e.g. 1,3 or 3 or [1,3]
sf_inverter_channels = <sf_inverter_channels>

# the max output power of your inverter, used to calculate correct absolute values
inverter_max_power = <inverter_max_power>

# The name of the inverter in AhoyDTU
#inverter_name = AhoyDTU

[smartmeter]
# rapid change difference defines the difference in W that has to be detected on the smartmeter readings to consider it a fast drop or rise in demand.
# this helps a faster adjustment in switching various limits e.g. when a water boiler is turned on/off
rapid_change_diff = <sm_rapid_change_diff>
zero_offset = <sm_zero_offset>

# The MQTT base topic your Hichi, Tasmota, generic smartmeter reader reports to
base_topic = <sm_generic_base_topic>
# if the published value at the base_topic is a JSON type then these accessors are used to get the power values
# e.g. if Smartmeter reader posts { "Power": {"Power_curr": 120, "Total_in": 12345.6} }
cur_accessor = <sm_generic_cur_accessor>
total_accessor = <sm_generic_total_accessor>

[poweropti]
# Username and password for you Powerfox API to get readings (internet connection required)
poweropti_user = <sm_poweropti_user>
poweropti_password = <sm_poweropti_password>

[shellyem3]
# The MQTT base topic your Shelly 3EM (Pro) is posting it's telemetry data to
# Note: you have to configure your Shelly to use MQTT
base_topic = <sm_shelly3em_base_topic>

[control]
min_charge_power = <min_charge_power>
max_discharge_power = <max_discharge_power>
discharge_during_daytime = <discharge_during_daytime>
max_inverter_limit = <max_inverter_limit>
limit_inverter = <limit_inverter>
inverter_min_limit = <min_inverter_limit>
# Geolocation LAT/LNG
latitude = <latitude>
longitude = <longitude>
# Offset in minutes after sunrise/before sunset. Can be used to set the duration of what is considered "night"
sunrise_offset = <sunrise_offset>
sunset_offset = <sunset_offset>
Loading

0 comments on commit 2daf998

Please sign in to comment.