nathanmarlor / foxess_em

FoxESS - Energy Management
MIT License
55 stars 3 forks source link
energy foxess homeassistant

FoxESS - Energy Management

GitHub Release GitHub Activity License

pre-commit Black

hacs Project Maintenance BuyMeCoffee

Discord Community Forum

** This project is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by FoxESS **

Introduction

A Home Assistant custom component designed to maximises solar, battery and grid usage and avoid peak rate tarriffs.

This integration will ensure that your home batteries are charged to the optimal level when the forecasted solar output drops below your daily average usage. The integration will also ensure that, given a day where the solar forecast is greater than your daily average usage, the battery has enough charge to last until dawn.

To further ease managing the battery state, the integration includes a switch to boost (+1kW) the battery charge and a second switch to charge fully; this is useful for times when you expect a higher than average load.

Example showing the integration:

Example

Assumptions/Dependencies

These may change as development progresses:

Installation

Recommend installation through HACS

  1. Navigate to HACS integrations
  2. Hit the menu button (top right) and select 'Custom repositories'
  3. Paste this GitHub link and select 'Integration'
  4. Install as usual through HACS
    • 'Explore & Download Repositories'
    • Search for 'FoxESS...'
    • Download

Configuration and Options

Solcast Setup

- **API Key**: API Key from Solcast Toolkit ![Solcast Setup](images/config-step-1.png)
Inverter Connection Setup

Choose from one of the following options: ![Inverter](images/config-step-2.png) Modbus TCP (Only compatible with RTU -> TCP devices, not direct LAN) - **Modbus Host**: IP Adddress of your Modbus (i.e. W610) host - **Modbus Port**: Port number (default 502) - **Modbus Slave**: Slave ID (default 247) ![TCP](images/config-step-2-tcp.png) Modbus Serial - **Modbus Host**: Path to your USB host (default /dev/ttyUSB0) - **Modbus Slave**: Slave ID (default 247) ![SERIAL](images/config-step-2-serial.png) FoxESS Cloud - **API Key**: API Key from FoxESS Cloud. To find this, go to https://www.foxesscloud.com/, select the User icon in the top right corner and select User Profile, then select API Management and generate an API key if you do not already have one. Do not generate a new key if you have already generated one for something else (e.g. [foxess-ha](https://github.com/macxq/foxess-ha)), as this will invalidate the previous key and you will have to reconfigure your other uses. ![FOX](images/config-step-2-fox.png)
Battery Parameters

Enter your desired battery parameters: - **Eco Start Time**: Start time of your off-peak period (i.e. 00:30 on Octopus Go) - **Eco End Time**: End time of your off-peak period (i.e. 4:30 on Octopus Go) - **Dawn Buffer**: As forecasts and usage patterns can change, leave a buffer to ensure the battery doesn't get too close to empty - **Day Buffer**: As above, but for the day - **Battery Capacity**: Capacity of battery in kWh - **Minimum SoC**: Minimum State of Charge as set in the FoxESS App If using Modbus connection: - **Charge Rate**: Nominal charge rate in A - for a 3.6kw inverter this should be ~18A - **Battery Volts**: Nominal battery voltage in V - i.e. 4 x HV2600 is ~220V ![Battery Params](images/config-step-3.png)
Home Assistant Sensors

- **Battery SoC**: Battery State of Charge sensor - must be an integer % - **House Power**: House load power - must be kW - **Aux Power**: Aux sensors to remove from the house power, i.e. an Eddi, Zappi charger etc. which will skew the base house load calculations - must be W ![HA Sensors](images/config-step-4.png)

Sensors and Switches

Sensors

Description of sensors: Notes: - all capacity values are forward looking to the next period once past the eco-start time
| Sensor | Description | Attributes | | ---------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | Capacity: Battery Empty Time | Forecasted time battery will be depleted (Unknown if battery is empty) | | | Capacity: Charge Needed | Charge needed for the next off-peak period | Dawn charge needed
Day charge needed
Min SoC | | Capacity: Eco Start | Forecasted battery capacity at the start of the off-peak period | | | Capacity: Next Dawn Time | Forecasted next dawn time (i.e. solar output > house load) | | | Capacity: Peak Grid Export | Forecasted solar export to grid until the next off-peak period | | | Capacity: Peak Grid Import | Forecasted import from grid until the next off-peak period | | | Forecast: API Count | Number of hits against the Solcast API | | | Forecast: Today | Forecasted solar output for today | | | Forecast: Today Remaining | Forecasted solar output remaining (resampled to 1Min for continual updates) | | | Forecast: Tomorrow | Forecasted solar output for tomorrow | | | Last Update | Last update time | Battery last update
Forecast last update
Average last update
| | Load: Daily | Total load, averaged over the last 2 complete days | | | Load: Peak | Peak only load (i.e. outside of the Go period), averaged over the last 2 complete days | | | FoxESS EM: Schedule | Entity to persist the schedule | Schedule stored as JSON | | FoxESS EM: Raw Data | Entity to persist the the raw data for graphing purposes | Raw data stored as JSON - disabled by default |
Switches

Description of switches: | Switch | Description | | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | Boost Charge (+1kW) | Adds 1kW to the charge needed sensor. Resets after the charge period. | | Disable Auto Charge | Prevents the integration from changing FoxESS settings to auto-charge or setting Min-SoC | | Full Charge | Fully charges the battery during off-peak. Resets after the charge period. | | Custom Charge Profile (Modbus Only) | Uses a custom charge profile which reduces charge current to meet the desired SoC and further ramps when > 90% SoC to aid with balancing |

Extras

Graphing & Home Assistant Tweaks Important! Before following this guide add the following to your configuration.yaml to prevent the HA database becoming bloated ``` recorder: exclude: entities: - sensor.foxess_em_raw_data - sensor.foxess_em_forecast ``` - Enable the FoxESS Raw Data entity from the entity settings: ![Service](images/raw-data-entity.png)

- Install Apex Charts from HACS - Use the templated example in the /apex-example folder ![Raw Data Graph](images/raw-data-graph.png)

Dashed = predicted / Solid = actual
Battery = blue / Load = pink / Solar = orange / Grid = green
Energy Dashboard Forecast ![Energy Dash Setup](images/energy-dashboard-config.png)

![Energy Dash](images/energy-dashboard.png)
Service Calls - Start force charge now - Start force charge at off-peak - Stop force charge ![Service](images/service.png)

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines

Credits

Thanks to the awesome work from oziee and StealthChesnut