GithubHelp home page GithubHelp logo

stealthchesnut / ha-foxess-modbus Goto Github PK

View Code? Open in Web Editor NEW
75.0 18.0 38.0 153 KB

Home Assistant Modbus Integration setup for Fox ESS H1 and AC Inverters

home-assistant homeassistant foxess modbus modbus-tcp rs485

ha-foxess-modbus's Introduction

FoxESS and Home Assistant integration via Modbus RS485


A community maintained Home Assistant integration using local native polling of Modbus data using RS485 to enable near realtime data access, with no reliance on the FoxESS cloud portal

image


Please note: as of April 2023, @nathanmarlor has mirrored and extended functionality, including easier setup in this alternative https://github.com/nathanmarlor/foxess_modbus - you should likely use that instead! This integration is being kept open in case the information here is useful.

Connecting to your inverter can be acheived in two ways:

  • Using the inverters LAN port connected to your router/switch (no additional hardware required)

  • 22/12/22 - Manager version 1.56 appears to break the LAN connectivity option!

  • Connecting to the COM port using a RS485 to USB adapter or WIFI/LAN RS485 converter

⚠️ Additional hardware requires basic electronics competencies to connect the two additional wires for the RS485 interface to the inverters com connector.⚠️


Supported Hardware

Hybrid Series
✅ H1-3.0-E
✅ H1-3.7-E
✅ H1-4.6-E
✅ H1-5.0-E
✅ H1-6.0-E
AC Series
✅ AC-3.0-E
✅ AC-3.7-E
✅ AC-4.6-E
✅ AC-5.0-E
✅ AC-6.0-E
AIO Series
✅ AIO-H1-3.0
✅ AIO-H1-3.7
✅ AIO-H1-4.6
✅ AIO-H1-5.0
✅ AIO-H1-6.0

For T Series - See this alternative project by assembly12


The aim of this project is to enable the full use of the Energy dashboard in Home Assistant and is a fully functional replacement of the FoxESS App for reporting needs.

HACS Specific Installation

  • Add this repository to your HACS custom integrations
  • Install from HACS

Manual Specific installation

  • Hardware configuration instructions can be found on the wiki
  • Copy the Required modbus file (USB or LAN) file to /config/custom_components/HA-FoxESS-Modbus/modbusLAN.yaml

Then, Common Installation Steps

  • Create a full backup of your HA instance including the configuration.yaml file
  • Copy the Required modbus line (USB or LAN) and following contents of the configuration.yaml file to your config file
  • For LAN, create your Secrets file entry
  • Check your config is valid, then Restart HA
  • Map energy dashboard as per below example and enjoy configuring dashboards using near realtime data.

Step by step walkthrough of the setup image

Engergy Dashboard Configuration

image

Energy Dashboard Values

⚠️Some values won't appear until a small amount of data has passed through that value. You may need to wait 24hrs before you can setup the energy dashboard.

Electricity Grid

  • grid_daily
  • feedin_daily

Solar Panels

  • pv1_daily
  • pv2_daily

Home Batteries

  • bat_charge_daily
  • bat_discharge_daily

Provided Entities

Registers

The wiki has references for the registers.




Please read and understand before using this plugin:

This plugin has been developed as a personal project, with no connection to the official brand of FoxESS, use of this plugin is intended for use by the community without fee but has no warrenty or liability should any damage, harm or undesired results happen as a result of using this plugin. We strongly recommend that only competently trained individuals attempt to wire the additional connections required for this plugin to function. There is a risk of personal or device damage/harm. You have been warned!


If you find this useful and are thinking of joining Octopus Energy, use my referral code! We both get £50 credit on our bills! https://share.octopus.energy/showy-pup-300

ha-foxess-modbus's People

Contributors

canton7 avatar nathanmarlor avatar ndrinta avatar phips avatar rand12345 avatar stealthchesnut avatar williamjeccles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ha-foxess-modbus's Issues

Quick question about the BMS Watthours sensor;

          Quick question about the BMS Watthours sensor;

Should this be the same as the kWh (x1000) value that is available in the Foxcloud data report?
If so then I think I have a problem;
Foxcloud reports my throughput as roughly 9947kWh or 9,947,000 Wh.
The sensor I am pullling in from register 11049 is giving me odd values in HA;
image

It peaked at 32,731 then dropped to -32749 (more or less 2^15 to -2^15) so is this a stack overflow issue?

In modbus config for this sensor I tried adding data_type: xxxxx (int16, int32, int64, uint16, uint32, uint64) but none of these worked either!

Originally posted by @Daibutt in #92 (comment)

Scan interval

Just put a vote in for a review of scan interval settings?

