404
+ +Page not found
+ + +diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/404.html b/404.html new file mode 100644 index 000000000..74474db8e --- /dev/null +++ b/404.html @@ -0,0 +1,148 @@ + + +
+ + + + +Page not found
+ + +The basic configuration for Predbat is configured in the apps.yaml
file.
Depending on whether you have used the combined AppDaemon/Predbat add-on installation method or the
+HACS, Appdaemon add-on then Predbat installation method, the apps.yaml
file will be held in one of two directories in Home Assistant:
/addon_configs/46f69597_appdaemon-predbat/apps
if you used the combined AppDaemon/Predbat add-on installation methodor
+/config/appdaemon/apps/batpred/config/
if you used the HACS, AppDaemon add-on then Predbat installation methodYou will need to use a file editor within Home Assistant (e.g. either the File editor or Studio Code Server add-on's)
+to edit the apps.yaml
file - see editing configuration files within Home Assistant if you need to install an editor.
This section of the documentation describes what the different configuration items in apps.yaml
do.
When you edit apps.yaml
, AppDaemon will automatically detect the change and Predbat will be reloaded with the updated file.
+You don't need to restart the AppDaemon add-on for your edits to take effect.
You can find template configurations in the following locations:
+Template | +Link | +
---|---|
GivEnergy | +apps.yaml | +
SolisX | +apps.yaml | +
SolarEdge | +apps.yaml | +
The GivEnergy template will be installed by default but if you are using another inverter please copy the correct template into the directory
+where your apps.yaml
is stored, and modify it from there.
Basic configuration items
+prefix - Set to the prefix name to be used for all entities that predbat creates in Home Assistant. Default 'predbat'. Unlikely that you will need to change this.
+timezone - Set to your local timezone, default is Europe/London. It must be set to a +valid Python time zone for your location
+template - Initially set to True, this is used to stop Predbat from operating until you have finished configuring your apps.yaml. +Once you have made all other required changes to apps.yaml this line should be deleted or commented out.
+notify_devices - A list of device names to notify when Predbat sends a notification. The default is just 'notify' which contacts all mobile devices
+days_previous - A list (one entry per line) of the number of days of historical house load to be used to predict your future daily load.
+It's recommended that you set days_previous so Predbat uses sufficient days' history so that 'unusual' load activity (e.g. saving sessions, "big washing day", etc) get averaged out.
+Typical settings could be 1, 7 or 7, 14, or 2, 3, 4, 5, 6, 7, 8.
+Do keep in mind that Home Assistant only keeps 10 days history by default, so you might need to increase the number of days history kept in HA before its purged
+by editing and adding the following to the /homeassistant/configuration.yaml
configuration file and restarting Home Assistant afterwards:
recorder:
+ purge_keep_days: 14
+
+days_previous_weight - A list (one entry per line) of weightings to be applied to each of the days in days_previous. Default value is 1, that all history days are equally weighted.
+forecast_hours - the number of hours to that Predbat will forecast ahead, 48 is the suggested amount, although other values can be used +such as 30 or 36 if you have a small battery and thus don't need to forecast 2 days ahead.
+The template apps.yaml
comes pre-configured with regular expressions that should auto-discover the GivTCP Home Assistant entity names.
+If you have more than one inverter or entity names are non-standard then you will need to edit apps.yaml for your inverter entities.
+For other inverter brands, see Other Inverters
num_inverters - The number of inverters you have. If you increase this above 1 you must provide multiple of each of the inverter entities
+geserial - This is a helper regular expression to find your serial number, if it doesn't work edit it manually or change individual entities to match.
+Predbat can either get historical data (house load, import, export and PV generation) directly from GivTCP or it can obtain it from the GivEnergy cloud. +Unless you have a specific reason to not use the GivTCP data (e.g. you've lost your GivTCP data), its recommended to use GivTCP.
+The following configuration entries in apps.yaml
are pre-configured to automatically use the appropriate GivTCP sensors.
If you have a 3-phase electricity supply and one inverter (and battery) on each phase then you will need to add one line for the load, import, export and PV sensors +for each of the 3 phases.
+If you have a single phase electricity supply and multiple inverters on the phase then you will need to add one line for each of the load and PV sensors. +You don't need multiple lines for the import or export sensors as each inverter will give the total import or export information.
+Edit if necessary if you have non-standard GivTCP sensor names:
+See the Workarounds section below for configuration settings for scaling these if required.
+If you have multiple inverters then you may find that the load_today figures from GivTCP are incorrect as the inverters share the house load between them. +In this circumstance one solution is to create a Home Assistant template helper to calculate house load from {pv generation}+{battery discharge}-{battery charge}+{import}-{export}.
+e.g.
+{{ states('sensor.givtcp_XXX_pv_energy_today_kwh')|float(0) + <inverter 2>...
++ states('sensor.givtcp_XXX_battery_discharge_energy_today_kwh')|float(0) + <inverter 2>...
+- states('sensor.givtcp_XXX_battery_charge_energy_today_kwh')|float(0) - <inverter 2>...
++ states('sensor.givtcp_XXX_import_energy_today_kwh')|float(0)
+- states('sensor.givtcp_XXX_export_energy_today_kwh')|float(0) }}
+
+If you have an issue with the GivTCP data, Predbat can get the required historical data from the GivEnergy cloud instead. This data is updated every 30 minutes. +Obviously connecting to the cloud is less efficient and means that Predbat will be dependent upon your internet connection and the GivEnergy cloud to operate.
+By default if Predbat sees a gap in the historical load data it will fill it with average data. This is to help in the cases of small amounts of lost data. +For entire lost days you should change days_previous to point to different days(s) or include 3 or more days and if you set switch.predbat_load_filter_modal to true, +the lowest day's historical load will be discarded.
+inverter_limit - One per inverter. When set defines the maximum watts of AC output power for your inverter (e.g. 3600). +This will help to emulate clipping when your solar produces more than the inverter can handle, but it won't be that accurate as the source of the data isn't minute by minute. +If you have a separate Solar inverter as well then add the solar inverter limit to the battery inverter limit to give one total amount.
+export_limit - One per inverter (optional). When set defines the maximum watts of AC power your inverter can export to the grid at (e.g. 2500). +This will emulate the software export limit setting in the Inverter that you will have if your G98/G99 +approval was lower than your maximum inverter power (check your install information for details). +If you do not set an export limit then it's the same as the inverter limit.
+inverter_limit_charge and inverter_limit_discharge - One per inverter (optional). When set in watts, overrides the maximum +charge/discharge rate settings used when controlling the inverter. +This can be used if you need to cap your inverter battery rate (e.g. charge overnight at a slower rate to reduce inverter/battery heating) as Predbat +will normally configure all timed charges or discharges to be at the inverter's maximum rate.
+There are two ways that Predbat can control GivTCP to control the inverter, either via REST API calls (preferred) or via the GivTCP inverter controls in Home Assistant.
+To check your REST is working open up the readData API point in a Web browser e.g: http://homeassistant.local:6345/readData
+If you get a bunch of inverter information back then it's working!
+It's recommended you enable 'Output Raw Register Values' in GivTCP (via Settings / Add-on's / GivTCP / configuration tab) for added monitoring:
+As an alternative to REST control, Predbat can control the GivEnergy inverters via GivTCP controls in Home Assistant.
+The template apps.yaml
is pre-configured with regular expressions for the following configuration items that should auto-discover the GivTCP controls,
+but may need changing if you have multiple inverters or non-standard GivTCP entity names.
The givtcp_rest line should be commented out/deleted in order for Predbat to use the direct GivTCP Home Assistant controls.
+If you are using REST control the above GivTCP configuration items can be deleted or commented out of apps.yaml.
+As described in the Predbat installation instructions, Predbat needs a solar forecast +in order to predict solar generation and battery charging which can be provided by the Solcast integration.
+The template apps.yaml
is pre-configured with regular expressions for the following configuration items that should auto-discover the Solcast entity names.
+They are unlikely to need changing although a few people have reported their entity names don't contain 'solcast' so worth checking, or edit if you have non-standard names:
If you do not have a PV array then comment out or delete these Solcast lines from apps.yaml
.
If you have multiple PV arrays connected to GivEnergy Hybrid inverters or you have GivEnergy AC-coupled inverters, then ensure your PV configuration in Solcast covers all arrays.
+If however you have a mixed PV array setup with some PV that does not feed into your GivEnergy inverters +(e.g. hybrid GE inverters but a separate older FIT array that directly feeds AC into the house), +then it's recommended that Solcast is only configured for the PV connected to the GivEnergy inverters.
+Solcast produces 3 forecasted PV estimates, the 'central' (50% or most likely to occur) PV forecast, the '10%' (worst case) PV forecast, and the '90%' (best case) PV forecast.
+By default Predbat will use the central estimate and applies to it the input_number.pv_metric10_weight weighting of the 10% (worst case) estimate.
Predbat models cloud coverage by using the difference between the PV and PV10 forecasts to work out a cloud factor, +this modulates the PV output predictions up and down accordingly as if there were passing clouds. +This can have an impact on planning, especially for things like freeze charging which could assume the PV will cover the house load but it might not due to clouds.
+apps.yaml
can be used to configure Predbat to always use the 10% forecast by setting the configuration item to '10',
+or '90' to always use the 90% PV estimate (not recommended!).If pv_estimate is set to 10 then input_number.pv_metric10_weight in Home Assistant should be set to 1.0.
+There are a number of configuration items in apps.yaml for telling Predbat what your import and export rates are.
+These are described in detail in Energy Rates and are listed here just for completeness:
+Predbat is able to include electric vehicle charging in its plan and manage the battery activity so that the battery isn't discharged into your car when the car is charging +(although you can over-ride this if you wish by setting the switch.predbat_car_charging_from_battery to True in Home Assistant).
+There are two different ways of planning car charging into cheap slots with Predbat, either by the Octopus Energy integration or by Predbat identifying the cheapest slots. +These approaches and the set of settings that need to be configured together are described in Car Charging Planning.
+The full list of car charging configuration items in apps.yaml
that are used to plan car charging activity within Predbat are described below.
+The Home Assistant controls (switches, input numbers, selectors, etc) related to car charging are described in Car Charging configuration within Home Assistant,
+with brief mention of pertinent controls included here alongside the apps.yaml configuration items where relevant for context.
You might want to remove your electric car charging data from the historical house load data so as to not bias the calculations, otherwise you will get +high battery charge levels when the car was charged previously (e.g. last week).
+switch.car_charging_hold - A Home Assistant switch that when turned on (True) tells Predbat to remove car charging data from Predbat's battery prediction plan.
+car_charging_energy - Set in apps.yaml to point to a Home Assistant entity which is the incrementing kWh data for the car charger. +This has been pre-defined to a regular expression to auto-detect the appropriate Wallbox and Zappi car charger sensors, or edit as necessary in apps.yaml for your charger sensor.
+input_number.car_charging_energy_scale - A Home Assistant entity used to define a scaling factor (in the range 0.1 to 1.0) +to multiply the car_charging_energy data by if required (e.g. set to 0.001 to convert Watts to kW).
+If you do not have a suitable car charging kWh sensor in Home Assistant then comment the car_charging_energy line out of apps.yaml
and configure the following Home Assistant entity:
These features allow Predbat to know when you plan to charge your car.
+If you have Intelligent Octopus setup then planning of charging is done via the Octopus app and Predbat obtains this information through the Octopus Energy integration in Home Assistant.
+The following apps.yaml
configuration items are pre-defined with regular expressions to point to appropriate sensors in the Octopus Energy integration.
+You should not normally need to change these if you have Octopus Intelligent:
octopus_intelligent_slot - Points to the Octopus Energy integration 'intelligent dispatching' sensor that indicates +whether you are within an Octopus Energy "smart charge" slot, and provides the list of future planned charging activity.
+octopus_ready_time - Points to the Octopus Energy integration sensor that details when the car charging will be completed by.
+octopus_charge_limit - Points to the Octopus Energy integration sensor that provides the car charging limit.
+If you don't use Intelligent Octopus then the above 3 Octopus Intelligent configuration lines in apps.yaml
can be commented out or deleted,
+and there are a number of other apps.yaml configuration items that should be set:
car_charging_planned - Optional, can be set to a Home Assistant sensor which lets Predbat know the car is plugged in and planned to charge during low rate slots. +Or manually set it to 'False' to disable this feature, or 'True' to always enable.
+car_charging_planned_response - An array of values for the above car_charging_planned sensor which indicate that the car is plugged in and will charge +in the next low rate slot. Customise for your car charger sensor if it sets sensor values that are not in the pre-defined list.
+car_charging_now - For some cases finding details of planned car charging is difficult to obtain (e.g. Ohme with Intelligent doesn't report slots).
+The car_charging_now configuration item can be set to point to a Home Assistant sensor that tells you that the car is currently charging.
+Predbat will then assume this 30 minute slot is used for charging regardless of the plan.
+If Octopus Intelligent Charging is enabled and car_charging_now indicates the car is charging then Predbat will also assume that this is a
+low rate slot for the car/house (and might therefore start charging the battery), otherwise electricity import rates are taken from the normal rate data.
car_charging_now_response - Set to the range of positive responses for car_charging_now to indicate that the car is charging. +Useful if you have a sensor for your car charger that isn't binary.
+To make planned car charging more accurate, configure the following items in apps.yaml
:
car_charging_battery_size - Set to the car's battery size in kWh, defaults to 100. It will be used to predict car charging stops.
+car_charging_limit - Set to point to a sensor that specifies the % limit the car is set to charge to. Default is 100%
+car_charging_soc - Set to point to a sensor that specifies the car's current % charge level. Default is 0%
+Multiple cars can be planned with Predbat, in which case you should set num_cars in apps.yaml
to the number of cars you want to plan
car_charging_limit, car_charging_planned, car_charging_battery_size and car_charging_soc must then be a list of values (i.e. 2 entries for 2 cars)
+If you have Intelligent Octopus then Car 0 will be managed by the Octopus Energy integration, if its enabled
+Each car will have it's own Home Assistant slot sensor created e.g. binary_sensor.predbat_car_charging_slot_1, +SOC planning sensor e.g predbat.car_soc_1 and predbat.car_soc_best_1 for car 1
+When you have two or more inverters it's possible they get out of sync so they are at different charge levels or they start to cross-charge (one discharges into another). +When enabled, balance inverters tries to recover this situation by disabling either charging or discharging from one of the batteries until they re-align.
+Most of the Predbat configuration for balancing inverters is through a number of Home Assistant controls for Balancing Inverters,
+but there is one configuration item in apps.yaml
:
There are a number of different configuration items in apps.yaml
that can be used to tweak the way Predbat operates and workaround
+weirdness you may have from your inverter and battery setup.
If your inverter's time is different to the time on the computer running Home Assistant, you may need to skew the time settings made on the inverter when you trigger charging or discharging. +Again 1 means the inverter is 1 minute fast and -1 means the inverter is 1 minute slow.
+Separate start and end options are applied to the start and end time windows, mostly as you want to start battery activity late (not early) and finish early (not late).
+You can adjust the charge and discharge times written to the inverter by setting the following in apps.yaml
:
inverter_clock_skew_start, inverter_clock_skew_end - Skews the setting of the charge slot registers vs the predicted start time
+inverter_clock_skew_discharge_start, inverter_clock_skew_discharge_end - Skews the setting of the discharge slot registers vs the predicted start time
+battery_scaling - Default value 1.0. This setting is used to scale the battery reported SOC kWh to make it appear bigger or larger than it is
+e.g. if you have an 80% depth of discharge battery that falsely reports its capacity, set this to 0.8 to report the real figure.
+If you are going chart your battery SoC in Home Assistant then you may want to use predbat.soc_kw_h0 as your current SoC
+rather than the usual givtcp_
import_export_scaling - Default value 1.0. Used to scale the import & export kWh data from GivTCP if the inverter information is incorrect.
+inverter_battery_rate_min - One per inverter (optional), set in Watts, when set models a "bug" in the inverter firmware +in some models where if charge or discharge rates are set to 0 you actually get a small amount of charge or discharge. +Recommended setting is 200 for Gen 1 hybrids with this issue.
+inverter_reserve_max - Global, sets the maximum reserve % that maybe set to the inverter, the default is 98 as some Gen 2 inverters and +AIO firmware versions refuse to be set to 100. Comment the line out or set to 100 if your inverter allows setting to 100%.
+battery_charge_power_curve - Some batteries tail off their charge rate at high soc% and this optional configuration item enables you to model this in Predbat. +Enter the charging curve as a series of steps of % of max charge rate for each soc percentage. +The default is 1.0 (full power) charge all the way to 100%. +Example from a GivEnergy 9.5kWh battery with latest firmware and Gen 1 inverter:
+ battery_charge_power_curve:
+ 91 : 0.91
+ 92 : 0.81
+ 93 : 0.71
+ 94 : 0.62
+ 95 : 0.52
+ 96 : 0.43
+ 97 : 0.33
+ 98 : 0.24
+ 99 : 0.24
+ 100 : 0.24
+
+The trigger feature is useful to help trigger your own automations based on Predbat determining that you have spare solar energy or battery that you would otherwise export. +For example you may turn an immersion heater or the washing machine on to consume the excess solar power.
+The triggers count export energy until the next active charge slot only.
+For each trigger give a name, the minutes of export needed and the energy required in that time.
+Multiple triggers can be set at once so in total you could use too much energy if all run.
+Each trigger specified in apps.yaml
will create a Home Assistant entity called 'binary_sensor.predbat_export_trigger_name' which will be turned on when the condition is valid.
+Connect this binary sensor to your automation to start whatever you want to trigger.
Set the name for each trigger, the number of minutes of solar export you need, and the amount of energy in kWh you will need available during that time period in apps.yaml:
+For example:
+export_triggers:
+ - name: "large"
+ minutes: 60
+ energy: 1.0
+ - name: "small"
+ minutes: 15
+ energy: 0.25
+
+If you wish to trigger based on charging or discharging the battery rather than spare solar energy you can instead use the following binary sensors in Home Assistant:
+binary_sensor.predbat_charging - Will be True when the home battery is inside a charge slot (either being charged or being held at a level). +Note that this does include charge freeze slots where the discharge rate is set to zero without charging the battery.
+binary_sensor.predbat_discharging - Will be True when the home battery is inside a force discharge slot. This does not include +discharge freeze slots where the charge rate is set to zero to export excess solar only.
+There are two ways to plan car charging slots:
+If you have Intelligent Octopus import tariff and the Octopus Energy integration - in which case Predbat will use the slots allocated by Octopus Energy in battery prediction
+apps.yaml
points to the Intelligent Slot sensor in the Octopus Energy integrationapps.yaml
then Predbat can also know if the car's limit is set lower than in Intelligent OctopusPredbat-led charging - Here Predbat plans the charging based on the upcoming low rate slots
+apps.yaml
NOTE: Multiple cars can be planned with Predbat.
+See Car charging filtering and Planned car charging +in the apps.yaml settings section of the documentation.
+ +First get the basics set up, ensure you have the inverter controls configured, +you have configured apps.yaml to your setup, and the solar forecast is in place. +Make sure your energy rates are configured correctly for import and export.
+If you have an EV try to set up the car charging sensor correctly so Predbat can tell what part of your historical load is EV charging. +You might want to also set to the car charging plan so you can predict when your car is plugged in and how much it will charge.
+It is recommended that you create a dashboard page with all the required entities to control Predbat.
+You should try to tune input_number.inverter_loss, input_number.battery_loss and input_number.battery_loss_discharge to the correct % loss for your system +in order to get more accurate predictions. Around 4% for each is good for a hybrid inverter. +Also set switch.inverter_hybrid to True or False depending upon if you have a Hybrid or AC-Coupled battery.
+The setting input_number.metric_battery_cycle (expert mode) can be used to put a 'virtual cost' in pence on using your battery for charging and discharging.
+In theory if you think your battery will last say 6000 complete cycles and cost you £4000 and is 9.5kWh then each cycle is 19kWh and so the cost per cycle is £4000 / 19 / 6000 = 3.5p.
+If you configure this number higher then more expensive plans will be selected which avoids charging and discharging your battery as much.
+The default is 1p but can be set to 0 if you want to turn this feature off.
+Note that the cycle cost will not be included in the cost predictions that Predbat produces, its just taken into account in the planning stage.
+NB: Setting this to a non-zero value will increase your daily cost, but will reduce your home battery usage.
input_number.forecast_plan_hours - the number of hours after the next charge slot to include in the plan, default 24 hours is the suggested amount (to match energy rate cycles)
+switch.set_discharge_during_charge - If turned off disables inverter discharge during charge slots, useful for multi-inverter setups +to avoid cross charging when batteries are out of balance.
+Below is a guide to some of the electricity tariff options and a set of recommended Predbat settings for each tariff type. +In theory most tariffs will work out of the box but still it's worth reviewing your settings.
+With a fixed daily rate tariff you will just be predicting the battery levels, no charging or discharging is required although it won't hurt if you leave these options enabled.
+You should set select.predbat_mode to 'Monitor'.
+In this scenario you will want to charge overnight based on the next day's solar forecast and don't want Predbat to force discharge your battery.
+Recommended settings - these must be changed in Home Assistant once Predbat is running:
+Item | +Value | +Comment | +
---|---|---|
select.predbat_mode | +Control Charge | +You want Predbat to calculate and control charging | +
input_number.predbat_best_soc_keep | +2.0 | +Tweak this to control what battery level you want to keep as a backup in case you use more energy | +
switch.predbat_combine_charge_slots | +True | +Use one big charge slot | +
If you are using expert mode then these options maybe worth reviewing:
+Item | +Value | +Comment | +
---|---|---|
input_number.predbat_forecast_plan_hours | +24 | +If you set this to 24 then you will have quicker updates, the cycle repeats itself anyhow | +
switch.predbat_combine_charge_slots | +True | +As you have just one overnight rate then one slot is fine | +
input_number.metric_min_improvement | +0 | +Charge less if it's cost neutral | +
You should set select.predbat_mode to 'Control Charge'
+Follow the instructions from the Cheap Night rate above, but also you will also want to have automatic discharge occurring when the export rates are profitable.
+Item | +Value | +Comment | +
---|---|---|
select.predbat_mode | +Control Charge & Discharge | +You want Predbat to calculate and control charging and discharging | +
input_number.predbat_best_soc_keep | +2.0 | +Tweak this to control what battery level you want to keep as a backup in case you use more energy | +
switch.predbat_combine_charge_slots | +True | +Use one big charge slot | +
If you are using expert mode then these options maybe worth reviewing, otherwise ignore this:
+Item | +Value | +Comment | +
---|---|---|
input_number.predbat_forecast_plan_hours | +24 | +If you set this to 24 then you will have quicker updates, the cycle repeats itself anyhow | +
switch.predbat_combine_charge_slots | +? | +Setting to False will allow charging at more expensive day rates when it's worth it to export more | +
input_number.metric_min_improvement | +0 | +Charge less if it's cost neutral | +
input_number.metric_min_improvement_discharge | +0.1 | +Discharge only if there is a profit | +
input_number.metric_battery_cycle | +? | +Higher numbers mean less charging and discharging but higher costs | +
input_number.predbat_best_soc_min | +? | +Can be set non-zero if you want to force a minimum charge level | +
You should set select.predbat_mode to 'Control Charge & Discharge'
+Follow the instructions from Cheap Night rate above, but also you will want to have automatic discharge when the export rates are profitable.
+Recommended settings - these must be changed in Home Assistant once Predbat is running:
+Item | +Value | +Comment | +
---|---|---|
select.predbat_mode | +Control Charge & Discharge | +You want Predbat to calculate and control charging and discharging | +
input_number.predbat_best_soc_keep | +0.5 | +Use the full battery without going empty | +
switch.predbat_combine_charge_slots | +True | +Use one big charge slot | +
If you are using expert mode then these options maybe worth reviewing, otherwise ignore this:
+Item | +Value | +Comment | +
---|---|---|
input_number.predbat_forecast_plan_hours | +24 | +If you set this to 24 then you will have quicker updates, the cycle repeats itself anyhow | +
switch.predbat_combine_charge_slots | +? | +Setting to False will allow charging at more expensive day rates when it's worth it to export more | +
input_number.metric_min_improvement | +0 | +Charge less if it's cost neutral | +
input_number.metric_min_improvement_discharge | +0.1 | +Discharge only if there is a profit | +
input_number.metric_battery_cycle | +? | +Higher numbers mean less charging and discharging but higher costs | +
input_number.predbat_best_soc_min | +0 | +Don't use non-zero otherwise all slots will be force charging | +
You should set select.predbat_mode to 'Control Charge & Discharge'
+Recommended settings - these must be changed in Home Assistant once Predbat is running:
+Item | +Value | +Comment | +
---|---|---|
select.predbat_mode | +Control Charge & Discharge | +You want Predbat to calculate and control charging and discharging | +
input_number.predbat_best_soc_keep | +0.5 | +Use the full battery without going empty | +
switch.predbat_combine_charge_slots | +True | +Use one big charge slot | +
If you are using expert mode then these options maybe worth reviewing, otherwise ignore this:
+Item | +Value | +Comment | +
---|---|---|
input_number.predbat_forecast_plan_hours | +24-48 | +If you set this to 24 then you will have quicker updates, going to 36/48 for a longer plan | +
input_number.metric_min_improvement | +0 | +Charge less if it's cost neutral | +
input_number.metric_min_improvement_discharge | +0.1 | +Discharge only if there is a profit | +
input_number.metric_battery_cycle | +? | +Higher numbers mean less charging and discharging but higher costs | +
input_number.predbat_best_soc_min | +0 | +Don't use non-zero otherwise all slots will be force charging | +
switch.calculate_fast_plan | +False | +The fast plan feature reduces accuracy of planning | +
You should set select.predbat_mode to 'Control Charge & Discharge'
+ +To create the fancy charts:
+See the video guides for a walkthrough of what the different charts show.
+Example charts:
+These are the Predbat configuration items in Home Assistant that you can modify to fit your needs, you can configure these in Home Assistant directly.
+See Displaying output data +for information on how to view and edit these entities within +Home Assistant.
+The mode that Predbat operates in will change the operation, this can be configured with select.predbat_mode drop down menu as follows:
+If the switch.predbat_set_read_only is set to True then this prevents Predbat from making modifications to the inverter settings (regardless of the configuration). +Predbat will continue making and updating its prediction plan every 5 minutes, but no inverter changes will be made. +This is useful if you want to over-ride what predbat is planning to do (e.g. your own automation), or whilst you are learning how Predbat works prior to turning it on 'in anger'.
+NOTE: Changing the Predbat mode or the read only switch will cause Predbat to reset the inverter settings to default, this will disable +both charge and discharge, reset charge and discharge rates to full power and reset the reserve to the default setting
+In monitor mode Predbat will not control charging or discharging, inverter balancing will take place if enabled, the plan will show +just what is expected based on the current inverter configuration alone.
+In Control SOC Only mode Predbat will adjust the target charge percentage (SOC target) according to the Best plan, but the charge +window will not be modified. This can be useful if you just have one fixed +charge slot per day and you only want Predbat to control the percentage.
+CAUTION: If the charge window is disabled then no charging will take place.
+In Control Charge mode Predbat will set the charge times and charge percentages according to the Best plan, charging can be enabled and +disabled by Predbat.
+In Control Charge and Discharge mode Predbat will set both charge and discharge times and control charge and discharge percentages.
+If you have set the switch.predbat_set_discharge_freeze_only to True then forced export won't occur but Predbat can force the export +of solar power to the grid when desired.
+Predbat has a toggle switch called switch.predbat_expert_mode which is off by default for new installs (on +by default for upgraded installs). A lot of configuration items will not be available unless expert mode is enabled. +It's recommended for new users to start without expert mode and then maybe enable it later once you become more +confident with the tool.
+By default Predbat controls the inverter and updates the plan every 5 minutes, this can however use a lot of CPU power +especially on more complex tariffs like Agile when run on lower power machines such as Raspberry PIs and some thin clients.
+You can tweak input_number.predbat_calculate_plan_every (expert mode) to reduce the frequency of replanning while +keeping the inverter control in the 5 minute slots. E.g. a value of 10 or 15 minutes should also give good results.
+If you have performance problems leave switch.predbat_calculate_second_pass (expert mode) turned Off as it's +quite CPU intensive and provides very little improvement for most systems.
+If you have performance problems turn switch.predbat_calculate_fast_plan (expert mode) On to help +reduce your CPU load.
+input_number.battery_loss accounts for energy lost charging the battery, default 0.05 is 5%
+input_number.battery_loss_discharge accounts for energy lost discharging the battery, default 0.05 is 5%
+input_number.inverter_loss accounts for energy loss during going from DC to AC or AC to DC, default is 0% for +legacy reasons but please adjust.
+switch.inverter_hybrid When True you have a hybrid inverter so no inverter losses for DC charging. When false +you have inverter losses as it's AC coupled battery.
+input_number.metric_battery_cycle (expert mode) Sets the cost in pence per kWh of using your battery for charging and discharging. +Higher numbers will reduce battery cycles at the expense of using higher energy costs. +Figures of around 1p-5p are recommended, the default is 1p per kWh.
+input_number.predbat_metric_battery_value_scaling (expert mode) Can be used to scale the value of the energy +in the battery at the end of the plan. The battery value is accounted for in the optimisations at the lowest future +import rate including charging and inverter losses. A value of 1.0 means no change to this, while lower than 1.0 +means to value future battery levels less, greater than 1.0 will value it more (and hence hold more charge at the end of the plan).
+input_number.battery_rate_max_scaling adjusts your maximum charge/discharge rate from that reported by GivTCP +e.g. a value of 1.1 would simulate a 10% faster charge/discharge than reported by the inverter
+switch.predbat_battery_capacity_nominal - When enabled Predbat uses the reported battery size from the Nominal field rather than from the normal GivTCP +reported size. If your battery size is reported wrongly maybe try turning this on and see if it helps.
+input_number.load_scaling is a Scaling factor applied to historical load, tune up if you want to be more pessimistic on future consumption +Use 1.0 to use exactly previous load data (1.1 would add 10% to load)
+input_number.load_scaling10 is a Scaling factor applied to historical load only for the PV10% scenario (this is in addition to load_scaling). +This can be used to make the 10% scenario take into account extra load usage and hence be more pessimistic while leaving the central +scenario unchanged. The default is 1.1 meaning an extra 10% load is added. This will only have an impact if the PV 10% weighting is non-zero.
+input_number.pv_scaling is a scaling factor applied to PV data, tune down if you want to be more pessimistic on PV production vs Solcast +Use 1.0 to use exactly the Solcast data (0.9 would remove 10% from forecast)
+input_number.pv_metric10_weight is the weighting given to the 10% PV scenario. Use 0.0 to disable this. +A value of 0.1 assumes that 1:10 times we get the 10% scenario and hence to count this in the metric benefit/cost. +A value of 0.15 is recommended.
+The historical load data is taken from the load sensor as configured in apps.yaml
and the days are selected
+using days_previous and weighted using *days_previous_weight in the same configuration file
switch.predbat_load_filter_modal (expert mode) when enabled will automatically discard the lowest daily consumption +day from the list of days to use (provided you have more than 1 day selected in days_previous). This can be used to ignore +a single low usage day in your average calculation. By default is feature is enabled but can be disabled only in expert mode.
+Car charging hold is a feature where you try to filter out previous car charging from your historical data so that +future predictions are more accurate.
+When car_charging_hold is enabled loads of above the power threshold car_charging_threshold then you are +assumed to be charging the car and car_charging_rate will be subtracted from the historical load data.
+For more accurate results can you use an incrementing energy sensor set with car_charging_energy in the apps.yml +then historical data will be subtracted from the load data instead.
+car_charging_energy_scale Is used to scale the car_charging_energy sensor, the default units are kWh so +if you had a sensor in watts you might use 0.001 instead.
+car_charging_loss gives the amount of energy lost when charging the car (load in the home vs energy added to the battery). A good setting is 0.08 which is 8%.
+Car charging planning - is only used if Intelligent Octopus isn't enabled and car_charging_planned is connected correctly.
+This feature allows Predbat to create a plan for when you car will charge, but you will have to create an automation +to trigger your car to charge using binary_sensor.predbat_car_charging_slot if you want it to match the plan.
+car_charging_plan_time - When using Predbat-led planning set this to the time you want the car to be charged by
+car_charging_plan_smart - When enabled (True) allows Predbat to allocate car charging slots to the cheapest times, +when disabled (False) all low rate slots will be used in time order.
+switch.predbat_octopus_intelligent_charging when true enables the Intelligent Octopus charging feature +which will make Predbat create a car charging plan which is taken from the Intelligent Octopus plan +you must have set octopus_intelligent_slot sensor in apps.yaml to enable this feature.
+If Octopus Intelligent Charging is enabled the switch switch.predbat_octopus_intelligent_ignore_unplugged (expert mode) +can be used to prevent Predbat from assuming the car will be charging when the car is unplugged. This will only work correctly +if car_charging_planned is set correctly in apps.yaml to detect your car being plugged in.
+Control how your battery behaves during car charging:
+If your car does not have an SOC sensor and you are not using Octopus Intelligent you can set switch.predbat_car_charging_manual_soc +to have Predbat create input_number.predbat_car_charging_manual_soc_kwh which will hold the cars current state of charge (soc) +in kWh. You will need to manually set this to the cars current charge level before charging, Predbat will increment it during +charging sessions but will not reset it automatically.
+See the Predbat mode setting as above for basic calculation options
+switch.predbat_calculate_regions (expert mode) When True the a second pass of the initial thresholds is +calculated in 4 hour regions before forming the detailed plan. Is True by default but can be turned off in expert +mode.
+switch.predbat_calculate_fast_plan (expert mode) When True the plan is calculated with a limited number of +windows to make calculations faster. When False (default) all windows are considered but planning will take a little +longer but be more accurate. +The end result is unlikely to change in fast mode as the next 8 windows are always considered in the plan, but the +longer term plan will be less accurate.
+switch.predbat_calculate_discharge_oncharge (expert mode) When True calculated discharge slots will +disable or move charge slots, allowing them to intermix. When False discharge slots will never be placed into charge slots.
+switch.predbat_calculate_tweak_plan (expert mode) When True causes Predbat to perform a second pass optimisation +across the next 8 charge and discharge windows in time order.
+This can help to slightly improve the plan for tariffs like Agile but can make it worse in some fixed rate tariffs which +you want to discharge late.
+switch.predbat_calculate_second_pass (expert mode) When True causes Predbat to perform a second pass optimisation +across all the charge and discharge windows in time order.
+NOTE: This feature is quite slow and so may need a higher performance machine
+This can help to slightly improve the plan for tariffs like Agile but can make it worse in some fixed rate tariffs which +you want to discharge late.
+input_number.best_soc_keep is the minimum battery level in kWh that Predbat will to try to keep above during the whole period of the simulation time. +This is a soft constraint only so it is possible for your SoC to drop below this - use input_number.best_soc_min for hard SoC constraint that will always be maintained. +It's usually good to have best_soc_keep set to a value above 0 to allow some margin +in case you use more energy than planned between charge slots.
+input_number.best_soc_min (expert mode) sets the minimum charge level (in kWh) for charging during each slot and the +minimum discharge level also (set to 0 if you want to skip some slots). If you set this to a non-zero value you will need +to use the low rate threshold to control which slots you charge from or you may charge all the time.
+input_number.best_soc_max (expert mode) sets the maximum charge level (in kWh) for charging during each slot. +A value of 0 disables this feature.
+switch.combine_charge_slots Controls if charge slots of > 30 minutes can be combined. When disabled they will be split up, +increasing run times but potentially more accurate for planning. Turn this off if you want to enable ad-hoc import +during long periods of higher rates but you wouldn't charge normally in that period (e.g. pre-charge at day rate before +a saving session). The default is enable (True)
+switch.combine_discharge_slots (expert mode) Controls if discharge slots of > 30 minute can be combined. When disabled +they will be split up, increasing run times but potentially more accurate for planning. The default is disabled (False)
+input_number.metric_min_improvement (expert mode) sets the minimum cost improvement that it's worth lowering the battery SOC % for. +If it's 0 then this is disabled and the battery will be charged less if it's cost neutral. +If you use pv_metric10_weight then you probably don't need to enable this as the 10% forecast does the same thing better +Do not use if you have multiple charge windows in a given period as it won't lead to good results (e.g. Agile) +You could even go to something like -0.1 to say you would charge less even if it cost up to 0.1p more (best used with metric10)
+input_number.metric_min_improvement_discharge (expert mode) Sets the minimum pence cost improvement it's worth doing a forced discharge (and export) for. +A value of 0.1 is the default which prevents any marginal discharges. If you increase this value (e.g. you only want to discharge/forced export if definitely very profitable), +then discharges will become less common and shorter.
+input_number.rate_low_threshold (expert mode) When 0 (default) this is automatic but can be overridden. When non zero it sets +the threshold below average rates as the minimum to consider for a charge window, 0.8 = 80% of average rate +If you set this too low you might not get enough charge slots. If it's too high you might get too many in the +24-hour period which makes optimisation harder.
+input_number.rate_high_threshold (expert mode) When 0 (default) this is automatic but can be overridden. When non zero it sets +the threshold above average rates as to the minimum export rate to consider exporting for - 1.2 = 20% above average rate +If you set this too high you might not get any export slots. If it's too low you might get too many in the 24-hour period.
+input_number.metric_future_rate_offset_import (expert mode) Sets an offset to apply to future import energy rates that are +not yet published, best used for variable rate tariffs such as Agile import where the rates are not published until 4pm. +If you set this to a positive value then Predbat will assume unpublished import rates are higher by the given amount.
+input_number.metric_future_rate_offset_export (expert mode) Sets an offset to apply to future export energy rates that are +not yet published, best used for variable rate tariffs such as Agile export where the rates are not published until 4pm. +If you set this to a negative value then Predbat will assume unpublished export rates are lower by the given amount.
+switch.predbat_calculate_inday_adjustment (expert mode) Enabled by default with damping of 0.95. When enabled will +calculate the difference between today's actual load and today's predicated load and adjust the rest of the days usage +prediction accordingly. A scale factor can be set with input_number.predbat_metric_inday_adjust_damping (expert mode) +to either scale up or down the impact of the in-day adjustment (lower numbers scale down its impact). The in-day adjustment +factor can be see in predbat.load_inday_adjustment and charted with the In Day Adjustment chart (template can be found +in the charts template in Github).
+switch.set_status_notify Enables mobile notification about changes to the Predbat state (e.g. Charge, Discharge etc). On by default.
+switch.set_inverter_notify Enables mobile notification about all changes to inverter registers (e.g. setting window, turning discharge on/off). +Off by default.
+switch.predbat_set_charge_low_power Enables low power charging mode where the max charge rate will be limited to the +lowest possible to meet the charge target. Only really effective for charge windows >30 minutes. +Off by default.
+switch.set_reserve_enable (expert_mode) When enabled the reserve setting is used to hold the battery charge level +once it has been reached or to protect against discharging beyond the set limit. Enabled by default.
+switch.set_charge_freeze (expert mode) When enabled will allow Predbat to hold the current battery level while drawing +from the grid/solar as an alternative to charging. Enabled by default.
+switch.set_discharge_freeze_only (expert mode) When enabled forced discharge is prevented, but discharge freeze can be used +(if enabled) to export excess solar rather than charging the battery. This is useful with tariffs that pay you for +solar exports but don't allow forced export (brown energy).
+If you have switch.inverter_hybrid set to False then if switch.inverter_soc_reset (expert mode) is set to True then the +target SOC % will be reset to 100% outside a charge window. This may be required for AIO inverter to ensure it charges from solar.
+input_number.set_reserve_min Defines the reserve percentage to reset the reserve to when not in use, a value of 4 is the +minimum and recommended to make use of the full battery
+switch.inverter_soc_reset (expert mode) When enabled the target SOC for the inverter(s) will be reset to 100% +when a charge slot is not active, this can be used to workaround some firmware issues where the SOC target is +used for solar charging as well as grid charging. When disabled the SOC % will not be changed after a charge slot. +This is disabled by default.
+When you have two or more inverters it's possible they get out of sync so they are at different charge levels or they start to cross-charge (one discharges into another). +When enabled, balance inverters tries to recover this situation by disabling either charging or discharging from one of the batteries until they re-align.
+The apps.yaml contains a setting balance_inverters_seconds which defines how often to run the balancing, 30 seconds is recommended if your +machine is fast enough, but the default is 60 seconds.
+Enable the switch.predbat_balance_inverters_enable switch in Home Assistant to enable this feature.
+iBoost model, when enabled with switch.iboost_enable tries to model excess solar energy being used to heat +hot water (or similar). The predicted output from the iBoost model is returned in iboost_best.
+The following entities are only available when you turn on iboost enable:
+iboost_solar When enabled assumes iBoost will use solar power to boost.
+iboost_min_soc sets the minimum home battery soc % to enable iboost solar on, default 0
+iboost_gas When enabled assumes IBoost will operate when electric rates are lower than gas rates. +Note: Gas rates have to be configured in apps.yaml with metric_octopus_gas
+iboost_gas_scale Sets the scaling of the gas rates used before comparing with electric rates, to account for losses
+iboost_charging Assume IBoost operates when the battery is charging (can be combined with iboost_gas or not)
+iboost_max_energy Sets the max energy sets the number of kwh that iBoost can consume during a day before turning off - default 3kWh
+iboost_max_power Sets the maximum power in watts to consume - default 2400
+iboost_min_power Sets the minimum power in watts to consume - default 500
+You will see predbat.iboost_today entity which tracks the estimated amount consumed during the day, and resets at night
+The binary_sensor.iboost_active entity will be enabled when IBoost should be active, can be used for automations to trigger boost
+If you have an incrementing Sensor that tracks iBoost energy usage then you should set iboost_energy_today sensor in +apps.yaml to point to it and optionally set iboost_energy_scaling if the sensor isn't in kWh.
+When you go away you are likely to use less electricity and so the previous load data will be quite pessimistic.
+Using the Home Assistant entity input_number.predbat_holiday_days_left you can set the number of full days that +you will be away for (including today). The number will count down by 1 day at midnight until it gets back to zero. +Whilst holiday days left is non-zero, Predbat's 'holiday mode' is active.
+When Predbat's 'holiday mode' is active the historical load data will be taken from yesterday's data (1 day ago) rather than from the days_previous setting in apps.yaml. +This means Predbat will adjust more quickly to the new usage pattern.
+If you have been away for a longer period of time (more than your normal days_previous setting) then obviously it's going +to take longer for the historical data to catch up, you could then enable holiday mode for another 7 days after your return.
+In summary:
+debug_enable when on prints lots of debug, leave off by default
+plan_debug (expert mode) when enabled adds some extra debug to the Predbat HTML plan
+ +Using GitHub, take a fork of Predbat - effectively, this creates +a copy of the main repository, but in your personal space. +There, you can create branches to develop on.
+Once you've completed your work on your branch, you can create a
+pull request (PR) to merge your work back in to the main
branch
+of Predbat.
This PR should describe the work you've done in a way that +makes it easy for someone to review your work, and either +add comments or approve it.
+There are at least a couple of ways of working on the code, outlined here.
+Especially if you don't need to have a running Home Assistant system +to make the changes you're interested in (e.g. for documentation, +quick fixes etc.) a really easy way to work on the code is using +GitHub Codespaces.
+GitHub Codespaces gives you a full featured development environment. +This includes:
+pre-commit
to run the automatic code quality checks, linting files, etc.mkdocs
to re-generate the documentation files (and other software we may include)
+pre-installed in itThe Codespaces environment is entirely separate from your HA +installation, so does not require any modification to your HA +setup to work with it.
+However, you are modifying code in an environment where you +can't see HA running, so it's great for things like +updating documentation, or writing automated tests, but not +if you need to see your changes live within HA.
+You may with to first install VS Code +on your machine, which does offer some benefits compared to running +Codespaces in the cloud, but this is certainly not essential, and +you'll see the same code editor and terminal, and you'll have the +same commands and Python packages available in the terminal. +The local installation is better in a small number of +scenarios e.g. if you need to connect from your browser to a specific port +on the VM, such as if you're working on the documentation.
+Importantly, even if you do a local install of VS Code and use that
+to edit your code within GitHub, the terminal, the code you're editing
+any commands that you run, and any processes like mkdocs
that you
+may browse to are all running in the Codespaces VM. Your local
+VS Code is connected to the VM through SSH. It will appear as if
+the code, the terminal etc. are local, but they are not. Running
+a local VS Code install connected to Codespaces will not install
+Python, Python packages or anything else on your local machine.
Now, from your fork or branch, click on the Code button, and select the Codespaces tab. +You can create multiple environments, or use a single environment and swap +between branches in it.
+Once you start your Codespaces environment, it'll take a minute to +create a VM for you, and to install the software we've asked it to +install in there. It will also clone your repository and chosen +branch into it for you, and the VM will be authenticated with GitHub +so you can commit and push straight back to your fork of Predbat on GitHub.
+You can choose between running the IDE in the browser, or having +your local installation of VS Code connect to the environment that GitHub +Codespaces has created for you.
+The Codespaces will be already set up with Python, along with various
+Python packages (as defined in requirements.txt
). The environment
+is configured through the config in .devcontainer/devcontainer.json
.
To be documented later.
+The documentation site at https://springfall2008.github.io/batpred/ +is built from Markdown files in this repo.
+The Markdown files used to build the documentation are in the docs/
folder,
+with additional config for building the documentation site in mkdocs.yml
.
If you're making minor changes to the documentation e.g. fixing a spelling,
+you can just edit the Markdown files directly, and it will be pushed to the
+main documentation site as outlined in the documentation build process
+section below, once your changes are merged into main
and released.
However, if you're doing more than that, e.g. adding new sections, working +with lists etc. we recommend you follow the instructions in +working locally on the documentation +below, as this will give you a live preview of what the documentation +will look like once it's build and published. This will avoid any +unexpected results appearing in the main documentation site.
+If you are adding a new file, please ensure you add that file to
+mkdocs.yml
, so it will be linked from the menu in the sidebar.
The documentation for the site is built using mkdocs
, which will
+already be installed if you're using a GitHub Codespaces environment.
For a detailed explanation of mkdocs
features, please read the
+mkdocs
documentation.
As briefly covered above, mkdocs.yml
contains the config for defining the documentation site,
+and the documentation is built by mkdocs
reading the Markdown files in the docs/
folder,
+and creating HTML files from those files. mkdocs
can be used locally for previewing,
+but is also used as part of the documentation build process that publishes
+the official documentation site.
The publishing of the documentation is triggered by a GitHub action,
+as defined in .github/workflows/main.yml
.
In short, after configuring the build environment, mkdocs
builds the
+site, then pushes the HTML produced to the gh-pages
branch,
+overwriting whatever was there previously.
GitHub will then detect a new commit on the gh-pages
branch,
+and that will trigger another action to run (as defined by GitHub).
+This action will take the HTML files on the gh-pages
branch,
+and will make it available at https://springfall2008.github.io/batpred/.
The documentation will be published as it is, with no further +review process, so please ensure you check the documentation +that will be built before merging it in.
+If you are making changes to the documentation, you can see +a live preview version of the documentation as it will be +built and deployed.
+This preview version is local to your environment, is +temporary, and does not impact the published version in any way.
+It's recommended for anything other than simple changes +like fixing spellings, adding a sentence or two. Things like +new sections, lists, new pages etc. are best previewed +due to the complications of various Markdown standards, +as what works on GitHub READMEs, for example, does not +necessarily work with the published documentation site +(which follows a more strict Markdown standard).
+There are a number of terminal commands that you can use in the Codespaces environment. Open a terminal window in Codespaces by choosing menu > Terminal > New Terminal.
+To run the live preview, enter mkdocs serve
in the terminal window - this will cause mkdocs
to build a
+local temporary version of the documentation site,
+and to temporarily publish it on port 8000 - it will
+show the link where you can access the documentation.
Also, it will watch the docs/
folder, and any time you change the
+files, it will rebuild the site, allowing you to see changes to
+the Markdown files in your browser within a few seconds.
The site will continue being served until you press CTRL-C
to
+end the mkdocs serve
command.
Note, accessing the site published by mkdocs serve
is not
+possible if you are using Codespaces to run VS Code in the browser,
+but it is possible if you're using it via VS Code running locally,
+due to the way in which ports on your environment are shared.
This section will be enhanced following discussions as we go.
+However, here's a starting point:
+lower_case_with_underscores
- this fits
+with most existing variables, is a common standard for Python code,
+and also allows the spell checking to check individual words within
+the variable name.Certain coding standards are enforced within the repository. +Some of them can be auto-fixed, if you do a commit that +fails one of those standards; other issues will need fixing +first, as your pull request won't merge in GitHub until it passes.
+These standards are enforced by pre-commit, +a tool which is able to run other tools to check, and potentially fix +(for certain types of issues) any mistakes you've made.
+The .pre-commit-config.yaml
file lists all checks that are
+currently carried out within the repository. Bear in mind that
+these checks are done according to the config within that file
+in the branch that you are working in,
+so if someone adds a new check, or changes some of the related settings,
+it won't apply on your branch until you've merged in their changes.
Some of the tools have their own related config files:
+.cspell.json
and .cspell/custom-dictionary-workspace.txt
pyproject.toml
.markdownlint.jsonc
Additional notes on some of the standards:
+.cspell/custom-dictionary-workspace.txt
and stage those changes.
+The spell-check should then pass. Note, the dictionary file will get
+re-sorted alphabetically when you run pre-commit
, so you'll need to
+re-stage the file after it's been sorted.If you are using a Codespaces environment, you'll already have pre-commit
+installed automatically. You can run it manually, or automatically.
Running pre-commit
manually:
In a terminal window, running pre-commit
will run all the checks against any files that you
+have modified and staged.
Alternatively, running pre-commit run --all-files
will run all the checks
+against all files within the repository.
Note that if pre-commit
makes any changes to any files when it runs,
+those changes will not be staged. You will need to stage those changes too
+before committing.
You may notice pre-commit
mentioning about stashing changes - this is
+because when it runs, any changes that aren't staged are stashed (saved
+away temporarily) so it runs against only the staged changes;
+after it has run, it pulls back those stashed changes, so they appear
+again (still unstaged).
Running pre-commit
automatically:
If you run pre-commit install
in a terminal window it will install a pre-commit hook -
+this is a file which tells git
to run some code each type you do a
+particular action (a pre-commit hook runs at the start of processing
+a commit, but there are other hooks e.g. pre-push).
Now, any time you perform a commit, pre-commit
will run
+automatically on the staged files - this is a handy way of making sure
+that you don't accidentally commit code which will fail checks later.
You can still run it manually as outlined above, in addition to the +automated checks that it will do on commits.
+When commits are done on pull requests, and in any other scenarios
+added to the on
section of.github/workflows/linting.yml
,
+the GitHub Actions in that file will run.
In particular, the pre-commit.ci lite
+action will run. This uses the code here
+to run the same checks that get run locally
+(as described in the .pre-commit-config.yaml
file).
This will cause your commit, branch or pull request to get either a green tick +or a red cross against it, to show whether the code passed the checks or not. +This will happen automatically, when you push code on a branch that has a +pull request.
+In addition, if pre-commit
finds any errors that it is able to fix
+(e.g. a missing blank line at the end of a file, or trailing whitespace),
+it will do a commit of its own to fix those problems, and will push that
+commit back to your branch on GitHub. This will then trigger another run,
+which should now pass.
Note: This means that pre-commit
will be adding commits to
+your branch - this will need you to be pulling changes from GitHub
+so you pick up the changes that have been added by pre-commit
+otherwise you will hit a problem when you next try to push a commit
+on your branch. You can pull in those changes by running git pull
+, which is the equivalent of running git fetch
then git merge
.
+This is no different to working on the same branch with another developer,
+but it will be different to the workflow most of us have when working
+on Predbat.
Predbat needs to know what your Import and (optionally) Export rates are so it can plan the optimal way to use your battery. +Your Import and Export rates can be simple flat rates, +more complex time of day tariffs (e.g. Economy 7, Octopus Flux), +or daily/half-hourly rates that track electricity market prices (e.g. Octopus Agile or Tracker).
+Energy rates are all configured in the apps.yaml
file that's stored in either the /addon_configs/46f69597_appdaemon-predbat/apps
+or the /config/appdaemon/apps/batpred/config/
directory depending on what type of Predbat installation method you have used.
You will need to use a file editor within Home Assistant (e.g. either the File editor or Studio Code Server add-on's) +to edit this file - see editing configuration files within Home Assistant if you need to install an editor.
+If your electricity supplier is Octopus Energy then the simplest way to provide Predbat with your electricity pricing information +is to use the Octopus Energy integration.
+The Octopus Energy integration connects to your Octopus Energy account and retrieves the tariffs you are on, and the current tariff rates. +If you change tariff within Octopus the integration will automatically retrieve the updated tariff information, and as tariff prices change, again they are automatically retrieved.
+The integration also provides support for Intelligent Octopus charging to support car charging.
+Follow the instructions provided in the Octopus Energy integration documentation to install and setup the integration.
+Once installed, you will need to configure the integration (go to Settings / Devices & Services / Integrations / Octopus Energy then click 'Configure') +and provide the integration with your 'Octopus API key' (that you obtain from your Octopus account : Personal Details / API access).
+CAUTION To get detailed energy rates needed by Predbat you need to go into Home Assistant and manually enable the following +Octopus Energy events which are disabled by default when the integration is installed:
+ event.octopus_energy_electricity_xxxxxxxx_previous_day_rates
+ event.octopus_energy_electricity_xxxxxxxx_current_day_rates
+ event.octopus_energy_electricity_xxxxxxxx_next_day_rates
+
+ event.octopus_energy_electricity_xxxxxxxx_export_previous_day_rates
+ event.octopus_energy_electricity_xxxxxxxx_export_current_day_rates
+ event.octopus_energy_electricity_xxxxxxxx_export_next_day_rates
+
+ event.octopus_energy_gas_xxxxxxxx_previous_day_rates
+ event.octopus_energy_gas_xxxxxxxx_current_day_rates
+ event.octopus_energy_gas_xxxxxxxx_next_day_rates
+
+To enable the above events:
+Repeat this for the other events.
+The gas rates are only required if you have a gas boiler, an iBoost, and are using Predbat to determine whether it's cheaper to heat your hot water with the iBoost or via gas.
+Verify that the integration is working correctly in Home Assistant by going to Developer Tools / States, and enter 'octopus' in the 'Filter entities' box. +Confirm that the Octopus entities are being populated correctly.
+The following configuration items in apps.yaml are used to configure Predbat to use the Octopus Energy integration. +They are set to a regular expression and should be auto-discovered so that Predbat automatically uses the Octopus Energy integration, +but you can comment out the regular expression lines to disable, or you set them manually.
+metric_octopus_gas is (as above) only required to be configured if you are using Predbat to determine whether to heat your hot water via your iBoost or gas.
+If you do not have an export rate, or are not on the Octopus Go tariff, then the appropriate lines can be commented out in apps.yaml.
+Predbat can also (optionally) include the daily standing charge in cost predictions. +The following configuration item in apps.yaml defaults to obtaining the standing charge from the Octopus Energy integration:
+You can manually change this to a standing charge in pounds, e.g. 0.50 is 50p, or delete this line from apps.yaml, or set it to zero +if you don't want the standing charge (and only have consumption usage) to be included in Predbat charts and output data.
+Predbat is able to automatically join you to Octopus saving sessions and plan battery activity for the saving session period to maximise your income.
+For Predbat to automatically manage Octopus saving sessions the following additional configuration item in apps.yaml is used. +Like the electricity rates this is set in the apps.yaml template to a regular expression that should auto-discover the Octopus Energy integration.
+When a saving session is available it will be automatically joined by Predbat and should then appear as a joined session within the next 30 minutes.
+In the Predbat plan, for joined saving sessions the energy rates for import and export will be overridden by adding the assumed saving rate to your normal rate. +The assumed rate will be taken from the Octopus Energy integration and converted into pence +using the octopus_saving_session_octopoints_per_penny configuration item in apps.yaml (default is 8).
+As the saving session import and export rates are very high compared to normal Predbat will plan additional export during the saving session period. +If necessary, a pre-charge may happen at some point during the day to maintain the battery right level for the session.
+Note that Predbat's operational mode select.predbat_mode must be set to either 'Control charge' +or 'Control charge & discharge' for Predbat to be able to manage the battery for the saving session.
+If you do not have an export tariff then forced export will not apply and Predbat will just ensure you have enough battery charge to see you through the saving session period.
+If you do not want Predbat to automatically join Octopus saving sessions and manage your battery activity for the session, +simply delete or comment out the octopus_saving_session entry in apps.yaml.
+If you do not wish to use the Octopus Energy integration and are an Octopus Energy customer then you can configure Predbat to get the electricity rates +directly online from the Octopus website.
+In apps.yaml configure the following lines:
+e.g.
+ rates_import_octopus_url : "https://api.octopus.energy/v1/products/FLUX-IMPORT-23-02-14/electricity-tariffs/E-1R-FLUX-IMPORT-23-02-14-A/standard-unit-rates"
+ rates_import_octopus_url : "https://api.octopus.energy/v1/products/AGILE-FLEX-BB-23-02-08/electricity-tariffs/E-1R-AGILE-FLEX-BB-23-02-08-A/standard-unit-rates"
+
+ rates_export_octopus_url: "https://api.octopus.energy/v1/products/FLUX-EXPORT-BB-23-02-14/electricity-tariffs/E-1R-FLUX-EXPORT-BB-23-02-14-A/standard-unit-rates"
+ rates_export_octopus_url: "https://api.octopus.energy/v1/products/AGILE-OUTGOING-BB-23-02-28/electricity-tariffs/E-1R-AGILE-OUTGOING-BB-23-02-28-A/standard-unit-rates/"
+ rates_export_octopus_url: "https://api.octopus.energy/v1/products/OUTGOING-FIX-12M-BB-23-02-09/electricity-tariffs/E-1R-OUTGOING-FIX-12M-BB-23-02-09-A/standard-unit-rates/"
+
+If you configure the rates_import_octopus_url then Predbat will use this instead of metric_octopus or rates_import. +Similarly rates_export_octopus_url takes precedence over metric_octopus_export or rates_export.
+Configuring the Octopus rates URL is an expert feature and for most users the Octopus Energy integration is a simpler solution to use.
+If you are not an Octopus Energy customer, or you are but your energy rates repeat in a simple manner, you can configure your rate bands in apps.yaml using rates_import/rates_export.
+Add the following entries to apps.yaml to define the pattern of rates over a 24-hour period:
+rates_import:
+ - start: "HH:MM:SS"
+ end: "HH:MM:SS"
+ rate: pence
+rates_export:
+ - start: "HH:MM:SS"
+ end: "HH:MM:SS"
+ rate: pence
+
+start and end are in the time format of "HH:MM:SS" e.g. "12:30:00" and should be aligned to 30 minute slots normally. +rate is in pence e.g. 4.2
+start and end can be omitted and Predbat will assume that you are on a single flat rate tariff.
+If there are any gaps in the 24-hour period then a zero rate will be assumed.
+You can also override the energy rates (regardless of whether they are set manually or via the Octopus Energy integration) by using the override feature in apps.yaml.
+Rate override is used to set the specific date and time period where your rates are different, e.g. an Octopus Power Up session (zero rate for an hour or two), +or the British Gas half-price electricity on Sunday's.
+Unfortunately there aren't any API's available to feed this information automatically into Predbat so you will have to edit apps.yaml manually +to set the appropriate rate over-ride dates and times:
+rates_import_override:
+ - date : "YYYY-MM-DD"
+ start : "HH:MM:SS"
+ end : "HH:MM:SS"
+ rate : pence
+rates_export_override:
+ - date : "YYYY-MM-DD"
+ start : "HH:MM:SS"
+ end : "HH:MM:SS"
+ rate : pence
+
+date is in the date format of "YYYY-MM-DD" e.g. "2023-09-09", start and end in "HH:MM:SS" time format e.g. "12:30:00", and rate in pence.
+If you are on an Agile or Tracker tariff you can tune future unknown energy rates by adjusting the entities input_number.predbat_metric_future_rate_offset_import (expert mode) +and input_number.predbat_metric_future_rate_offset_export (expert mode) inside Home Assistant to set the predicted offset for future unknown rates.
+In the energy market it's possible to calculate the Octopus Agile rates from around 10am UK time using public data, you can +enable this in apps.yaml for Import, Export or both. This will approximate next day's rates based on the spot prices. +The approximation is only used until the real Octopus Agile rates are released around 4pm.
+CAUTION: You may violate the terms and conditions of the Nordpool site if you use this data and as such the authors of +Predbat accept no responsibility for any violations:
+https://www.nordpoolgroup.com/en/About-us/terms-and-conditions-for-useofwebsite/
+futurerate_url: '<https://www.nordpoolgroup.com/api/marketdata/page/325?currency=GBP>'
+futurerate_adjust_import: True
+futurerate_adjust_export: False
+futurerate_peak_start: "16:00:00"
+futurerate_peak_end: "19:00:00"
+futurerate_peak_premium_import: 14
+futurerate_peak_premium_export: 6.5
+
+
+ apps.yaml
config to match your own names
+(some people don't have the solcast_ bit in their names)appdaemon.yaml
?# Filter out 'message too large' warnings from Predbat
+logger:
+ default: warning
+ filters:
+ homeassistant.components.recorder.db_schema:
+ - "State attributes for predbat.plan_html exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored"
+
+If you get this error in the Predbat log file:
+If you get this warning message in the Predbat log file:
+If you are still having trouble feel free to raise a Github ticket for support
+ +Home battery prediction and automatic charging for Home Assistant with GivTCP
+Also known by some as Batpred or Batman!
+Copyright (c) Trefor Southwell October 2024 - All rights reserved
+This software maybe used at not cost for personal use only
+No warranty is given, either expressed or implied
+
+For support please raise a Github ticket or use the GivTCP Facebook page:
+https://www.facebook.com/groups/615579009972782
+For support specific to the Solis inverter you can use the Solis Facebook Group:.
+If you want to buy me a beer then please use Paypal - tdlj@tdlj.net
+
These instructions will take you through the process of installing and configuring Predbat for first time use.
+It's recommended that you watch the Video Guides before you start.
+A level of familiarity with the basics of Home Assistant, Add-on's, Integrations, Entities and File Editing is assumed. +There are plenty of "Home Assistant basics" tutorials on YouTube, but if you get stuck, please read the FAQ's +and if necessary raise a Github ticket for support.
+The Integration that communicates with your inverter will be depend on the brand of inverter you have:
+Brand | +Integration | +Github Link | +
---|---|---|
GivEnergy | +GivTCP | +https://github.com/britkat1980/giv_tcp | +
Solis | +SolaX ModBus | +https://github.com/wills106/homeassistant-solax-modbus | +
Sofar | +Sofar MQTT | +https://github.com/cmcgerty/Sofar2mqtt | +
Please see Other Inverters for details on how Solis, Solax and Sofar install details.
+The basic configuration for Predbat is stored in a configuration file called apps.yaml
.
+A standard template apps.yaml file will be installed as part of the Predbat installation and you will need to edit and customise this configuration file for your own system setup.
You will therefore need a method of editing configuration files within your Home Assistant environment.
+There are severals ways to achieve this in Home Assistant, but two of the simplest are to use either the File Editor or Studio Code Server add-on's. +Whichever you use is a personal preference. File Editor is a bit simpler, Studio Code Server is more powerful +but does require HACS (the Home Assistant Community Store) to be installed first.
+If you do not have one of these file editors already installed in Home Assistant:
+Thereafter whenever you need to edit a configuration file in Home Assistant you can navigate to Settings / Add-on's /
If you are using the File Editor to edit Predbat's configuration files, you will need to turn off Enforce Basepath to enable you to access files in the appdaemon directory:
+The simplest way to install Predbat now is with a combined AppDaemon/Predbat add-on. +This is a fork of AppDaemon which automatically includes an install of Predbat.
+Installing the combined AppDaemon-predbat add-on is thus simpler for new users as they do not need to install HACS, AppDaemon and Predbat as three separate installation steps. +If you are already running AppDaemon then the original installation method for Predbat still exists, is still supported, and is described below in Predbat Installation into AppDaemon.
+To install the combined AppDaemon-predbat add-on:
+NOTE: Throughout the rest of the Predbat documentation you will find reference to the Predbat configuration file apps.yaml
and the Predbat logfile.
These are located under the Home Assistant directory /addon_configs/46f69597_appdaemon-predbat
which contains:
You can use your file editor (i.e. 'File editor' or 'Studio Code Server' add-on) to open the directory /addon_configs/46f69597_appdaemon-predbat
and view these files.
If you have used the AppDaemon-predbat add-on installation method you do not need to install HACS or AppDaemon so you can skip directly to Solcast install below.
+This is the "classic" way of installing Predbat, to firstly install HACS (the Home Assistant Community Store), then install the AppDaemon add-on, +and finally install Predbat from HACS to run within AppDaemon.
+Predbat and AppDaemon are available through the Home Assistant Community Store (HACS). You can install Predbat manually (see below) but its usually easier to install it through HACS.
+Predbat is written in Python and runs on a continual loop (default every 5 minutes) within the AppDaemon add-on to Home Assistant. +The next task therefore is to install and configure AppDaemon.
+appdaemon.yaml
configuration file for AppDaemon and so will need to have either
+the File Editor or Studio Code Server add-on's installed firstappdaemon.yaml
file in the directory /addon_configs/a0d7b954_appdaemon
: appdaemon.yaml
configuration file:/homeassistant/appdaemon/apps
where Predbat will be installed/homeassistant/appdaemon/appdaemon.log
and increase the logfile maximum size and number of logfile generations to capture a few days worth of logs.Example AppDaemon config in appdaemon.yaml
:
appdaemon:
+ latitude: 52.379189
+ longitude: 4.899431
+ elevation: 2
+ time_zone: Europe/London
+ thread_duration_warning_threshold: 120
+ plugins:
+ HASS:
+ type: hass
+ app_dir: /homeassistant/appdaemon/apps
+http:
+ url: http://homeassistant.local:5050
+admin:
+api:
+hadashboard:
+
+# write log records to a file, retaining 9 versions, rather than the standard appdaemon log
+logs:
+ main_log:
+ filename: /homeassistant/appdaemon/appdaemon.log
+ log_generations: 9
+ log_size: 10000000
+
+CAUTION: If you are upgrading AppDaemon from an older version to version 0.15.2 or above you need to follow these steps to ensure Predbat continues working. +These are only required if you are upgrading AppDaemon from an old version, they're not required for new installations of AppDaemon:
+/addon_configs/a0d7b954_appdaemon
and edit appdaemon.yaml
. You need to add app_dir (see above) to point to the
+old location and update your logfile location (if you have set it). You should remove the line that points to secrets.yaml
+(most people don't use this file) or adjust it's path to the new location (/homeassistant/secrets.yaml
)/addon_configs/a0d7b954_appdaemon
(new location) to /config/appdaemon
(the old location)If you install Predbat through HACS, once installed you will get automatic updates for each new release of Predbat!
+NOTE: Throughout the rest of the Predbat documentation you will find reference to the Predbat configuration file apps.yaml
and the Predbat logfile.
These are located under the Home Assistant directory /config/appdaemon/
which contains:
A manual install is suitable for those running Docker type systems where HACS does not function correctly and you had to manually install AppDaemon.
+Note: Not recommended if you are using HACS
+/config/appdaemon/apps/
directory in Home Assistant (or wherever you set appdaemon app_dir to)/config/appdaemon/apps/
directory in Home Assistant (or wherever you set appdaemon app_dir to)Edit in Home Assistant the /config/appdaemon/apps/apps.yaml
file to configure Predbat
If you later install with HACS then you must move the apps.yaml
into /config/appdaemon/apps/predbat/config
Predbat needs a solar forecast in order to predict solar generation and battery charging.
+If you don't have solar then use a file editor to comment out the following lines from the Solar forecast part of the apps.yaml
configuration:
pv_forecast_today: re:(sensor.(solcast_|)(pv_forecast_|)forecast_today)
+ pv_forecast_tomorrow: re:(sensor.(solcast_|)(pv_forecast_|)forecast_tomorrow)
+ pv_forecast_d3: re:(sensor.(solcast_|)(pv_forecast_|)forecast_(day_3|d3))
+ pv_forecast_d4: re:(sensor.(solcast_|)(pv_forecast_|)forecast_(day_4|d4))
+
+If you do have solar panels its recommended to use the Solcast integration to automatically retrieve your forecast solar generation. +Predbat is configured to automatically discover the Solcast forecast entities in Home Assistant.
+Install the Solcast integration (https://github.com/oziee/ha-solcast-solar), create a Solcast account, +configure details of your solar arrays, and request an API key that you enter into the Solcast integration in Home Assistant.
+Note that Predbat does not update Solcast for you so you will need to create your own Home Assistant automation that updates the solar forecast a few times a day +(e.g. dawn, dusk, and just before your nightly charge slot).
+Example Solcast update automation script:
+alias: Solcast update
+description: "Update Solcast solar forecast"
+trigger:
+ - platform: time
+ at: "23:00:00"
+ - platform: time
+ at: "12:00:00"
+ - platform: time
+ at: "04:00:00"
+condition: []
+action:
+ - service: solcast_solar.update_forecasts
+ data: {}
+mode: single
+
+Manually run the automation and then make sure the Solcast integration is working in Home Assistant by going to Developer Tools / States, filtering on 'solcast', +and checking that you can see the half-hourly solar forecasts in the Solcast entities.
+Predbat needs to know what your electricity import and export rates are in order to optimise battery charging and discharging to minimise your expenditure.
+These rates are configured in Predbat's apps.yaml
configuration file. Follow the instructions in the Energy Rates document.
Note: that if you are using the Octopus integration the 'sensor.octopus_xxx' and 'event.octopus_xxx' entities must have a similar pattern of +names for Predbat to work correctly - see the FAQ's if they are not.
+You will need to use a file editor (either the File editor or Studio Code Server add-on) to edit the apps.yaml
file in Home Assistant
+to configure Predbat - see Configuring apps.yaml.
When Predbat starts up initially it will perform a sanity check of the AppDaemon configuration itself and confirm the right files are present. +You will see this check in the log, should it fail a warning will be issued and predbat.status will also reflect the warning. +While the above warning might not prevent Predbat from starting up, you should fix the issue ASAP as it may cause future problems.
+As described above, the basic configuration of Predbat is held in the apps.yaml
configuration file.
When Predbat first runs it will create a number of output and configuration control entities in Home Assistant which are used to fine-tune how Predbat operates. +The entities are all prefixed predbat and can be seen (and changed) from the Settings / Devices & Services / Entities list in Home Assistant.
+It is recommended that you create a dashboard page with all the required entities to control Predbat +and another page to display Predbat's charging and discharging plan for your battery.
+The Output Data section describes these points in more detail.
+The Home Assistant entity predbat.status contains details of what status Predbat is currently in (e.g. Idle, Charging, Error). +Detailed progress messages and error logging is written to the Predbat logfile which you can view within Home Assistant using a file editor.
+The Predbat Configuration Guide gives an overview of the main Predbat configuration items and +detail of 'standard Predbat configuration' settings for different electricity tariff types - e.g. a cheap overnight rate, +multiple import rates during the day, and variable tariffs such as Agile, etc.
+The detailed Predbat Customisation Guide details all the Predbat configuration items (switches, input numbers, etc) in Home Assistant, and what each of them does.
+By now you should have successfully installed and configured Predbat in AppDaemon and the other components it is dependent upon (e.g. GivTCP, Solcast, Octopus Integration).
+You have checked the Predbat AppDaemon log file doesn't have any errors (there is a lot of output in the logfile, this is normal).
+You have configured predbat's control entities, created a couple of dashboard pages to control and monitor Predbat, and are ready to start Predbat running.
+In order to enable Predbat you must delete the 'template: True' line in apps.yaml
once you are happy with your configuration.
You may initially want to set select.predbat_mode to Monitor to see how Predbat operates, e.g. by studying the Predbat Plan.
+Once you are happy with the plan Predbat is producing, and are ready to let Predbat start controlling your inverter, set select.predbat_mode +to the correct mode of operation for your system.
+Note that future updates to Predbat will not overwrite the apps.yaml
configuration file that you have tailored to your setup.
+You may therefore need to manually copy across any new apps.yaml settings from the Template apps.yaml for new features.
HACS checks for updates and new releases only once a day by default, you can however force it to check again, or download a specific version +by using the 'Redownload' option from the top-right three dots menu for Predbat in the HACS Automation section.
+NOTE: If you update Predbat through HACS you may need to restart AppDaemon as it sometimes reads the config wrongly during the update.
+(If this happens you will get a template configuration error in the entity predbat.status).
+Go to Settings, Add-ons, AppDaemon, and click 'Restart'.
Predbat can now update itself, just select the version you want from the select.predbat_update drop down menu, the latest version will be at the top of the list. +Predbat will update itself and automatically restart.
+Alternatively, if you turn on switch.predbat_auto_update, Predbat will automatically update itself as new releases are published on Github.
+If you have used the Combined AppDaemon and Predbat add-on installation method then +once installed and configured you should update Predbat to the latest version by using the select.predbat_update selector or by enabling the switch.predbat_auto_update.
+You can go to Github and download predbat.py from the releases tab and then manually copy this file
+over the existing version in /config/appdaemon/apps/batpred/
manually.
Please see the sections below for how to achieve each step. This is just a checklist of things:
+apps.yaml
configuration file to to match your system - apps.yaml settings/addon_configs/46f69597_appdaemon-predbat/apps
+or /config/appdaemon/apps/predbat/config/
depending on which Predbat install method you used.Overview of the key configuration elements:
+PredBat was originally written for GivEnergy inverters using the GivTCP integration but this is now being extended to other models:
+Note that support for all these inverters is in various stages of development. Please expect things to fail and report them as Issues on Github. +Please also ensure you have set up enhanced logging in AppDaemon as described here.
+To run PredBat with Solis hybrid inverters, follow the following steps:
+Name | +Description | +
---|---|
sensor.solisx_rtc |
+Real Time Clock | +
sensor.solisx_battery_power |
+Battery Power | +
apps.yaml
use ginlong_solis.yaml
from this Repo as your starting template.
+ The majority of settings should be correct but please check.
+ You will need to un-comment the template
line to enable it. Save it to the config/appdaemon/apps/predbat/config
folder.Timed Charge/Discharge
.
+ If you want to use the Reserve
functionality within PredBat you will need to select Backup/Reserve
(code 51) instead but be aware that
+ this is not fully tested. In due course these mode settings will be incorporated into the code.Please see this ticket in Github for ongoing discussion: https://github.com/springfall2008/batpred/issues/259
+For this integration the key elements are:
+This integration has various limitations, it can charge and discharge the battery but does not have finer control over reserve and target SOC%
+Note: You will need to change the min reserve in Home Assistant to match your minimum battery level.
+Please see this ticket in Github for ongoing discussions: https://github.com/springfall2008/batpred/issues/395
+ +Each Predbat config item has an input_number or switch associated with it, you can find an auto-generated dashboard for your +configuration in your AppDaemon configuration area under the filename predbat_dashboard.yaml. +You will need to open that file in a Home Assistant file editor and copy the contents into a new dashboard page.
+You can also create a dashboard page using dynamic-entities-card.yaml for a +dynamically created list of all Predbat entities which groups the entities by type and is collapsed by default to prevent screen clutter. Requires lovelace-collapsable-cards +(https://github.com/RossMcMillan92/lovelace-collapsable-cards) +and lovelace-auto-entities (https://github.com/thomasloven/lovelace-auto-entities) +to be installed via HACS as well as the stock vertical stack card. Credit @DJBenson for the code.
+The Predbat Plan card is very useful for seeing the plan that Predbat has created - Create the Predbat Plan card.
+A set of Apex Charts can also be created to see graphically what Predbat plans to do - Creating the charts.
+What your battery is expected to do with no changes made by Predbat:
+The calculated baseline results under PV 10% scenario:
+When calculate_best is enabled a second set of entities are created for the simulation based on the best battery charge percentage:
+The calculated best results under PV 10% scenario:
+Predbat writes detailed logging, status and progress activity information to a logfile as it runs and so this file should be checked if predbat.status reports an error, +or if you want to verify that Predbat is running OK.
+There is a lot of output in the logfile, this is normal!
+Depending upon whether you have used the combined AppDaemon/Predbat add-on installation method or the +HACS, Appdaemon add-on then Predbat installation method, the logfile will be held in one of two directories in Home Assistant:
+/addon_configs/46f69597_appdaemon-predbat/predbat.log
if you used the combined AppDaemon/Predbat add-on installation methodor
+/homeassistant/appdaemon/appdaemon.log
if you used the HACS, AppDaemon add-on then Predbat installation methodYou will need to use a file editor within Home Assistant (e.g. either the File editor or Studio Code Server add-on's) +to view Predbat's logfile - see editing configuration files within Home Assistant if you need to install an editor.
+With GivTCP and Predbat performing an important function, managing your battery charging and discharging to best reduce your electricity bills, +you may find these automations useful to monitor that GivTCP and Predbat are running OK, and if not, to raise an alert on your mobile device.
+This automation will raise an alert if any of the following occur:
+The script will need to be customised for your inverter id, battery id and mobile details, and can be extended for multiple inverters and batteries.
+alias: GivTCP activity monitor
+description: Alert when communications to GivTCP have ceased for 30 minutes
+trigger:
+ - platform: state
+ entity_id: sensor.givtcp_<inverter id>_last_updated_time
+ to: null
+ for:
+ minutes: 30
+ id: no-givtcp-update
+ variables:
+ inv_id: inverter <id>
+ - platform: state
+ entity_id:
+ - sensor.givtcp_<inverter id>_status
+ from: online
+ for:
+ minutes: 30
+ id: no-givtcp-update
+ variables:
+ inv_id: inverter <id>
+ - platform: state
+ entity_id:
+ - sensor.givtcp_<battery id>_battery_cells
+ to: unknown
+ for:
+ minutes: 30
+ id: battery-unavailable
+ variables:
+ batt_id: <batt size/id>
+action:
+ - condition: trigger
+ id:
+ - no-givtcp-update
+ - service: notify.mobile_app_<your mobile device id>
+ data:
+ title: GivTCP communication issue
+ message: |
+ {{ now().timestamp() | timestamp_custom('%-d %b %H:%M') }} ISSUE:
+ No GivTCP update received from {{ inv_id }} for the past 30 minutes.
+ data:
+ visibility: public
+ persistent: true
+ push:
+ sound:
+ name: default
+ critical: 1
+ volume: 0.8
+ sticky: true
+ color: red
+ - condition: trigger
+ id:
+ - battery-unavailable
+ - service: notify.mobile_app_<your mobile device id>
+ data:
+ title: GivTCP communication issue
+ message: |
+ {{ now().timestamp() | timestamp_custom('%-d %b %H:%M') }} ISSUE:
+ Battery {{ batt_id }} offline to GivTCP for the past 30 minutes.
+ data:
+ visibility: public
+ persistent: true
+ push:
+ sound:
+ name: default
+ critical: 1
+ volume: 0.8
+ sticky: true
+ color: red
+mode: single
+
+This automation will raise an alert if Predbat's status turns to ERROR for more than 10 minutes.
+The script will need to be customised for your mobile details.
+alias: predbat error monitor
+description: Alert when Predbat has raised an exception
+trigger:
+ - platform: state
+ entity_id:
+ - predbat.status
+ to: "ERROR: Exception raised"
+ for:
+ minutes: 10
+ - platform: template
+ value_template: "{{ 'ERROR' in states('predbat.status') }}"
+ for:
+ minutes: 10
+action:
+ - service: notify.mobile_app_<your mobile device id>
+ data:
+ title: Predbat status issue
+ message: |
+ {{ now().timestamp() | timestamp_custom('%-d %b %H:%M') }} ISSUE:
+ predbat status is {{ states('predbat.status') }}
+ data:
+ visibility: public
+ persistent: true
+ push:
+ sound:
+ name: default
+ critical: 1
+ volume: 0.8
+ sticky: true
+ color: red
+mode: single
+
+An error alert looks like this:
+Predbat can create its own plan card which can be added to your HA dashboard.
+Next create a new card as follows:
+type: custom:html-template-card
+title: Predbat plan
+ignore_line_breaks: true
+content: |
+ {{ state_attr('predbat.plan_html', 'html') }}
+
+You should see something like this:
+' + escapeHtml(summary) +'
' + noResultsText + '
'); + } +} + +function doSearch () { + var query = document.getElementById('mkdocs-search-query').value; + if (query.length > min_search_length) { + if (!window.Worker) { + displayResults(search(query)); + } else { + searchWorker.postMessage({query: query}); + } + } else { + // Clear results for short queries + displayResults([]); + } +} + +function initSearch () { + var search_input = document.getElementById('mkdocs-search-query'); + if (search_input) { + search_input.addEventListener("keyup", doSearch); + } + var term = getSearchTermFromLocation(); + if (term) { + search_input.value = term; + doSearch(); + } +} + +function onWorkerMessage (e) { + if (e.data.allowSearch) { + initSearch(); + } else if (e.data.results) { + var results = e.data.results; + displayResults(results); + } else if (e.data.config) { + min_search_length = e.data.config.min_search_length-1; + } +} + +if (!window.Worker) { + console.log('Web Worker API not supported'); + // load index in main thread + $.getScript(joinUrl(base_url, "search/worker.js")).done(function () { + console.log('Loaded worker'); + init(); + window.postMessage = function (msg) { + onWorkerMessage({data: msg}); + }; + }).fail(function (jqxhr, settings, exception) { + console.error('Could not load worker.js'); + }); +} else { + // Wrap search in a web worker + var searchWorker = new Worker(joinUrl(base_url, "search/worker.js")); + searchWorker.postMessage({init: true}); + searchWorker.onmessage = onWorkerMessage; +} diff --git a/search/search_index.json b/search/search_index.json new file mode 100644 index 000000000..c064f9142 --- /dev/null +++ b/search/search_index.json @@ -0,0 +1 @@ +{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Introduction Home battery prediction and automatic charging for Home Assistant with GivTCP Also known by some as Batpred or Batman! Copyright (c) Trefor Southwell October 2024 - All rights reserved This software maybe used at not cost for personal use only No warranty is given, either expressed or implied For support please raise a Github ticket or use the GivTCP Facebook page: https://www.facebook.com/groups/615579009972782 For support specific to the Solis inverter you can use the Solis Facebook Group: . If you want to buy me a beer then please use Paypal - tdlj@tdlj.net","title":"Introduction"},{"location":"#introduction","text":"Home battery prediction and automatic charging for Home Assistant with GivTCP Also known by some as Batpred or Batman! Copyright (c) Trefor Southwell October 2024 - All rights reserved This software maybe used at not cost for personal use only No warranty is given, either expressed or implied For support please raise a Github ticket or use the GivTCP Facebook page: https://www.facebook.com/groups/615579009972782 For support specific to the Solis inverter you can use the Solis Facebook Group: . If you want to buy me a beer then please use Paypal - tdlj@tdlj.net","title":"Introduction"},{"location":"apps-yaml/","text":"apps.yaml settings The basic configuration for Predbat is configured in the apps.yaml file. Depending on whether you have used the combined AppDaemon/Predbat add-on installation method or the HACS, Appdaemon add-on then Predbat installation method , the apps.yaml file will be held in one of two directories in Home Assistant: /addon_configs/46f69597_appdaemon-predbat/apps if you used the combined AppDaemon/Predbat add-on installation method or /config/appdaemon/apps/batpred/config/ if you used the HACS, AppDaemon add-on then Predbat installation method You will need to use a file editor within Home Assistant (e.g. either the File editor or Studio Code Server add-on's) to edit the apps.yaml file - see editing configuration files within Home Assistant if you need to install an editor. This section of the documentation describes what the different configuration items in apps.yaml do. When you edit apps.yaml , AppDaemon will automatically detect the change and Predbat will be reloaded with the updated file. You don't need to restart the AppDaemon add-on for your edits to take effect. Templates You can find template configurations in the following locations: Template Link GivEnergy apps.yaml SolisX apps.yaml SolarEdge apps.yaml The GivEnergy template will be installed by default but if you are using another inverter please copy the correct template into the directory where your apps.yaml is stored, and modify it from there. Basics Basic configuration items prefix - Set to the prefix name to be used for all entities that predbat creates in Home Assistant. Default 'predbat'. Unlikely that you will need to change this. timezone - Set to your local timezone, default is Europe/London. It must be set to a valid Python time zone for your location template - Initially set to True, this is used to stop Predbat from operating until you have finished configuring your apps.yaml. Once you have made all other required changes to apps.yaml this line should be deleted or commented out. notify_devices - A list of device names to notify when Predbat sends a notification. The default is just 'notify' which contacts all mobile devices days_previous - A list (one entry per line) of the number of days of historical house load to be used to predict your future daily load. It's recommended that you set days_previous so Predbat uses sufficient days' history so that 'unusual' load activity (e.g. saving sessions, \"big washing day\", etc) get averaged out. Typical settings could be 1, 7 or 7, 14, or 2, 3, 4, 5, 6, 7, 8. Do keep in mind that Home Assistant only keeps 10 days history by default, so you might need to increase the number of days history kept in HA before its purged by editing and adding the following to the /homeassistant/configuration.yaml configuration file and restarting Home Assistant afterwards: recorder: purge_keep_days: 14 days_previous_weight - A list (one entry per line) of weightings to be applied to each of the days in days_previous. Default value is 1, that all history days are equally weighted. forecast_hours - the number of hours to that Predbat will forecast ahead, 48 is the suggested amount, although other values can be used such as 30 or 36 if you have a small battery and thus don't need to forecast 2 days ahead. Inverter information The template apps.yaml comes pre-configured with regular expressions that should auto-discover the GivTCP Home Assistant entity names. If you have more than one inverter or entity names are non-standard then you will need to edit apps.yaml for your inverter entities. For other inverter brands, see Other Inverters num_inverters - The number of inverters you have. If you increase this above 1 you must provide multiple of each of the inverter entities geserial - This is a helper regular expression to find your serial number, if it doesn't work edit it manually or change individual entities to match. Historical data Predbat can either get historical data (house load, import, export and PV generation) directly from GivTCP or it can obtain it from the GivEnergy cloud. Unless you have a specific reason to not use the GivTCP data (e.g. you've lost your GivTCP data), its recommended to use GivTCP. Data from GivTCP The following configuration entries in apps.yaml are pre-configured to automatically use the appropriate GivTCP sensors. If you have a 3-phase electricity supply and one inverter (and battery) on each phase then you will need to add one line for the load, import, export and PV sensors for each of the 3 phases. If you have a single phase electricity supply and multiple inverters on the phase then you will need to add one line for each of the load and PV sensors. You don't need multiple lines for the import or export sensors as each inverter will give the total import or export information. Edit if necessary if you have non-standard GivTCP sensor names: load_today - GivTCP Entity name for the house load in kWh today (must be incrementing) import_today - GivTCP Imported energy today in kWh (incrementing) export_today - GivTCP Exported energy today in kWh (incrementing) pv_today - GivTCP PV energy today in kWh (incrementing). If you have multiple inverters, enter each inverter PV sensor on a separate line. If you have an AC-coupled GivEnergy inverter then enter the Home Assistant sensor for your PV inverter. If you don't have any PV panels, comment or delete this line out of apps.yaml. See the Workarounds section below for configuration settings for scaling these if required. If you have multiple inverters then you may find that the load_today figures from GivTCP are incorrect as the inverters share the house load between them. In this circumstance one solution is to create a Home Assistant template helper to calculate house load from {pv generation}+{battery discharge}-{battery charge}+{import}-{export}. e.g. {{ states('sensor.givtcp_XXX_pv_energy_today_kwh')|float(0) +All the video guides are now available on my YouTube channel: Springfall2008
+Playlist of Predbat installation videos
+Predbat installation - Predbat, Solcast, Dashboard, Charts and Plans
+Playlist of other Predbat configuration videos
+Playlist of Predbat feature videos
+Predbat is a home battery automation program.
+It automatically runs every 5 minutes and will update its prediction for the home battery levels for the next period, up to a maximum of 48 hours ahead. +Predbat will automatically decide when to charge and discharge your battery to achieve the best (lowest) cost spend within the parameters you have set. +It uses the solar production forecast from Solcast combined with your historical +energy usage to make this prediction.
+When you first install Predbat it will be in 'Monitor' mode.
+You can configure Predbat's mode of operation using the drop down menu in select.predbat_mode. +You will find a full description of Predbat Modes in the Customisation Guide.
+Once you are ready for Predbat to take control move this setting to one of the active control modes.
+The current Predbat status is reported in the Home Assistant entity predbat.status:
+Idle - This is the default, the load will be covered by solar and/or battery. Excess solar will charge the battery or be +exported if the battery is full. This is described as 'ECO' Mode for GivEnergy inverters but other inverters use different terminology.
+Charging - The battery charges from the grid and the grid also covers any load. Solar power will also be used to charge the battery.
+No Charge - A charge where the target SOC % is lower than the current battery SOC level so there will be no charging unless the usage is unexpectedly high.
+Discharging - The battery is being force-discharged. The house load will be covered by the battery and any excess is exported to the grid. Any solar generated will be exported.
+Freeze discharging - The battery is covering the load but charging is disabled, thus any solar generated will be exported.
+Error - There is a configuration error or other problem, you should check the Predbat AppDaemon log file for more details.
+