Configuring Set Tariff - TonyM1958/FoxESS-Cloud GitHub Wiki
set_tariff() is used to set the tariff details that determine the charge times, peak and off-peak times and prices and other parameters.
Tariffs
f.set_tariff('agile', region='H')
The first parameter for set_tariff() selects from a list of different pre-configured tariffs. The parameter can be the full or part of the name of the tariff and sets the following time periods:
- Octopus Flux: off-peak from 02:00 to 05:00, peak from 16:00 to 19:00, forecasts from 22:00 to 23:59. Timed work mode changes to Self Use at 5am and Feed In First at 4pm.
- Intelligent Octopus: off-peak from 23:30 to 05:30, forecasts from 22:00 to 23:59
- Octopus Cosy: off-peak from 04:00 to 07:00, 13:00 to 16:00 and 22:00 to 24:00, peak from 16:00 to 19:00, forecasts from 01:00 to 02:59 and 10:00 to 11:59
- Octopus Go: off peak from 00:30 to 04:30, forecasts from 22:00 to 23:59
- Agile Octopus: off-peak from 00:00 to 06:00 and 12:00 to 16:00, peak from 16:00 to 19:00, forecasts from 10:00 to 11:59 and 22:00 to 23:59
- British Gas Electric Driver: off-peak from 00:00 to 05:00, forecasts from 22:00 to 23:59
- EON Next Drive: off-peak from 00:00 to 07:00, forecasts from 22:00 to 23:59
- Eco 7: Economy 7: off-peak from 00:30 to 07:30 GMT (01:30 to 08:30 during BST)
Custom periods can be configured for specific times if required:
- Custom: off-peak from 02:00 to 05:00, peak from 16:00 to 18:59, forecasts from 22:00 to 23:59
Region
Region codes include:
- 'A' = Eastern England
- 'B' = East Midlands
- 'C' = London
- 'D' = Merseyside and Northern Wales
- 'E' = West Midlands
- 'F' = North Eastern England
- 'G' = North Western England
- 'H' = Southern England (default)
- 'J' = South Eastern England
- 'K' = Southern Wales
- 'L' = South Western England
- 'M' = Yorkshire
- 'N' = Southern Scotland
- 'P' = Northern Scotland
Configuring Strategies
Strategies are used to change the work mode of the inverter over time, when timed_mode is set to 1 or 2:
- in timed_mode 1, the strategy is used to track the inverter charging / discharging behaviour only. This is used where, for example, Home Assistant automations are used to change the work mode at specific times
- in timed_mode 2, the strategy is converted into a schedule and downloaded to the inverter, along with any plunge slots and charge slots. The inverter supports a maximum of 8 slots; if the number of slots would exceed 8, the most expensive plunge slots are removed
Any strategy time segments that overlap a charge time for the tariff will be dropped.
The 'strategy' parameter configures the times when work modes will be changed. The parameter is a list of dictionary items, containing:
- 'start', 'end': times in decimal hours or time format. The end time is exclusive so setting an end time of '07:00' will set a schedule that ends at '06:59'
- 'mode': the work mode to be used from 'SelfUse', 'Feedin', 'Backup', 'ForceCharge', 'ForceDischarge'
- 'min_soc, 'fdsoc', 'fdpwr' and 'max_soc': optional values for each work mode. The defaults are 10, 10, 0 and 100 respectively.
For example, this line configures the inverter for SelfUse between 7am and noon and FeedIn between 4pm and 7pm:
f.set_tariff( ..., strategy = [
{'start': 7, 'end': 12, 'mode': 'SelfUse'},
{'start': 16, 'end': 19, 'mode': 'FeedIn'}],
... )
Strategies can include periods for Force Charge and Force Discharge if required. It is best not to put Force Charge times into the strategy unless absolutely necessary as this will reduce the ability of charge_needed() to configure optimal charge times.
Plunge Pricing
Plunge pricing allows for the automatic configuration of charging periods when Agile prices are low.
The parameters are:
- 'plunge_pricing' is a price or list of prices. If the price for a 30 minute period is below this price, a plunge charging period is added to the schedule. The default is [3, 3]
- 'plunge_slots' sets the maximum number of 30 minute plunge charging slots to use. The default is 6
When a list of prices is used, the values are spread over 24 hours starting with the first value at 7am:
- if 2 prices are provided, the first applies between 7am and 7pm and the second applies between 7pm and 7am. This allows different prices to be applied for day-time and night-time.
- if 3 prices are provided, each covers 8 hours so the time slots are 7am-3pm, 3pm-11pm and 11pm-7am
- with 4 prices, each covers 6 hours so the time periods are 7am-1pm, 1pm-7pm, 7pm-1am, 1am-7am etc
For example, these parameters set the price threshold to 3p/kWh between 7am and 7pm and 10p/kWh between 7pm and 7am. The aim is to increases the likelyhood of plunge slots at night without more adding more day time plunge slots as these could conflict with PV generation, stop the battery being used and cause clipping.
f.set_tariff( ..., plunge_pricing = [3, 10], ... )
Customising the Times
Multiple off-peak and peak periods can be configured using the 'times' parameter. Times is a list of tuples containing values for key, 'start', 'end' and optional 'hold'.
- recongnised keys are: 'off_peak1', 'off_peak2', 'off_peak3', 'off_peak4', 'peak1', 'peak2'
- a tuple containing a key with no values will remove the time period from the tariff.
For example, this parameter configures an AM charging period between 11pm and 8am and a PM charging period between 12 noon and 4pm and removes the time period 'peak2':
- times=[("off_peak1", "23:00", "8:00"), ("off_peak2", "12:00", "16:00"), ("peak2")]