I use 30 seconds for most sensors, with 5 seconds for power sensors.

For example, do we need to scan BMS cell mV high / low every 5 seconds, would 30 seconds suffice?

Should there be !secret scan_interval setting so people can make a global change up or down to the default 30 seconds if they wish?

Grid Consumption Accuracy

Issue with grid accuracy:
https://www.facebook.com/groups/foxessownersgroup/permalink/1577479335967576/

"For the last two days I've seen some funny values in my HA energy dashboard. Todays usage, for example, shows we've imported 5kWh from the grid when using the grid_daily sensor for the Grid consumption. But if I change that to use the Hildebrand Glow integration I only see 0.6kWh of consumption.
Yesterday was similar, and Octopus, Glow and even FoxEssCloud all seem to agree on consumption. It's just the grid_daily sensor that is wrong."

Instructions for connecting W610 to Ethernet

Hi,

After some tinkering, I managed to get my W610 connected using ethernet, rather than as a wifi client.

I don't have permission to edit the wiki, but I've created some instructions below in case you (or anyone else) finds them useful.

Thanks!

  1. Plug in the USR W610 into power without an ethernet cable attached wait 10-15 secs to boot
  2. Using a laptop or desktop with wifi access search for and connect to the device’s wifi name. Normally USR-XXXX
  3. Open a browser and navigate to 10.10.100.254 (normally printed on the back of the device)
  4. Enter Admin / Admin for the username and Password
  5. Click english top right to change to english
  6. Under Ethernet Setting - Set the Ethernet work mode to WAN port, Apply
  7. Under Mode Selection - Set AP Mode, Data Transfer Mode to Modbus TCP<=>Modbus RTU, Apply
  8. Under STA Interface Setting - Set AP+STA to Off, Apply
  9. Under Device Management - Click Restart, and connect an ethernet cable

Using your router's device list or local ip scanner, find the ip address of the USR now on your local network.

  1. Type in your USR’s IP address while connected to your normal network
  2. When prompted enter Admin/Admin as the username and password
  3. Under AP Interface Setting - change Security Mode from Disable to WPA2-PSK and set a Pass Phase in the box, this will secure the wifi for the device but allow you future direct access for future troubleshooting
  4. Under Application Settings Match These settings (Click Apply after each section and then click Application Settings for each, no need to reboot until you've completed them all):

Sensors showing Unavailable

I've just addded the integration to home assistant from my H1 invertor and i'm not recieving values for a number of sensors. Grid CT and CT2 as a couple of examples but there are a few more. Looking at the modbusLAN.yaml file at the Grid CT and CT2 the addresses are down as 31014 and 31015 respectivley but looking a the registers wiki should these not be 11021 and 11022?

Sensors need Unique ID values

Looking at sensors created by the integration in the settings area of Home assistant shows a message saying they can't be managed from the UI.

Add Unique IDs to prevent this.

WiFi / LAN Feed sending no data

Had a brand new system installed today and was quite looking forward to just cracking on with the HA build and better integration direct without relying on FoxESS Cloud and their slow polling.

Anyone had any joy extracting sensor data from the network port on the most recent firmware? I can't understand why a vendor would disable or limit this interaction?!

I've set this up perfectly, all of the sensors are available in HA but no data ever seems to appear.

Tried to set this up but keep getting errors

Tried setting this up and put ip that’s on inverter but keep’s failing to connect, how do I check its real ip ? I’ve tried connecting laptop to same lan lead and getting 50 meg bb so not as connecting problem even followed the YouTube video done today no luck spent countless hours trying to get this to work please help thanks
Error message I get is
Logger: pymodbus.client.sync
Source: components/modbus/modbus.py:386
First occurred: 19:51:35 (251 occurrences)
Last logged: 19:57:59

Connection to (192.168.0.043, 502) failed: timed out
Connection to (192.168.0.043, 502) failed: [Errno 113] Host is unreachable

And at startup

Logger: homeassistant.components.integration.sensor
Source: components/integration/sensor.py:184
Integration: integration (documentation, issues)
First occurred: 19:51:27 (8 occurrences)
Last logged: 19:51:27

sensor.load_sum could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]
sensor.bat_charge_sum could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]
sensor.bat_discharge_sum could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]
sensor.feedin_sum could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]
sensor.grid_consumption_sum could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]

Running Home Assistant 2022.11.5
Supervisor 2022.11.2
Operating System 9.3
Frontend 20221108.0 - latest

but had issues been trying since 2022 11 ish tried to restore back to 10.5 but won’t restore properly so can’t go back before 11.2 but even had problems on 10.5 on both modbus and fox cloud hacs add on

H3 Hybrid Series Support (inverter LAN interface)

Hi, currently there is only support for the H1 Version .

I own a H3-6.0E and tried the integration, but the registers seems to be wrong. I do not get any information.
I can confirm, that Port 502 is open, but that's it.

Maybe the registers are different!? @StealthChesnut can you share some information, how you found the correct registers for the H1 inverter interface?

H3 Register Tables

I have a 3-Phase inverter H3-8.0-E and I want to share my register findings for Modbus over Serial with you.
The default Modbus device ID (Slave ID) is 247. This can be adjusted in the inverter menu Settings->Communication->RS485->DeviceID.

I put all findings to my fork of this project for 3-phase inverters

LAN RS485 Name data_type scale unit device class Description Validated with display values
? 31000 PV1-Voltage int16 0.1 V Y
? 31001 PV1-Current int16 0.1 A Y
? 31002 PV1-Power int16 W Y
? 31003 PV2-Voltage int16 0.1 V Y
? 31004 PV2-Current int16 0.1 A Y
? 31005 PV2-Power int16 W Y
? 31006 Grid-Voltage-Phase-R int16 0.1 V suggested
? 31007 Grid-Voltage-Phase-S int16 0.1 V suggested
? 31008 Grid-Voltage-Phase-T int16 0.1 V suggested
? 31009 Grid-Current-Phase-R int16 0.1 A Y
? 31010 Grid-Current-Phase-S int16 0.1 A Y
? 31011 Grid-Current-Phase-T int16 0.1 A Y
? 31012 Grid-Power-Phase-R int16 W suggested
? 31013 Grid-Power-Phase-S int16 W suggested
? 31014 Grid-Power-Phase-T int16 W suggested
? 31015 Grid-Frequency int16 0.01 Hz suggested
? 31016 EPS-Voltage-Phase-R int16 0.1 V Y
? 31017 EPS-Voltage-Phase-S int16 0.1 V Y
? 31018 EPS-Voltage-Phase-T int16 0.1 V Y
? 31019 EPS-Current-Phase-R int16 0.1 A Y
? 31020 EPS-Current-Phase-S int16 0.1 A Y
? 31021 EPS-Current-Phase-T int16 0.1 A Y
? 31022 EPS-Power-Phase-R int16 W Y
? 31023 EPS-Power-Phase-S int16 W Y
? 31024 EPS-Power-Phase-T int16 W Y
? 31025 EPS-Frequency int16 0.01 Hz Frequency (island mode) Y
? 31026 Smart-Meter-Power-Phase-R int16 W smart-meter negative=consumption/import Y
? 31027 Smart-Meter-Power-Phase-S int16 W smart-meter negative=consumption/import Y
? 31028 Smart-Meter-Power-Phase-T int16 W smart-meter negative=consumption/import Y
? 31029 Load-Power-Phase-R int16 W Main+EPS out
? 31030 Load-Power-Phase-S int16 W Main+EPS out
? 31031 Load-Power-Phase-T int16 W Main+EPS out
? 31032 Temperature Inverter int16 0.1 °C Y
? 31033 Temperature Inner int16 0.1 °C Y
? 31034 Battery-Voltage int16 0.1 V battery Y
? 31035 Battery-Current int16 0.1 A battery Y
? 31036 Battery-Power int16 W battery Negative=charging Y
? 31037 Battery-Temperature int16 0.1 °C battery Y
? 31038 Battery-SoC int16 % battery Y
? 32001 PV-Energy-total int16 0.1 kWh inverter total_increase Y
? 32002 PV-Energy-daily int16 0.1 kWh inverter total_increase, daily reset Y
? 32004 Battery-Charge-Energy-total int16 0.1 kWh battery total_increase Y
? 32005 Battery-Charge-Energy-daily int16 0.1 kWh battery total_increase, daily reset Y
? 32007 Battery-Discharge-Energy-total int16 0.1 kWh battery total_increase Y
? 32008 Battery-Discharge-Energy-daily int16 0.1 kWh battery total_increase, daily reset Y
? 32013 Smart-Meter-Import-total int16 0.1 kWh smart-meter total_increase, daily reset Y
? 32014 Smart-Meter-Import-daily int16 0.1 kWh smart-meter total_increase Y
? 32016 Smart-Meter-Export-total int16 0.1 kWh smart-meter total_increase, daily reset Y
? 32017 Smart-Meter-Export-daily int16 0.1 kWh smart-meter total_increase Y
? 32022 Load-Energy-total int16 0.1 kWh inverter total_increase Y
? 32023 Load-Energy-daily int16 0.1 kWh inverter total_increase, daily reset Y

Address Bankand 30000 (RS485)
30000-30011 - Model name in hex - 'H3-8.0-E'

