diff --git a/solarflow-control/config.yaml b/solarflow-control/config.yaml index 94f8c66..f88f5fa 100644 --- a/solarflow-control/config.yaml +++ b/solarflow-control/config.yaml @@ -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? diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/dependencies.d/base b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/run b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/run new file mode 100755 index 0000000..0cae110 --- /dev/null +++ b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/run @@ -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|g" /solarflow/config.ini + +smartmeter_type=$(bashio::config 'smartmeter_type') +sed -i "s||$smartmeter_type|g" /solarflow/config.ini + +device_id=$(bashio::config 'product_id') +sed -i "s||$device_id|g" /solarflow/config.ini + +device_id=$(bashio::config 'device_id') +sed -i "s||$device_id|g" /solarflow/config.ini + +full_charge_interval=$(bashio::config 'full_charge_interval') +sed -i "s||$full_charge_interval|g" /solarflow/config.ini + +control_bypass=$(bashio::config 'control_bypass') +sed -i "s||$control_bypass|g" /solarflow/config.ini + +mqtt_host=$(bashio::config 'mqtt_host') +sed -i "s||$mqtt_host|g" /solarflow/config.ini + +mqtt_port=$(bashio::config 'mqtt_port' '1883') +sed -i "s||$mqtt_port|g" /solarflow/config.ini + +mqtt_user=$(bashio::config 'mqtt_user') +sed -i "s||$mqtt_user|g" /solarflow/config.ini +mqtt_password=$(bashio::config 'mqtt_password') +sed -i "s||$mqtt_password|g" /solarflow/config.ini + +dtu_base_topic=$(bashio::config 'dtu_base_topic') +sed -i "s||$dtu_base_topic|g" /solarflow/config.ini + +sf_inverter_channels=$(bashio::config 'sf_inverter_channels') +sed -i "s||$sf_inverter_channels|g" /solarflow/config.ini + +inverter_max_power=$(bashio::config 'inverter_max_power') +sed -i "s||$inverter_max_power|g" /solarflow/config.ini + +opendtu_inverter_serial=$(bashio::config 'opendtu_inverter_serial') +sed -i "s||$opendtu_inverter_serial|g" /solarflow/config.ini + +ahoydtu_inverter_id=$(bashio::config 'ahoydtu_inverter_id') +sed -i "s||$ahoydtu_inverter_id|g" /solarflow/config.ini + +sm_rapid_change_diff=$(bashio::config 'sm_rapid_change_diff') +sed -i "s||$sm_rapid_change_diff|g" /solarflow/config.ini + +sm_zero_offset=$(bashio::config 'sm_zero_offset') +sed -i "s||$sm_zero_offset|g" /solarflow/config.ini + +sm_generic_base_topic=$(bashio::config 'sm_generic_base_topic') +sed -i "s||$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|g" /solarflow/config.ini + +sm_generic_total_accessor=$(bashio::config 'sm_generic_total_accessor' ' ') +sed -i "s||$sm_generic_total_accessor|g" /solarflow/config.ini + +sm_poweropti_user=$(bashio::config 'sm_poweropti_user' ' ') +sed -i "s||$sm_poweropti_user|g" /solarflow/config.ini + +sm_poweropti_password=$(bashio::config 'sm_poweropti_password' ' ') +sed -i "s||$sm_poweropti_password|g" /solarflow/config.ini + +sm_shelly3em_base_topic=$(bashio::config 'sm_shelly3em_base_topic') +sed -i "s||$sm_shelly3em_base_topic|g" /solarflow/config.ini + +min_charge_power=$(bashio::config 'min_charge_power') +sed -i "s||$min_charge_power|g" /solarflow/config.ini + +max_discharge_power=$(bashio::config 'max_discharge_power') +sed -i "s||$max_discharge_power|g" /solarflow/config.ini + +limit_inverter=$(bashio::config 'limit_inverter') +sed -i "s||$limit_inverter|g" /solarflow/config.ini + +max_inverter_limit=$(bashio::config 'max_inverter_limit') +sed -i "s||$max_inverter_limit|g" /solarflow/config.ini + +min_inverter_limit=$(bashio::config 'min_inverter_limit') +sed -i "s||$min_inverter_limit|g" /solarflow/config.ini + +discharge_during_daytime=$(bashio::config 'discharge_during_daytime') +sed -i "s||$discharge_during_daytime|g" /solarflow/config.ini + +latitude=$(bashio::config 'latitude' ' ') +sed -i "s||$latitude|g" /solarflow/config.ini + +longitude=$(bashio::config 'longitude' ' ') +sed -i "s||$longitude|g" /solarflow/config.ini + +sunrise_offset=$(bashio::config 'sunrise_offset') +sed -i "s||$sunrise_offset|g" /solarflow/config.ini + +sunset_offset=$(bashio::config 'sunset_offset') +sed -i "s||$sunset_offset|g" /solarflow/config.ini diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/type b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/up b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/up new file mode 100644 index 0000000..21f3853 --- /dev/null +++ b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/init-solarflow-control/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-solarflow-control/run \ No newline at end of file diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/solarflow-control/dependencies.d/init-solarflow-control b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/solarflow-control/dependencies.d/init-solarflow-control new file mode 100644 index 0000000..e69de29 diff --git a/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-solarflow-control b/solarflow-control/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-solarflow-control new file mode 100644 index 0000000..e69de29 diff --git a/solarflow-control/rootfs/solarflow/config.ini b/solarflow-control/rootfs/solarflow/config.ini deleted file mode 120000 index 3a45780..0000000 --- a/solarflow-control/rootfs/solarflow/config.ini +++ /dev/null @@ -1 +0,0 @@ -/share/solarflow/config.ini \ No newline at end of file diff --git a/solarflow-control/rootfs/solarflow/config.ini b/solarflow-control/rootfs/solarflow/config.ini new file mode 100644 index 0000000..186c1d0 --- /dev/null +++ b/solarflow-control/rootfs/solarflow/config.ini @@ -0,0 +1,91 @@ +[global] +# DTY Type: either OpenDTU or AhoyDTU +dtu_type = +# Smartmeter Type: either Smartmeter (generic, Tasmota, Hichi, ...), PowerOpti, ShellyEM3 +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 = +# 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 = + +# 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 = + +# 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 = + +[mqtt] +# Your local MQTT host configuration +mqtt_host = +mqtt_port = +mqtt_user = +mqtt_pwd = + +[opendtu] +# The MQTT base topic your OpenDTU reports to (as configured in OpenDTU UI) +base_topic = +# your Inverters serial number +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 = + +[ahoydtu] +# The MQTT base topic your AhoyDTU reports to (as configured in AhoyDTU UI) +base_topic = +# The inverter ID in AhoyDTU: typically 1 for the first inverter +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 = + +# the max output power of your inverter, used to calculate correct absolute values +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 = +zero_offset = + +# The MQTT base topic your Hichi, Tasmota, generic smartmeter reader reports to +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 = +total_accessor = + +[poweropti] +# Username and password for you Powerfox API to get readings (internet connection required) +poweropti_user = +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 = + +[control] +min_charge_power = +max_discharge_power = +discharge_during_daytime = +max_inverter_limit = +limit_inverter = +inverter_min_limit = +# Geolocation LAT/LNG +latitude = +longitude = +# Offset in minutes after sunrise/before sunset. Can be used to set the duration of what is considered "night" +sunrise_offset = +sunset_offset = diff --git a/solarflow-control/translations/en.yaml b/solarflow-control/translations/en.yaml new file mode 100644 index 0000000..e167cf2 --- /dev/null +++ b/solarflow-control/translations/en.yaml @@ -0,0 +1,134 @@ +--- +configuration: + dtu_type: + name: DTU Type + description: >- + Type of the DTU. Either OpenDTU or AhoyDTU. + smartmeter_type: + name: Smartmeter Type + description: >- + Type of the Smartmeter. Either Smartmeter (generic, Tasmota, Hichi, etc.), PowerOpti or Shelly 3EM. + product_id: + name: Solarflow Product ID + description: >- + The product ID specifies the model of Solarflow hub to use: Hub-1200: "73bkTV" Hub-2000: "A8yh63" + device_id: + name: Solarflow Device ID + description: >- + The device ID of your Solarflow Hub (typically 8 characters). + full_charge_interval: + name: Full Charge Interval + description: >- + The time interval in hours that solarflow-control will try to ensure a full battery (i.e. no discharging if battery hasn't been at 100% for this long) + control_bypass: + name: Control Bypass + description: >- + 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. + mqtt_host: + name: MQTT Host + description: >- + The hostname or IP address of your MQTT broker. + mqtt_port: + name: MQTT Port + description: >- + The port of your MQTT broker. + mqtt_user: + name: MQTT User + description: >- + The username for your MQTT broker. + mqtt_password: + name: MQTT Password + description: >- + The password for your MQTT broker. + dtu_base_topic: + name: DTU Base Topic + description: >- + The MQTT base topic your OpenDTU/AhoyDTU reports to. + sf_inverter_channels: + name: Solarflow Inverter Channels + description: >- + 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] + inverter_max_power: + name: Inverter Maximum Power + description: >- + The maximum output power of your inverter, used to calculate correct absolute values. + opendtu_inverter_serial: + name: OpenDTU Inverter Serial + description: >- + The serial number of the inverter connected to the OpenDTU. + ahoydtu_inverter_id: + name: AhoyDTU Inverter ID + description: >- + The ID of the inverter connected to the AhoyDTU. + sm_rapid_change_diff: + name: Smartmeter Rapid Change Difference + description: >- + The 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 + sm_zero_offset: + name: Smartmeter Zero Offset + description: >- + The zero offset defines the minimum power that is considered as a load. This is used to prevent the inverter from switching on/off when the smartmeter is reading a small amount of power (e.g. standby power) + sm_generic_base_topic: + name: Generic Smartmeter Base Topic + description: >- + The MQTT base topic your generic smartmeter, Hichi, Tasmota, etc. reports to. + sm_generic_cur_accessor: + name: Generic Smartmeter Current Accessor + description: >- + The JSON accessor to the current power reading of your generic smartmeter. If Smartmeter reader posts { "Power": {"Power_curr": 120, "Total_in": 12345.6} } then the accessor would be Power.Power_curr + sm_generic_total_accessor: + name: Generic Smartmeter Total Accessor + description: >- + The JSON accessor to the total power reading of your generic smartmeter. If Smartmeter reader posts { "Power": {"Power_curr": 120, "Total_in": 12345.6} } then the accessor would be Power.Total_in + sm_poweropti_user: + name: PowerOpti User + description: >- + The username for your Powerfox API of your PowerOpti smartmeter (internet connection required). + sm_poweropti_password: + name: PowerOpti Password + description: >- + The password for your Powerfox API of your PowerOpti smartmeter (internet connection required). + sm_shelly3em_base_topic: + name: Shelly 3EM Base Topic + description: >- + The MQTT base topic your Shelly 3EM reports to (defaults to shellies/shellyem3/). Note: MQTT is disabled by default on the Shelly 3EM and needs to be enabled first. + min_charge_power: + name: Minimum Charge Power + description: >- + The minimum power that is required to start charging the battery. + max_discharge_power: + name: Maximum Discharge Power + description: >- + The maximum power that is allowed to be discharged from the battery. + limit_inverter: + name: Limit Inverter + description: >- + Limit the output to the inverter. + max_inverter_limit: + name: Maximum Inverter Limit + description: >- + The maximum power that is sent to the inverter. + min_inverter_limit: + name: Minimum Inverter Limit + description: >- + The minimum power that is sent to the inverter. + discharge_during_daytime: + name: Discharge During Daytime + description: >- + Allow discharging the battery during daytime. + latitude: + name: Latitude + description: >- + The latitude of your location. Used to calculate sunrise and sunset times. + longitude: + name: Longitude + description: >- + The longitude of your location. Used to calculate sunrise and sunset times. + sunrise_offset: + name: Sunrise Offset + description: >- + The offset in minutes before sunrise. Can be used to set the duration of what is considered "night". + sunset_offset: + name: Sunset Offset + description: >- + The offset in minutes after sunset. Can be used to set the duration of what is considered "night".