zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Frient EMIZB-151 does not provide produced energy

Open AJFproduction opened this issue 1 year ago • 20 comments

What happened?

The energy produced or fed back into the grid is not being delivered, even though the device is supplying it. (currentSummdelivered)

What did you expect to happen?

Add this numeric value

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.42.0

Adapter firmware version

8.0.3.0

Adapter

box luna

Setup

Device database.db entry

No response

Debug log

No response

Notes

No response

AJFproduction avatar Oct 28 '25 19:10 AJFproduction

I think this was added in https://github.com/Koenkk/zigbee-herdsman-converters/issues/10458 (CC: @Fabiancrg)

Koenkk avatar Oct 28 '25 20:10 Koenkk

Hello, than you for the link. My knowledge is limited, but is it possible for me to integrate this feature through an update?

AJFproduction avatar Oct 30 '25 21:10 AJFproduction

Hi @AJFproduction normally you should not have much to do so please give me your feedback after the next upgrade.

Fabiancrg avatar Nov 01 '25 16:11 Fabiancrg

With pleasure, I'm eagerly looking forward to this update.

AJFproduction avatar Nov 01 '25 16:11 AJFproduction

Just install; new commands appears but seems not working; 2.8.0 seems also still missing (but not real problem as 2.8.0 = 2.8.1 + 2.8.2)

When I tried to refrech value, I got this error. z2m: No converter available for 'energy_tier_1' on '0x0015bc001b1012db': ("") z2m: No converter available for 'energy_tier_2' on '0x0015bc001b1012db': ("") z2m: No converter available for 'produced_energy_tier_1' on '0x0015bc001b1012db': ("") z2m: No converter available for 'produced_energy_tier_2' on '0x0015bc001b1012db': ("")

EMIZB-151 latest F/W App: 0.0 build 3 // Stack: 0.1 build 7

AJFproduction avatar Nov 01 '25 22:11 AJFproduction

Just upgraded to 2.6.3 and now I can see this:

Image

Where Energy = Energy tier 1 + Energy tier 2

You also have Produced energy tier 1 and Produced energy tier 2 but not the sum, I will check if this can be added in next release. In the meanwhile, you can sum the two as produced energy in your home automation software.

Fabiancrg avatar Nov 01 '25 22:11 Fabiancrg

Unfortunatly, not working for me.

Image

Image

AJFproduction avatar Nov 01 '25 22:11 AJFproduction

Image

AJFproduction avatar Nov 01 '25 23:11 AJFproduction

So apparently there is a problem with the reporting configuration, I tried to remove/add the device and it's not working anymore. Reporting is sometimes only partially configured but most of the time not configured. If you want, you can use this external converter, create a folder /opt/zigbee2mqtt/data/external_converters and copy the file frient_EMIZB-151.js in it. After a restart of Zigbee2mqtt, everything should be back.

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
  zigbeeModel: ['EMIZB-151'],
  model: 'EMIZB-151',
  vendor: 'Frient',
  description: 'Electricity Meter Interface 2 P1',

  // Use the official modern extend for three-phase electricity meter (includes all calibration and precision)
  extend: [m.electricityMeter({threePhase: true})],

  // Add additional seMetering functionality for energy tariffs
  fromZigbee: [
    {
      cluster: 'seMetering',
      type: ['attributeReport', 'readResponse'],
      convert: (model, msg, publish, options, meta) => {
        const result = {};

        // Additional energy measurements for tariffs (not covered by standard electricityMeter)
        if ('currentSummReceived' in msg.data) {
          result.energy_produced = Math.round(msg.data['currentSummReceived'] / 1000);
        }

        if ('currentTier1SummDelivered' in msg.data) {
          result.energy_consumed_tariff1 = Math.round(msg.data['currentTier1SummDelivered'] / 1000);
        }
        if ('currentTier2SummDelivered' in msg.data) {
          result.energy_consumed_tariff2 = Math.round(msg.data['currentTier2SummDelivered'] / 1000);
        }
        if ('currentTier1SummReceived' in msg.data) {
          result.energy_produced_tariff1 = Math.round(msg.data['currentTier1SummReceived'] / 1000);
        }
        if ('currentTier2SummReceived' in msg.data) {
          result.energy_produced_tariff2 = Math.round(msg.data['currentTier2SummReceived'] / 1000);
        }

        return result;
      },
    }
  ],

  // Additional exposes for the extra seMetering attributes not covered by electricityMeter
  exposes: [
    e.numeric('energy_produced', ea.STATE).withUnit('kWh').withDescription('Total energy returned to the grid - OBIS 2.8.0'),
    e.numeric('energy_consumed_tariff1', ea.STATE).withUnit('kWh').withDescription('Energy consumed in tariff 1 (peak/high) - OBIS 1.8.1'),
    e.numeric('energy_consumed_tariff2', ea.STATE).withUnit('kWh').withDescription('Energy consumed in tariff 2 (off-peak/low) - OBIS 1.8.2'),
    e.numeric('energy_produced_tariff1', ea.STATE).withUnit('kWh').withDescription('Energy produced in tariff 1 (peak/high) - OBIS 2.8.1'),
    e.numeric('energy_produced_tariff2', ea.STATE).withUnit('kWh').withDescription('Energy produced in tariff 2 (off-peak/low) - OBIS 2.8.2'),
  ],

  ota: true,
  endpoint: (device) => ({default: 2}),

  configure: async (device, coordinatorEndpoint, logger) => {
    const endpoint = device.getEndpoint(2);

    // Bind seMetering cluster for the additional energy tariff measurements
    try {
      await reporting.bind(endpoint, coordinatorEndpoint, ['seMetering']);
    } catch (error) {
      // Binding can fail but device may still work
    }

    // Read metering multiplier/divisor
    await reporting.readMeteringMultiplierDivisor(endpoint).catch(() => {});

    // Configure the additional seMetering attributes for energy tariffs
    const meteringAttributes = [
      'currentSummReceived',
      'currentTier1SummDelivered',
      'currentTier2SummDelivered',
      'currentTier1SummReceived',
      'currentTier2SummReceived'
    ];

    // Read the attributes initially
    await endpoint.read('seMetering', meteringAttributes).catch(() => {});

    // Configure reporting for energy tariff attributes
    for (const attr of meteringAttributes) {
      await endpoint.configureReporting('seMetering', [{
        attribute: attr,
        minimumReportInterval: 300,      // Don't report more often than every 5 minutes
        maximumReportInterval: 3600,     // Report at least every hour
        reportableChange: 1000            // Report when energy changes by 1 kWh
      }]).catch(() => {});
    }
  },
};

module.exports = definition;

I will work on a fix for the existing converter.

Fabiancrg avatar Nov 01 '25 23:11 Fabiancrg

Fisrt of all thank you for your support. My knwolege is limited.

Here’s what I did, but it doesn’t work:

(1) I created the file in /opt/... as root. → but it seems not correct. (2) I created a .txt file and then renamed it to .js. (3) I copied the code you gave me into it. (4) I restarted the dependencies of JeeZigbee2MQTT. (5) I tryed also this directory /var/www/html/plugins/zigbee2mqtt/resources/zigbee2mqtt/data/external_converters/

 in that directory, the error is different, --> Cannot open the websocket;

frient_EMIZB-151.js

AJFproduction avatar Nov 02 '25 06:11 AJFproduction

my knowlede is very limited, but it seems when I restart the jeezigbee dependencies, the directory is scratched ... So may be I don't understand how to restart "restart Zigbee2mqtt" Could you also helpd me to find the good directory, I imagine /opt/ ... is not in the root ?

Thank you very much.

AJFproduction avatar Nov 02 '25 07:11 AJFproduction

The directory is: /opt/zigbee2mqtt/data/external_converters

You might have to use sudo to create it so if the command

mkdir /opt/zigbee2mqtt/data/external_converters

returns Permission denied then use

sudo mkdir /opt/zigbee2mqtt/data/external_converters

then copy the content of the converter above (make sure you use the copy button)

nano frient_EMIZB-151.js

or if you had to use sudo to create the directory

sudo nano frient_EMIZB-151.js

and paste the code

use CTRL-x to save

Then restart zigbee2mqtt, preferably before restarting, you can remove the device, it will rejoin automatically after the restart once you permit joining.

If you cannot do that, if the directory disappear after restart, please let me know how you installed it (+platform)

Fabiancrg avatar Nov 02 '25 09:11 Fabiancrg

OK, I have a box luna, so I have to use SSH. I'll try it. But if I remove the device, the command ID will change, which means I’ll need to update all the scenario code accordingly. So may be for me it is better to wait the fix. Thanks a lot for your help!

AJFproduction avatar Nov 02 '25 09:11 AJFproduction

Which software are you using ?

Fabiancrg avatar Nov 02 '25 09:11 Fabiancrg

I have different scenarios to manage annual, monthly, and daily energy using some PHP code. I use command numbers, so if I have to remove and pair the device again, the command number will change. This means I have to go through the code to make corrections.

For example: $v1 = cmd::byId(1260)->execCmd() *1000 ; // Production PV en Wh $v2 = cmd::byId(1117)->execCmd() ; // Production moyenne sur les 5 dernières minutes en W

I compute also data for pvoutput. (https://pvoutput.org/intraday.jsp?id=20913&sid=18792)

I can wait for a fix. Since my knowledge of the Jeedom architecture is limited, I'm hesitant to start this manual operation for fear of making things worse.

AJFproduction avatar Nov 02 '25 17:11 AJFproduction

I won't be able to help you with that but I am working on the issue so hopefully I might get a fix soon

Fabiancrg avatar Nov 02 '25 17:11 Fabiancrg

Many thanks for the good job.

AJFproduction avatar Nov 02 '25 17:11 AJFproduction

I submitted two PR, one to add "Produced energy" and another to fix the data not being reported.

Reading the attributes using /get is still not working, I need to continue working on that but the automatic reporting is working so you can adapt the reporting settings if needed.

Fabiancrg avatar Nov 02 '25 22:11 Fabiancrg

Manually added in the automatic reporting. Thanks a lot.

Image

AJFproduction avatar Nov 04 '25 16:11 AJFproduction

Solved with version 2.7.0 of MQTT; thanks.

AJFproduction avatar Dec 02 '25 06:12 AJFproduction