This post is about setting up FoxESS (Inverter and solar batteries) in Home Assistant and the steps to get the integration to work, allowing real-time data to be viewed in a dashboard on a computer, tablet or mobile phone. Click the link to find out how we came to get the FoxESS solar battery and inverter solution.
Why Home Assistant?
Because the cloud-based solution FoxESS offers through their mobile app or browser is flakey at best. I don’t use it anymore because whenever I look at it, the site is either down or there is a problem. On the rare occasion, I have successfully loaded it, the information is minimal and delayed by 5 minutes. I would much rather have real-time data that can be incorporated into a custom dashboard.
What is FoxESS?
Fox is a global leader in developing inverter and energy storage solutions. Gas & Electrics Services based in East Grinstead installed my inverter and batteries solution. I’ll do another post on the installation soon.
What is Home Assistant?
Home Assistant is an open-source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect for running on a Raspberry Pi or a local server.
What is a Raspberry Pi?
It is a tiny, dual-display desktop computer or a robot brain, a smart home hub, a media centre, a networked AI core, a factory controller, and much more.
Prerequisites for Home Assistant and following these instructions.
- You’ll need a Raspberry Pi 4 Model B for this installation guide.
- A computer to flash home assistant to a Micro SD card.
- Some knowledge of Micro SD cards (they might look the same, but they are different).
- Know how to run commands in Windows Command Prompt.
- There are over 70 steps involved, but fear not; I’ve provided screenshots for everything. 🙂
- Some common sense and a lot of patience.
Flashing Home Assistant for Raspberry Pi 4 Model B on a Micro SD Card.
- Using the application BalenEtcher, flash the Home Assistant image (https://github.com/home-assistant/operating-system/releases/download/9.3/haos_rpi4-64-9.3.img.xz) to an Application Class 2 Micro SD card.
- Insert the Micro SD Card into the Raspberry Pi 4 Model B, add a power cable, network cable and HDMI and boot it up.
- Retrieve the IP address from the Home Assitant boot screen. Mine started with 192.168.xxx.xxx, but yours could be anything your network is configured to.
How to load Home Assistant on a PC?
- Go to a browser on your PC and type in the HTTP IPv4 address shown on the home Assistant screen earlier.
- Set up a username and password and configure the location, unit & currency.
- Accept all the default toggles and log into Home Assistant.
- Click on your account or profile at the bottom and toggle on the Advanced mode.
How to install Add-ons like File Editor, Terminal & SSH on Home Assistant?
- Click Settings, Add-ons, Add-on store, select File editor, then Install. Wait for it to install, then select the toggle on Watchdog, Auto-Update and Show in the sidebar.
- Click on Start.
- Go back to the Add-on page and search for Terminal & SSH.
- Click on it and click Install.
- Wait for it to install, then select the toggle on Watchdog, Auto-Update and Show in the sidebar.
- Click on Start.
- If you plan to use SSH to log into your Raspberry Pi 4 from a different PC, you’ll want to set up a password. Click into the Configuration, and in the Password section, type in a password.
- Under the Network, add 22 as the port.
- Click Save and click on Restart.
How to set up an SSH application on your PC?
- With Terminal & SSH enabled, you can use any application to connect to the Home Assistant via SSH, which makes editing files much more accessible. I prefer using WinSCP on my windows machine to edit files, but anything that supports SSH will work. Remember to use the same password added to the configuration.
- Add the hostname (from the above steps).
- Set the port to 22.
- Type in the username as root.
- The password is whatever you’ve set the password to in step 12.
- When prompted to accept the server’s Ed25519 key details, click Yes.
- Finally, If you like using the command line, you may want to install PUTTY.EXE as well. Google search and download it.
How to install HACS (Home Assistant Community Store)?
- HACS stands for Home Assistant Community Store. HACS gives you a powerful UI to handle downloads of all your custom needs.
- To install, open the terminal and type the following:
- wget -O – https://get.hacs.xyz | bash –
- Quit the terminal.
- Click Settings, Devices & Services (integrations, devices, entities and helpers) and click the + Add integration button (bottom right).
- In the Search for a brand name, type HACS and select it.
- Check all the checkboxes (4 of them) on the screen that pops up and click Submit.
- Copy the code in the space, then click on the GitHub link.
- Paste the code into the Device Activation and click Continue.
- Next, you have to authorise HACS by clicking the green button.
- Finally, you’ll see a message “Congratulations, and you’re all set!”
- On the left sidebar, you should now see HACS.
Installing the FoxESS Cloud Integration in Home Assistant.
- Note 1: if you want the cloud version of FoxESS then follow these steps (34 to 43).
Note 2: If you want the LAN version, skip these steps and go to step 44. - Follow the instructions on this page: https://github.com/macxq/foxess-ha
- Use hacs.io to manage the installation and update process.
- Right now, this integration is part of HACS by default.
- Click on HACS, Integrations, + Explore Integrations & Repositories.
- Type FoxESS and when it appears, click on Download.
- Restart Home Assistant.
- When installed correctly, you’ll see it under HACS; integrations look like this:
- Go to https://github.com/macxq/foxess-ha and copy the five lines starting with the sensor: into the Configuration.yaml
foxesscloud_inverter_id
In UUID that can be found on the foxesscloud in the URL path on theInverter Details
page.
?? Please make sure that this is the exact value from the inverter details page address between = and & character:
- Restart Home Assistant and check your Overview to see the sensors.
FoxESS Community Modbus Integration (for LAN setup).
- Follow the instructions on this page: https://github.com/StealthChesnut/HA-FoxESS-Modbus#readme – Always follow the instructions on the website as they are the latest. Listed below are all the other steps I took to get this integration working in my Home Assistant.
- Plug an ethernet cable into the Inverter (see the manual to find the port) & the other end into your router or powerline adapter.
- Back up your Home Assistant before making any changes. (Very important).
- Remove any previous FoxESS cloud integration. (I initially didn’t do this but ended up with many duplicate entities).
Restart the Home Assistant.
Copy the code path from the GitHub code HTTPS link.
- In the Home Assistant, click on HACS, Integrations.
- At the top right, click on the three dots and select Custom Repositories.
- Paste the address into the Repository, set the Category equal to Integration, and click ADD.
- The FoxESS Community Modbus Integration will be added to the Custom Repositories list.
- Click on the FoxESS Community Modbus Integration. This will load the page (URL: http://192.168.XXX.YYY:8123/hacs/repository/483415021),
- Click on the DOWNLOAD button at the bottom.
- A pop-up will appear showing the integration and version. Leave everything as is and click on the blue DOWNLOAD link.
- Click on HACS on the sidebar, and you’ll see a red Pending restart notification at the top of the page.
- Click on NAVIGATE and RESTART.
- Open the File Editor, and click on the custom_components/HA-FoxESS-Modbus/modbusLAN.yaml
- Remove the hash in front of the – on line 8 to make line 8 active.
- Leave the type as TCP.
- The host is the IP address of your inverter.
- The port is 502.
- Save the file.
- Click on the configuration.yaml in the same folder
- On line 15, add a # in front of the word modbus: !include custom_components/HA-FoxESS-Modbus/modbusUSB.yaml, which makes the line inactive.
- Leave line 16 as it is.
- Restart Home Assistant – Settings, System, click restart.
- At this point, everything is done, and it should work. Check your Overview menu and see if the sensors exist.
Troubleshooting FoxESS Community Modbus Integration
- Everything was installed correctly, but nothing worked for me. As there are only a few configuration lines to change, the problem had to be with the IP address or the port.
- My setup in the garage is as follows: Devolo Powerline adapter plugged into a wall socket. The Devolo has Wifi built in as well as two RJ45 ports for wired connections. This adapter acts like a router in the garage. It has an IP address of 192.168.XXX.YYY
- The inverter wireless dongle connects to the Devolo Wifi to communicate to the cloud and phone app. This must stay on or as it is.
The CAT 5/6/7 cable is plugged into the Ethernet port in the inverter. The other end is in the Devolo Powerline adapter, which uses the electric wires in the walls to communicate to another Devolo Powerline adapter at the wall socket where the router is situated. There is a CAT 6 cable plugged from the router into the Devolo Powerline adapter.Troubleshooting the port and IP Address
- Add port 502 to router firewall rules.
- Check if the Ethernet port is activated on the Inverter in the Settings panel.
- Go to Settings (code), communications, Ethernet, DHCP, and activate the Inverter.
- Next, determine the IP address of the inverter. Look on the router under wired addresses and see if the Inverter name is listed. Mine wasn’t; instead, there were many MAC and IP Addresses.
- In the Windows command prompt as administrator, type command: arm -a
This will list all the IP addresses and their MAC Address. - If you know the MAC Address, then it can help you determine the IP address.
- I have many wired devices, and finding the correct IP address took a while. Next, I decided to test port 502.
- The FoxESS inverter LAN Port is:502 and to test if the IP address:502 is working, go to https://www.gineers.com/en/downloads.php and download Modbus RTU/TCP tester (free).
- The app needs to be run in the command prompt.
- Remote IP Address: your Inverter IP
- Remote Port: 502
- Modbus Address: 247
- Read Modbus: Holding
- Address: 31000
- Count: 32
- Click Connect TCP when ready.
- REPEAT the process for each IP Address you might be testing.
- This app aims to test the TCP connection between the inverter and the Router.
- Using a process of elimination, I filtered out all the wired IP addresses I knew and the remaining IP addresses in the list I plugged into the app, one by one, until port 502 showed success. That confirmed the IP Address of the Inverter.
- Another way to confirm the IP address and Port on the Inverter is to run a modpoll command.
- Download modpoll.exe from here https://www.modbusdriver.com/modpoll.html
- Download the windows file.
- Unzip it and then run the modpoll.exe with some parameters in a command prompt. I got these from an example somewhere. The various parameters are the following:
-m TCP is Modbus ASCII protocol
-p is Even parity (default)
502 is the Remote port
-a is the Slave address
247 is the Modbus address
-t 3 is the 16-bit input register data type
-0 is the first reference is 0 (PDU addressing) instead of 1
-1 is the Poll rate in ms, (1000 is the default)
-c is the Number of values to read (1-125, 1 is the default) option for writing (use -c 1 to force FC5 or FC6)
16 is the value used for the Number of values to read
-r is the Start reference (1-65536, 100 is the default)
11000 is the Start reference used
192.168.XXX.YYY is the remote IP Address used.
Type command: modpoll -m tcp -p 502 -a 247 -t 3 -0 -1 -c 16 -r 11000 192.168.XXX.YYY
- This command also confirmed the IP Address.
- Go back to Home Assistant, click on File editor and go to /config/custom_components/HA-FoxESS-Modbus/modbusLAN.yaml, and add the correct IP Address to line 10.
- Save the file.
- Restart Home Assistant.
- In the Overview dashboard, check your sensors.
That is it! Well done if you have reached this far, and it is working! 😀
If you need more sources of inspiration, check out the Facebook group FoxESS Solar/Battery Owners Group
Hi Mike, great write up!
One minor thing I noticed;
The Modbus address shown in the GModbus example is different than the one in the modpoll example. (237 vs 247).
Not sure what your inverter is but mine is at the default 247. Not a biggy but someone may get confused/stuck if they are trying to use both.
Cheers
Hi Dave,
Thanks. A lot of work, but worth it.
Thanks for spotting the error. I have changed the Modbus Address in the post to 247 and redone the screenshot to reflect this. I went back and tested it, and it connected successfully.
Mike
I’ve tried this and got it installed but the integration caused my inverter to restart every 5-10 mins. Anyone else seen this?
Hi David,
From what I understand, this solution should not affect your inverter in any shape or form. The direction is from the Inverter to Home Assistant, not the other way around. Something else is causing your inverter to restart every 5-10 minutes.
Mike