Add Random Noise Sensor - optional method of fixing integration sensors

OK... add this in your sensor part of configuration.yaml (mine is just below the integration sensors for bat discharge, grid consumption etc.).;

- platform: random
  name: random_watts
  minimum: 1
  maximum: 10

Then find your template for battery charge
image

and replace the zero indicated with this code;

{{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }}

first curly bracket needs to line up with the others in the template so it looks like this;

image

Originally posted by @Daibutt in #14 (comment)

Battery temperature sensor

I believe I have managed to find which one is for battery temperature:

- name: "Battery temperature"
  scan_interval: 60
  slave: 247
  address: 11038
  state_class: measurement
  unit_of_measurement: "°C"
  scale: 0.1
  data_type: int16
  input_type: input
  device_class: battery

Integration causes inverter to crash with "BMS Ext Fault"

I have an occurring fault with my inverter that has only started since my HA modbus connection using ethernet. I disabled the integration and no inverter issues or reboots in a month. Re-added the integration on a clean HA install and within a few days I get the same error

I'm using the standard HA settings but I have removed any sensors I do not use. I noticed in the Fox app that the battery goes offline and then a couple of minutes later it seems the inverter resets itself. This is noticeable for me as I have EPS setup on critical circuits and so the inverter resetting switches out the internal relay meaning these circuits lose power for 5-10 seconds.

The firmware versions are
Master : 1.48
Slave : 1.02
Manager : 1.45

System Losses sensor may be giving incorrect values

The system losses sensor using LAN config appears to be reading more like a current power generation figure, not a losses figure.
In the USB config it may not be accurate or is giving some surprisingly high figures.

Units may be wrong, or source data may be wrong (incorrect register definition in the LAN config?)

Need to check data source registers are correct in LAN config (or at least match the USB config), then check the implementation of the sensor template.

Prototype layout for repo

I noticed that you are integrating H3 inverters into the repo. Having seen this form of integration before with other platforms I'm offering a suggestion for a new layout which should help the maintainer's sanity when propagating changes. This isn't a PR although you are welcome to take it.

Pros:

  • User IP configuration is outside the repo, all held in /secrets.yaml
  • Selecting a communications method is set in /configuration.yaml and users to not edit repo files
  • Better maintainability, common modbus entries are shared between communication methods. One change propagates through inheritance
  • Feature updates require no selective copy and pasting which nips yaml issues in the bud
  • One copy and paste entry is needed to add this config to /configuration.yaml (see edited readme.md)
  • Can be symlinked to /config/custom_componants/HA-FoxESS-Modbus permitting git pulls within the home directory

Cons:

  • Breaking change occurs through instantiation, needs configuration.yaml updating and two entries in /secrets.yaml

https://github.com/rand12345/HA-FoxESS-Modbus/tree/new-layout-prototype

T Series (G3) Support ?

Hello,
i would like to know if anyone had luck with setting up a T Series.
It has a slightly different connector then shown here on the GitHub
this is the connector:
image

And if it is supported how do you connect to it?
Is the connector available for purchase or do you just put some cables in it ?

Template sensors need to be updated following Templates breaking change in HA 2022.6

I'm getting these errors in my HA logs.

Any ideas how to fix them?

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:173
Integration: Template (documentation, issues)
First occurred: June 1, 2022, 23:34:34 (12 occurrences)
Last logged: 11:59:37

TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{{ [0, ((states('sensor.pv1_power') | float + states('sensor.pv2_power') | float ) * 1)]|max }}' but no default was specified') while processing template 'Template("{{ [0, ((states('sensor.pv1_power') | float + states('sensor.pv2_power') | float ) * 1)]|max }}")' for attribute '_attr_native_value' in entity 'sensor.pv_total_power'
TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{% if (states('sensor.grid_ct') | float ) > 0 %} {{ states('sensor.grid_ct') | float * 1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}' but no default was specified') while processing template 'Template("{% if (states('sensor.grid_ct') | float ) > 0 %} {{ states('sensor.grid_ct') | float * 1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.feed_in_power'
TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{% if (states('sensor.grid_ct') | float ) < 0 %} {{ states('sensor.grid_ct') | float * -1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}' but no default was specified') while processing template 'Template("{% if (states('sensor.grid_ct') | float ) < 0 %} {{ states('sensor.grid_ct') | float * -1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.grid_consumption'
TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{% if (states('sensor.battery_discharge_power') | float ) > 0 %} {{ states('sensor.battery_discharge_power') | float * 1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}' but no default was specified') while processing template 'Template("{% if (states('sensor.battery_discharge_power') | float ) > 0 %} {{ states('sensor.battery_discharge_power') | float * 1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.battery_discharge'
TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{% if (states('sensor.battery_discharge_power') | float ) < 0 %} {{ states('sensor.battery_discharge_power') | float * -1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}' but no default was specified') while processing template 'Template("{% if (states('sensor.battery_discharge_power') | float ) < 0 %} {{ states('sensor.battery_discharge_power') | float * -1 }} {% else %} {{ (states('sensor.random_watts') | float - 5.5 ) / 1000 }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.battery_charge'

Originally posted by @Captain0Kangaroo in #22

Generation Totals

Sorry not an issue as such but was trying to get some totals for generation and its not working.

I've set up the following for example but i'm not getting any numbers logged:

utility_meter:
daily_pv1:
source: sensor.pv1_power
cycle: daily
#New Sensor
daily_pv2:
source: sensor.pv2_power
cycle: daily

template:

  • sensor:
    • name: "Solar Power Daily"
      unit_of_measurement: "kWh"
      state: "{{ states('sensor.daily_pv1_power') | float + states('sensor.daily_pv2_power') | float }}"

I would then do the same for Monthly, Yearly and Total.

Any ideas where i've gone wrong?

KH series inverters

Based on recent experience, I think you could add KH single phase inverters to the list as an enhancement with a wiki page on setting this up?

Heres the thing: there is no ethernet port so you connect to RS485 via the CT connector. You hook up W610 to this and scan for modbus ports and you find 31000!

So, surprisingly, KH then just works with the modbusLAN sensor configuration and the IP address of W610.

You would need a USB serial port config in modbusLAN for it to work with a USB to RS485 adapter.

sensors error -slave247

a number of sensors in the modbusLAN.yaml, don't have the line" slave: 247 "
these sensors don't seem to work without it ?

You need to add the line then reboot the system (a restart isn't good enough)

Grid CT sensor in LAN config not giving correct reading

@StealthChesnut Thank you for the updated code. I now have Grid Consumption and FeedIn gauges working. And they broadly match the values from the CTs feeding our MyEnergi Zappi which I've used as my measuring stick up to now. Spot on!

I see I also now have a Grid CT sensor which I can use to chart grid use, although it seems to be the inverse... See screenshot below - if you look at the right hand end the lilac Grid CT is the inverse of the Load Power:
image

Originally posted by @C00K50N in #25 (comment)

Do sensors need state_class: measurement

A number of the BMS sensors (11037, 11041, 11042, 11045, 11046) don't have

state_class: measurement

in their definition in modbusUSB.yaml so, as I undestand it, won't be storing any long term statistics whilst most other sensors do have this.

Is this intentional or should these sensors also have this property?

Default scan_intervals overwhelm the W610, causes problems in home assistant

From work done on https://github.com/nathanmarlor/foxess_modbus, we've found what the W610 supports one read about every 700ms (sometimes it can do one quicker). It's capable of reading 8 registers at a time, but the modbus integration only reads 1 register at a time. This means that it theoretically takes 28s to read the 40 sensors in modbusUSB.yaml.

modbusUSB.yaml contains a range of scan_intervals, but they add up to more than 1 read every 700ms.

This means that the modbus integration spawns read operations more quickly than they can be completed. There's no logic to say "I want to refresh this sensor, but it's still waiting for the previous refresh to finish, so I'll hold off" -- it just keeps throwing read operations onto a queue inside home assistant. The queue gradually grows in size, which is going to slow things down, and might eventually crash home assistant. It also delays things like shutdowns and restarts. It also means that sensors aren't actually read at the interval that was requested.

However there's no indication of this unless you go and manually add logging calls to the modbus integration. I did this, and very quickly I've got to having tasks which have been sitting in the queue for 15 minutes+, and it's still rising.

To make matters worse, some people are discussing setting the scan_interval to 5 seconds, or even 1 second, without knowing the problems this causes.

You should probably increase the scan_intervals in modbusUSB.yaml so that they don't mess up home assistant for people who are using a W610 by default, and add some strong warnings not to decrease them?

W610 setup with HA

Greetings!

Having an issue with setting up the w610 connected to a H1 inverter with a wired home network. Successfully followed the guide Stealth-chestnut created on here and the wiki article and received data from the H1 for several days. However it has moments of dropping out, and then no data is received intermittently.
To add to it on the network there is also a google mesh setup installed which seems to be causing somekind of "fight" between the w610 ip series addresses and the ip addresses assigned by the Mesh router.
The w610 is connected directly to n ethernet over power adapter then into a switch(hub) and then from there into the google mesh router.
Running an Ip scanner brings up several W610(s) and also the ip address series 10.10.100.. ect of the w610 gets assigned to some of the other devices on the network(tv, hue lighting system). Pretty lost on this one, and believe I need to start over again.
Wondering if someone has a guide for a ethernet wired setup of the 610? (I believe the link to wiki for setting up the w610 is for a wireless setup(which I cannot do due to distance from the inverter to the network hub)
Apologies that this is more of a network configuration issue(which I am unfamiliar with). Any help would be appreciated.

battery to grid control?

This is more a query than a fault....does the modbus interface allow local control of whether the inverter is charging from the grid, or supplying to the grid...or is it read-only?

Cheers!

More H1 RS485 registers

Hi,

I've found some more H1 RS485 registers:

  • 11070: PV total * 10
  • 11071: PV today * 10
    ... Presumably some in the range 11072-11078 are for charge / discharge, but I'm still waiting on my battery so can't test
  • 11079: Feed-in total * 10
  • 11080: Feed-in today * 10
  • 11082: Consume total * 10 (as shown under History on the inverter. Is this grid consumption?)
  • 11083: Consume today * 10 (as shown under History on the inverter)
    ... Presumably EPS is next, but I can't test
  • 11085: I think this is 'Energy Generated Total' * 10. The number's about right, but I can't find anything to compare it to
  • 11086: I think this is 'Energy Generated Today' * 10

Battery charge wrong when force charging

When force charging I'm getting inflated values for battery charge. I only have a 7.8kWh battery, and checking with my meter data confirms that I didn't use anywhere near this much electricity from the grid.

image

Modbus Data reporting NaN with HA 2023.9.1

I have been successfully using this code until recently.
Unfortunately with HA 2023.9.1 I find that all the Modbus values are being displayed as nan and being listed as Unavailable on the Entities page.
This appears to be related to a change made in this latest HA version.

My guess is that we now need to reject invalid data to prevent the sensors being made unavailable if they are not detected when the Modbus link is first started. Does anyone have the same experience or knowledge on how to solve this ?

Load Power goes negative

I have observed the Load Power reading going very low and negative at certain times. This seems to be when the battery SoC is full/99%, good solar generation (over 3kW), and load is less than the solar generation.

Not sure if this is anything to do with the integration config, or just the data that's coming from the inverter. Seeing matching data in the Fox portal, i.e. LoadsPower reading -0.37kW.

Octopus itegration?

Hi.
Thanks for the excellent work on this.
I apologise that this is only tangentially related to your code:

I am trying to get my head around how (if) the integration with Octopus, in terms of when the system is exporting and when it is importing, is managed with the foxESS kit

Does the use of the Modbus interface for local access using your code affect this - or is that managed between the Fox Cloud and the Octopus cloud....or something else?

Of the many inverters out there, any thoughts on Fox vs any of the others as a good solution?

Cheers!

Missing system losses sum

I was asked to have a look at an issue where the daily system losses was zero, but the system losses was correctly showing the current system losses.

The sensor logic appears to be sensor.system_losses is real time loss, this gets integrated by sensor.losses_sum and then the sensor.losses_daily utility meter (which is zero) is the daily summation.

Having looked at the sensor code added to the configuration.yaml, it seems the sensor.losses_sum definition is missing, if you add it in the daily losses sensor works ok - not sure whether this is the intended method but it does work.

The sensor I added is -

- method: left name: losses_sum platform: integration round: 2 source: sensor.system_losses unit_time: h

Question about sensor update frequency

I have set my sensors with a scan_interval of 5 - 30 sec. However, the values update very differently, often there are some minutes no update, sometimes even up to 25 min. although the values change with the cloud integration very fast.

But since I prefer the solution via Modbus, I would like to find out if this is a normal behavior or if it can be due to a misconfiguration. Here are a few examples. In this case, there was bright sunshine and the battery was charging at about 3 - 4 KW, so the SoC sensor should have changed promptly, but instead there are jumps of ~20%.

My setup

  • FoxESS Inverter H3 6.0E 6.5KW Battery
  • USR-610 Modbus LAN converter

SoC charge state screenshots:
Screenshot_2023-01-17 11 31 39_b2f7MH
Screenshot_2023-01-17 11 10 03_KDudbV
Screenshot_2023-01-17 10 52 20_UboAcO

SoC sensor config:

- name: "fox_bat_soc"
    scan_interval: 30
    slave: 247
    address: 31038
    state_class: measurement
    unit_of_measurement: "%"
    data_type: uint16
    input_type: holding
    device_class: battery

Modbus config

- name: FoxESS_Inverter
  type: tcp
  host: 192.168.XX.XXX
  port: 502
  retry_on_empty: true
  retries: 3
  timeout: 5
  close_comm_on_error: false

in the same time template sensor (pv1_power & pv2_power) has delivered timely data:

Screenshot_2023-01-17 11 18 39_86Y794

Screenshot_2023-01-17 10 57 16_duiaxh

so it looks like the inverter is providing data but very different in time, is there any explanation or way to change this?
I would like to have as accurate data as possible

regards

[Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received) / No Response received from the remote unit/Unable to decode response BUT INTEGRATION IS WORKING

I get 2 errors in the home assistant log:

  • [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
  • [Input/Output] No Response received from the remote unit/Unable to decode response

But the integration is working fine and all my data is filled in.
is this a bug in the integration or do I do something wrong?

Foxess Grid Power inverted

Hello, I have connected my inverted to home assistant using LAN and one of the sensors seems to be backwards:
image
As you will see during the night the value is a Minus but in the day its possitive. I would expect it to be opposite I.E returning to grid should be a negative number.

I have looked at the foxess app and that is reporting Returning to grid correctly. Here is the configuration in HA for the parameter:

    - name: "FoxESS Grid Power"
      scan_interval: 5
      address: 31014
      state_class: measurement
      unit_of_measurement: "kW"
      data_type: int16
      scale: 0.001
      precision: 3
      input_type: holding    
      device_class: power

CT2 Lan address

The LAN address for CT2 is 31015.

When using CT2 for PV power, load_power reads negative when exporting.
Please add the following templates to correct this.

ct2_power:
friendly_name: "CT 2 Power"
unit_of_measurement: 'kW'
device_class: power
value_template: >
{{ [0, (states('sensor.ct2_meter') | float(default=0) * 1)]|max }}

house_power:
friendly_name: "House Power"
unit_of_measurement: 'kW'
device_class: power
value_template: >
{% set load = states('sensor.load_power') | float(default=0) %}
{% set ct2 = states('sensor.ct2_meter') | float(default=0) %}
{% set power = ( load + ct2 ) | round(3) %}
{{ "{:.3f}".format(power) }}

Cheers!

Time sensors appear to be missing ?

Hi
These sensors appear to be missing are missing - where should they be obtained from please ?
sensor.time_period_1_start
sensor.time_period_1_end
sensor.time_period_2_start
sensor.time_period_2_end

They are used below :-

  • name: "Time Period 1 - Start Time"
    icon: "mdi:calendar-clock"
    state: >
    {% set raw_time = states('sensor.time_period_1_start') | int %}
    {% set hours = raw_time // 256 %}
    {% set minutes = raw_time - (hours * 256) %}
    {{ strptime(hours | string + ":" + minutes | string, '%H:%M').time() }}
    - name: "Time Period 1 - End Time"
    icon: "mdi:calendar-clock"
    state: >
    {% set raw_time = states('sensor.time_period_1_end') | int %}
    {% set hours = raw_time // 256 %}
    {% set minutes = raw_time - (hours * 256) %}
    {{ strptime(hours | string + ":" + minutes | string, '%H:%M').time() }}
    - name: "Time Period 2 - Start Time"
    icon: "mdi:calendar-clock"
    state: >
    {% set raw_time = states('sensor.time_period_2_start') | int %}
    {% set hours = raw_time // 256 %}
    {% set minutes = raw_time - (hours * 256) %}
    {{ strptime(hours | string + ":" + minutes | string, '%H:%M').time() }}
    - name: "Time Period 2 - End Time"
    icon: "mdi:calendar-clock"
    state: >
    {% set raw_time = states('sensor.time_period_2_end') | int %}
    {% set hours = raw_time // 256 %}
    {% set minutes = raw_time - (hours * 256) %}
    {{ strptime(hours | string + ":" + minutes | string, '%H:%M').time() }}

Reinvestigate the LAN Port on inverter

Discussed in #25

Originally posted by mdt3k June 8, 2022
My H1-5.0-E inverter has a LAN port, in addition to the RS485 port that the WiFi logger dongle connects to.

I decided to connect a computer to it, and discovered the port hosts a ModbusTCP server. I doesn't appear fussy about what equipment address you poke it with (I tried 1 and 247), it will respond to requests for modbus input registers 300-399, and holding registers 30,000-30,027, 31,000-31,038 and 44,000-44,002 (it is possible it will respond to other registers, I only tried every 100th register). The server responds straight away, and the solar-related values change at least every 5 seconds (I have not logged data for a long period at a faster rate than this, when register scanning I queried every 0.25 seconds and this didn't seem to cause any problems). It is interesting (to me at least) that these are not the same register numbers that everyone else is reporting, and they do not seem to contain exactly the same information as available via the WiFi dongle. I have not yet worked up the enthusiasm to create an RS485 break out box, but for now I assume my dongle is working the same as everyone elses.

The registers return the following information:

  • 300-399: the values 1-11 and then zeros. I am unclear on the purpose of these registers
  • 30,0000-30,027: 16 characters consisting of the model number (H1-5.0-E in my case) followed by some spaces to make up the 16 characters; then the firmware version numbers (138, 102 and 129 in my case), and then some zeros
  • 31000-31038: Solar-related information (see decode below). I don't currently have a battery connected so I expect some of the registers I haven't decoded are related to that.
  • 44,000-44,002: So far these have always contained the values 0; 0; 25,704 (=0x6468 or b0110 0100 0110 1000). It's not clear to me what this is, I would guess configuration settings, but I have not beeen able to map it on to any of the tables in the various manuals I have found floating around on the internet. I am interested in whether anyone can shed any light on this. Perhaps someone has the correct protocol manual for my inverter?

My decode of registers 31,000-31,038:
All the values appear to be signed, and where a multiplier is listed they are fixed point values (x10 means a reported value of 2 should be interpreted as 0.2, x100 means 2 -> 0.02)
31000 PV1 Voltage x10
31001 PV1 Current x10
31002 PV1 Watts
31003 PV2 Voltage x10
31004 PV2 Current x10
31005 PV2 Watts
31006 Grid Voltage x10
31007 Generated AC Current x10
31008 Generated AC WattsCurrent x10
31009 Grid Frequency Hz x100
31010 unknown_1
31011 unknown_2
31012 unknown_3
31013 unknown_4
31014 Export Watts (negative = importing)
31015 unknown_5
31016 House Usage Watts
31017 unknown_6
31018 Ambient Temperature degrees C x10
31019 Inverter Temperature degrees C x10 (the fox cloud has these values transposed, but that makes no sense)
31020 Inverter Battery Voltage x10
31021 Inverter Battery Current x10
31022 unknown_8
31023 unknown_9
31024 unknown_10
31025 unknown_11
31026 unknown_12
31027 Inverter State (0 = Standby, 2 = On Grid, other values = ?)
31028 Possibly the “Inverter Mode” from the Fox protocol manuals
31029 Possibly the CT meter type from the Fox protocol manuals
31030 unknown_13
31031 unknown_14
31032 unknown_15
31033 unknown_16
31034 unknown_17
31035 unknown_18
31036 unknown_19
31037 unknown_20
31038 unknown_21
(there is no unknown_7 as I worked out what that was).

Can anyone shed any light on any of the unknown values? In particular the use of registers 300+ and 44000+?

Add System Overhead or "losses" sensors

Discussed in #9

Originally posted by Daibutt May 7, 2022
I have seen several comments regarding energy values not matching up, and for a while I have been trying to estimate system "overhead" using the FoxESS cloud data.
Now we have ~real time data using the modbus integration this makes it easier to estimate these.
The inverter uses energy to do it's thing, and when you feel the inverter, batteries etc. warm to the touch, that's all using energy.

Conceptually, this is how I see it;
image

NB: I do not have an EV, so not sure if EV chargers typically are included in the "loads" sensor or if they are separate to this.


So doing some maths;
image
which can be rewritten as;
image

Im my HA configuration.yaml have added a template for a "losses" sensor, and also a totaliser and daily losses utility meter;

Template sensor;
image

Totaliser;

image

And a daily (utility) meter;

image

Obviously if you have other loads or generators that are different than the diagram above you will need to alter this accordingly (i.e. 2nd inverter, EV charger that is not included in the loads sensor, Eddi?)

I am typically seeing ~ 100W system overhead/loss, and this seems to vary depending on how hard the inverter is working, which sort of makes sense.
image

address: 11038 dupliate

I noticed the following in the HA log:

2023-03-05 13:12:48.334 WARNING (MainThread) [homeassistant.components.modbus.validators] Modbus sensor/Outer-BMS Cell Temp Reported address 11038_input_247 is duplicate, second entry not loaded!

And sure enough it is in there twice

- name: "Inner-Battery-Temp"
  scan_interval: 60
  slave: 246
  address: 11038
  state_class: measurement
  unit_of_measurement: "..C"
  scale: 0.1
  precision: 1
  data_type: int16
  input_type: input
  device_class: temperature

and

- name: "Outer-BMS Cell Temp Reported"
  scan_interval: 30
  slave: 247
  address: 11038
  state_class: measurement
  unit_of_measurement: "..C"
  data_type: int16
  scale: 0.1
  precision: 1
  device_class: temperature
  input_type: input

I checked the wiki, but couldn't see what the error is, but I wonder if (based on the pattern) if the second one (Outer-BMS Cell Temp Reported) should be 11049?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.