Foxess Inverter Modbus

Delete this:

        TwoByte grid_power_value;
        grid_power_value.Byte[0] = bytes[10];
        grid_power_value.Byte[1] = bytes[9];
        id(grid_power).publish_state(grid_power_value.UInt16);
        TwoByte loads_power_value;
        loads_power_value.Byte[0] = bytes[14];
        loads_power_value.Byte[1] = bytes[13];
        id(loads_power).publish_state(loads_power_value.UInt16);

And add this:

     TwoByte grid_power_value;
     grid_power_value.Byte[0] = bytes[10];
     grid_power_value.Byte[1] = bytes[9];
     //id(grid_power).publish_state(grid_power_value.UInt16);
     //ESP_LOGD("custom", "grid_power: %u" , grid_power_value.UInt16);
     
     int16_t grid_power_value_int;
     int16_t feedin_power_value;
     if(grid_power_value.UInt16 > 32768) {
       //Feed in
       grid_power_value_int = 65536 - grid_power_value.UInt16 * -1;
       feedin_power_value = 65536 - grid_power_value.UInt16;
     }
     else {
       //Consumption
       grid_power_value_int = grid_power_value.UInt16;
       feedin_power_value = 0;
     }
     id(grid_power).publish_state(grid_power_value_int);
     ESP_LOGD("custom", "grid_power: %i" , grid_power_value_int);
     id(feedin_power).publish_state(feedin_power_value);
     ESP_LOGD("custom", "grid_power: %i" , feedin_power_value);
       
     TwoByte loads_power_value;
     loads_power_value.Byte[0] = bytes[14];
     loads_power_value.Byte[1] = bytes[13];

     int16_t loads_power_value_int;
     if(grid_power_value.UInt16 > 32768) {
       //Feed in
       loads_power_value_int = 65536 - grid_power_value.UInt16 * -1;
     }
     else {
       //Consumption
       loads_power_value_int = grid_power_value.UInt16FeedIn;
     }
     id(loads_power).publish_state(loads_power_value_int);
     ESP_LOGD("custom", "loads_power: %i" , loads_power_value_int);

You’ll have to make an additional sensor for the feedin power.

1 Like

Thank you so much. For users with Smart-Meter connected. Do you think is there any possibility to read data during night to get actuall grid consumption ? Maybe powering up dataloger with 12V ? What do you think ?

As far as I can tell the problem isn’t the interruption of the power supply. Your ESP will be online even during the night.
The problem is that the the modbus connection closes during the night. Unless there is a way to disable this within the settings of the inverter, unfortunately it won’t be possible to read out anything during the night.

1 Like

In my opinion better solution is use zamel mew-01 as cloud or local mqtt

Yes actually i did test, ESP has power ( via 12V ) but Modbus died… how to read data from CHINT DTSU666 Smart Meter then :frowning: Hmm

It has its own RS485 port which you could tap into. I am however not familiar with this device and it would probably be better to start a separate thread, since it has nothing to do with the foxess inverter.

Guys, when inverter is offline and we have external power supply for ESP, function for checking inverter status floods every second HA ( and domoticz via mqtt in my case as well ). Is it the same in your case ?

Yes it’s true i check log’s bellow:
[19:28:46][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:46][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:46][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:46][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:46][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:46][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:46][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:46][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:46][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:46][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:47][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:47][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:47][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:47][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:47][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:47][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:47][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:48][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:48][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:48][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:48][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:48][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:48][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:48][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:48][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:49][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:49][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:49][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:49][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[19:28:49][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)
[19:28:49][V][sensor:076]: ‘T-Series Inverter State’: Received new state 0.000000
[19:28:49][D][sensor:127]: ‘T-Series Inverter State’: Sending state 0.00000 with 0 decimals of accuracy
[19:28:49][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[19:28:49][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’

Yes. I’ve noticed this and have modified it. I’m going to release the improved code in a couple of days, since I also wanted to implement the suggestion to set generation to 0 when offline.
I hope you can wait a few days. Thanks!

2 Likes

Yes of course. after release i test it and send information.

I have updated the .h file on Github.

The spamming of the Inverter state should be dealt with. Additionally the sensors for which it makes sense to be 0 when the Inverter is offline are now actually set to 0 (previously the last known state was kept).

Tested and perfect working after night start, inverter off line generation power 0w
Well done @asseembly ! :slight_smile: Only one state is send Offline with retain message
[18:10:31][V][text_sensor:016]: ‘T-Series Inverter Mode’: Received new state Offline
[18:10:31][D][text_sensor:067]: ‘T-Series Inverter Mode’: Sending state ‘Offline’
[18:10:32][V][mqtt:415]: Publish(topic=‘foxess-inverter/sensor/t-series_inverter_mode/state’ payload=‘Offline’ retain=1)

It’s only send once every minute, right?

Yes true once per minute

@Niqu Have you had any errors yet since I included the error tracking?
I still haven’t had the possibility to check if its working as intended myself.
And also still wondering if its just an errornumber being send, or an actual message :thinking:

Yes i have one error after grid voltage was out (i test it switching off circuit braker) After grid was ok then error goes out.

was it a number or a string with hex characters?

I don’t know sorry. Next time when i go there ( 70 km away) i log debug from this error :slight_smile:

Ok. No probs :grinning:. Was just curious.

1 Like

Hi I’ going to test it today. @Niqu do you know what night mode on inverter does ? PS. do you have chint dtsu666 meter as well ? Ps. regards from Poland :wink: