Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with support my own device #22076

Closed
ur5dco opened this issue Apr 4, 2024 · 2 comments
Closed

Problem with support my own device #22076

ur5dco opened this issue Apr 4, 2024 · 2 comments
Labels
problem Something isn't working

Comments

@ur5dco
Copy link

ur5dco commented Apr 4, 2024

What happened?

Before upgrade to latest version my zigbee2mqtt support my device with external converter.
But after upgrade zigbee2mqtt to version of 1.36.1-1 my device no longer support.
This is part of my configuration.yaml:

  "0x404ccafffe452ed8":
    friendly_name: GW007-Dishwasher
external_converters:
  - meter.js

And external converter meter.js:

const fz = require("zigbee-herdsman-converters/converters/fromZigbee");
const tz = require("zigbee-herdsman-converters/converters/toZigbee");
const exposes = require("zigbee-herdsman-converters/lib/exposes");
const reporting = require("zigbee-herdsman-converters/lib/reporting");
const extend = require("zigbee-herdsman-converters/lib/extend");
const e = exposes.presets;
const ea = exposes.access;

const fzLocalMetering = {
  Energy_metering: {
    cluster: "seMetering",
    type: ["attributeReport", "readResponse"],
    convert: (model, msg, publish, options, meta) => {
      const payload = {};

      if (msg.data.hasOwnProperty("currentSummDelivered")) {
        payload.energy = msg.data["currentSummDelivered"];
      }

      return payload;
    },
  },
};

const fzLocalElMes = {
  Electric_measurment: {
    cluster: "haElectricalMeasurement",
    type: ["attributeReport", "readResponse"],
    convert: (model, msg, publish, options, meta) => {
      const payload = {};

      if (msg.data.hasOwnProperty("totalActivePower")) {
        payload.active_power = msg.data["totalActivePower"];
      }
      // if (msg.data.hasOwnProperty("totalReactivePower")) {
      //   payload.reactive_power = msg.data["totalReactivePower"];
      // }
      // if (msg.data.hasOwnProperty("rmsVoltage")) {
      //   payload.voltage_a = msg.data["rmsVoltage"];
      // }
      // if (msg.data.hasOwnProperty("rmsVoltagePhB")) {
      //   payload.voltage_b = msg.data["rmsVoltagePhB"];
      // }
      // if (msg.data.hasOwnProperty("rmsVoltagePhC")) {
      //   payload.voltage_c = msg.data["rmsVoltagePhC"];
      // }
      // if (msg.data.hasOwnProperty("rmsCurrent")) {
      //   payload.current_a = msg.data["rmsCurrent"];
      // }
      // if (msg.data.hasOwnProperty("rmsCurrentPhB")) {
      //   payload.current_b = msg.data["rmsCurrentPhB"];
      // }
      // if (msg.data.hasOwnProperty("rmsCurrentPhC")) {
      //   payload.current_c = msg.data["rmsCurrentPhC"];
      // }
      return payload;
    },
  },
};

const definition = {
  zigbeeModel: ["M2Z"],
  model: "M2Z",
  vendor: "Bogdan Goral",
  description: "Modbus to ZigBee ESP32C-6",
  fromZigbee: [
    fzLocalMetering.Energy_metering,
    fzLocalElMes.Electric_measurment,
  ],
  toZigbee: [], // Should be empty, unless device can be controlled (e.g. lights, switches).
  configure: async (device, coordinatorEndpoint, logger) => {
    const endpoint = device.getEndpoint(1);
    await reporting.bind(endpoint, coordinatorEndpoint, ["seMetering"]);
    await reporting.bind(endpoint, coordinatorEndpoint, [
      "haElectricalMeasurement",
    ]);
  },
  exposes: [
    exposes
      .numeric("energy", ea.STATE)
      .withUnit("kWh")
      .withDescription("Energy Sum"),
    exposes
      .numeric("active_power", ea.STATE)
      .withUnit("W")
      .withDescription("Active Power"),
    // exposes
    //   .numeric("reactive_power", ea.STATE)
    //   .withUnit("VAr")
    //   .withDescription("Reactive Power"),
    // exposes
    //   .numeric("voltage_a", ea.STATE)
    //   .withUnit("V")
    //   .withDescription("Phase A Voltage"),
    // exposes
    //   .numeric("voltage_b", ea.STATE)
    //   .withUnit("V")
    //   .withDescription("Phase B Voltage"),
    // exposes
    //   .numeric("voltage_c", ea.STATE)
    //   .withUnit("V")
    //   .withDescription("Phase C Voltage"),
    // exposes
    //   .numeric("current_a", ea.STATE)
    //   .withUnit("A")
    //   .withDescription("Phase A Current"),
    // exposes
    //   .numeric("current_b", ea.STATE)
    //   .withUnit("A")
    //   .withDescription("Phase B Current"),
    // exposes
    //   .numeric("current_c", ea.STATE)
    //   .withUnit("A")
    //   .withDescription("Phase C Current"),
  ],
};

module.exports = definition;

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.36.1-1

Adapter firmware version

20221226

Adapter

Zigstar GW

Setup

Addon on Home Assistant on virtual machine

Debug log

Debug 2024-04-04 10:59:09Received MQTT message on 'zgw007/bridge/request/device/configure' with data '{"id":"GW007-Dishwasher","transaction":"bu5ny-1"}'
Info 2024-04-04 10:59:09Configuring 'GW007-Dishwasher'
Debug 2024-04-04 10:59:09Received Zigbee message from 'GW007-Dishwasher', type 'readResponse', cluster 'haElectricalMeasurement', data '{}' from endpoint 1 with groupID 0
Info 2024-04-04 10:59:09MQTT publish: topic 'zgw007/GW007-Dishwasher', payload '{"current":null,"energy":null,"last_seen":"2024-04-04T08:59:10.387Z","linkquality":149,"power":null,"voltage":null}'
Error 2024-04-04 10:59:09Failed to configure 'GW007-Dishwasher', attempt 4 (Error: ZCL command 0x404ccafffe452ed8/1 haElectricalMeasurement.read(["acPowerDivisor","acPowerMultiplier"], {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Status 'UNSUPPORTED_ATTRIBUTE') at Endpoint.checkStatus (/app/node_modules/zigbee-herdsman/src/controller/model/endpoint.ts:319:28) at Endpoint.zclCommand (/app/node_modules/zigbee-herdsman/src/controller/model/endpoint.ts:762:22) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Endpoint.read (/app/node_modules/zigbee-herdsman/src/controller/model/endpoint.ts:404:24) at result.configure (/app/node_modules/zigbee-herdsman-converters/src/lib/modernExtend.ts:1234:29) at Object.configure (/app/node_modules/zigbee-herdsman-converters/src/index.ts:162:21) at Configure.configure (/app/lib/extension/configure.ts:122:13) at Configure.onMQTTMessage (/app/lib/extension/configure.ts:55:21) at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:174:17))
Info 2024-04-04 10:59:09MQTT publish: topic 'zgw007/bridge/response/device/configure', payload '{"data":{"id":"GW007-Dishwasher"},"error":"Failed to configure (ZCL command 0x404ccafffe452ed8/1 haElectricalMeasurement.read(["acPowerDivisor","acPowerMultiplier"], {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Status 'UNSUPPORTED_ATTRIBUTE'))","status":"error","transaction":"bu5ny-1"}'
Debug 2024-04-04 10:59:10Received Zigbee message from 'GW007-Dishwasher', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":1347}' from endpoint 1 with groupID 0
Info 2024-04-04 10:59:10MQTT publish: topic 'zgw007/GW007-Dishwasher', payload '{"current":null,"energy":null,"last_seen":"2024-04-04T08:59:10.824Z","linkquality":138,"power":null,"voltage":null}'
Debug 2024-04-04 10:59:20Received Zigbee message from 'GW007-Dishwasher', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":1347}' from endpoint 1 with groupID 0
Info 2024-04-04 10:59:20MQTT publish: topic 'zgw007/GW007-Dishwasher', payload '{"current":null,"energy":null,"last_seen":"2024-04-04T08:59:21.065Z","linkquality":149,"power":null,"voltage":null}'

@ur5dco ur5dco added the problem Something isn't working label Apr 4, 2024
@ur5dco
Copy link
Author

ur5dco commented Apr 4, 2024

Log from zigbee2mqtt addon:

[14:07:39] INFO: Preparing to start...
[14:07:39] INFO: Socat not enabled
[14:07:41] INFO: Starting Zigbee2MQTT...
Zigbee2MQTT:error 2024-04-04 14:07:45: Failed to load external converter file 'meter.js' (Cannot find module 'zigbee-herdsman-converters/lib/extend'
Require stack:
- /app/dist/util/utils.js
- /app/dist/util/settings.js
- /app/index.js)
Zigbee2MQTT:error 2024-04-04 14:07:45: Probably there is a syntax error in the file or the external converter is not compatible with the current Zigbee2MQTT version
Zigbee2MQTT:error 2024-04-04 14:07:45: Note that external converters are not meant for long term usage, it's meant for local testing after which a pull request should be created to add out-of-the-box support for the device

@ur5dco
Copy link
Author

ur5dco commented Apr 4, 2024

I solve problem with replacing

const fz = require("zigbee-herdsman-converters/converters/fromZigbee");
const tz = require("zigbee-herdsman-converters/converters/toZigbee");
const exposes = require("zigbee-herdsman-converters/lib/exposes");
const reporting = require("zigbee-herdsman-converters/lib/reporting");
const extend = require("zigbee-herdsman-converters/lib/extend");
const e = exposes.presets;
const ea = exposes.access;

to

const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
const zigbeeHerdsmanUtils = require('zigbee-herdsman-converters/lib/utils');
const exposes = zigbeeHerdsmanConverters['exposes'] || require("zigbee-herdsman-converters/lib/exposes");
const ea = exposes.access;
const e = exposes.presets;
const fz = zigbeeHerdsmanConverters.fromZigbeeConverters || zigbeeHerdsmanConverters.fromZigbee;
const tz = zigbeeHerdsmanConverters.toZigbeeConverters || zigbeeHerdsmanConverters.toZigbee;

in my external converter meter.js

Now it work's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant