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

Custom Converter Issue #8663

Open
snksos opened this issue Jan 23, 2025 · 1 comment
Open

Custom Converter Issue #8663

snksos opened this issue Jan 23, 2025 · 1 comment

Comments

@snksos
Copy link
Contributor

snksos commented Jan 23, 2025

What happened?

Request for Help:
My Zigbee device is a two-button switch. I have configured a custom JS file as follows. However, after pressing the physical switch or toggling the button in Home Assistant, the same issue occurs: it turns ON and then immediately turns OFF automatically. Could you please help me modify it? Thank you!

Environment Information:

zigbee2mqtt: 2.0.0-1
homeassistant: 2025.1.3

configuration.yaml

version: 4
homeassistant:
  enabled: true
advanced:
  log_level: debug
  network_key:
    - 96
    - 75
    - 159
    - 231
    - 195
    - 26
    - 236
    - 60
    - 36
    - 87
    - 1
    - 163
    - 155
    - 235
    - 195
    - 0
  pan_id: 62664
  ext_pan_id:
    - 116
    - 182
    - 175
    - 163
    - 52
    - 106
    - 178
    - 218
  channel: 25
mqtt:
  server: mqtt://core-mosquitto:1883
  user: addons
  password: eisa5aef6uekeingeetohCiseeW6phah9tie5dainoo6dahThuapopho6Eeshahy
serial:
  port: /dev/ttyUSB0
  adapter: zstack
frontend:
  enabled: true
  port: 8099
devices:
  '0x2c1165fffe8f0c6b':
    friendly_name: '0x2c1165fffe8f0c6b'

I have configured a custom JS file located at

/mnt/data/supervisor/homeassistant/zigbee2mqtt/external_converters/esl-2c.js
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const { deviceEndpoints, onOff } = require('zigbee-herdsman-converters/lib/modernExtend');
const reporting = require('zigbee-herdsman-converters/lib/reporting');

const ea = exposes.access;

const definition = {
  zigbeeModel: ['3AFE1210F0068622'],
  model: '3AFE1210F0068622',
  vendor: 'EverGrande',
  description: '2键零火开关',
  extend: [
    deviceEndpoints({ endpoints: { 1: 1, 2: 2 } }),
    onOff({ endpointNames: ['1', '2'] }), 
  ],
  exposes: [
    exposes
      .binary('state', ea.STATE_SET, 'ON', 'OFF')
      .withEndpoint('1')
      .withDescription('State of key 1'),
    exposes
      .binary('state', ea.STATE_SET, 'ON', 'OFF')
      .withEndpoint('2')
      .withDescription('State of key 2'),
  ],
  meta: { multiEndpoint: true },
  configure: async (device, coordinatorEndpoint, logger) => {
    const endpoint1 = device.getEndpoint(1);
    await reporting.bind(endpoint1, coordinatorEndpoint, ['genOnOff']);
    await endpoint1.configureReporting('genOnOff', [
      {
        attribute: 'onOff',
        minimumReportInterval: 1,
        maximumReportInterval: 3600,
        reportableChange: 1,
      },
    ]);

    const endpoint2 = device.getEndpoint(2);
    await reporting.bind(endpoint2, coordinatorEndpoint, ['genOnOff']);
    await endpoint2.configureReporting('genOnOff', [
      {
        attribute: 'onOff',
        minimumReportInterval: 1,
        maximumReportInterval: 3600,
        reportableChange: 1,
      },
    ]);
  },
};

module.exports = definition;

Machine:

root@homeassistant:/ # cat /etc/os-release 
NAME="Home Assistant OS"
VERSION="14.1.1 (WaxGourd x88 pro 20 NPU)"
ID=haos
VERSION_ID=14.1.1
PRETTY_NAME="Home Assistant OS 14.1.1"
CPE_NAME=cpe:2.3:o:home-assistant:haos:14.1.1:*:production:*:*:*:x88pro20:*
HOME_URL=https://hass.io/
VARIANT="Home Assistant OS WaxGourd x88 pro 20 NPU"
VARIANT_ID=x88pro20
SUPERVISOR_MACHINE=green
SUPERVISOR_ARCH=aarch64
OS_SUBID=x88pro20
BUILD_DATE=20250117_182810
BUILD_GIT=810199190e
BUILD_MODE=release
ZONE_MODES=cn,global
BUILD_ZONE=cn

THX!!!

Image

Image

Image

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

2.0.0

Adapter firmware version

20230507

Adapter

CC2530/CC2531

Setup

x88pro20 homeassistant addons

Debug log

Logs

[11:15:37] INFO: Preparing to start...
[11:15:37] INFO: Socat not enabled
[11:15:38] INFO: Starting Zigbee2MQTT...
Starting Zigbee2MQTT without watchdog.
[2025-01-23 11:15:48] info: 	z2m: Logging to console, file (filename: log.log)
[2025-01-23 11:15:48] debug: 	z2m: Loaded state from file /config/zigbee2mqtt/state.json
[2025-01-23 11:15:48] info: 	z2m: Starting Zigbee2MQTT version 2.0.0 (commit #unknown)
[2025-01-23 11:15:48] debug: 	z2m: sd-notify loaded
[2025-01-23 11:15:48] info: 	z2m: Starting zigbee-herdsman (3.2.1)
[2025-01-23 11:15:48] debug: 	z2m: Using zigbee-herdsman with settings: '"{\"network\":{\"panID\":62664,\"extendedPanID\":[116,182,175,163,52,106,178,218],\"channelList\":[25],\"networkKey\":\"HIDDEN\"},\"databasePath\":\"/config/zigbee2mqtt/database.db\",\"databaseBackupPath\":\"/config/zigbee2mqtt/database.db.backup\",\"backupPath\":\"/config/zigbee2mqtt/coordinator_backup.json\",\"serialPort\":{\"path\":\"/dev/ttyUSB0\",\"adapter\":\"zstack\"},\"adapter\":{\"disableLED\":false}}"'
[2025-01-23 11:15:48] debug: 	zh:adapter:discovery: Connected devices: [{"path":"/dev/ttyS2"},{"path":"/dev/ttyUSB0","manufacturer":"1a86","pnpId":"usb-1a86_USB_Serial-if00-port0","vendorId":"1a86","productId":"7523"}]
[2025-01-23 11:15:48] debug: 	zh:adapter:discovery: Unable to match USB adapter: zstack | /dev/ttyUSB0
[2025-01-23 11:15:48] debug: 	zh:controller: Starting with options '{"network":{"networkKeyDistribute":false,"networkKey":"HIDDEN","panID":62664,"extendedPanID":[116,182,175,163,52,106,178,218],"channelList":[25]},"serialPort":{"path":"/dev/ttyUSB0","adapter":"zstack"},"adapter":{"disableLED":false},"databasePath":"/config/zigbee2mqtt/database.db","databaseBackupPath":"/config/zigbee2mqtt/database.db.backup","backupPath":"/config/zigbee2mqtt/coordinator_backup.json"}'

......

[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- AREQ: AF - incomingMsg - {"groupid":0,"clusterid":6,"srcaddr":25873,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":240,"securityuse":0,"timestamp":10371801,"transseqnumber":0,"len":7,"data":{"type":"Buffer","data":[8,4,10,0,0,16,1]}}
[2025-01-23 11:18:36] debug: 	zh:controller: Received payload: clusterID=6, address=25873, groupID=0, endpoint=1, destinationEndpoint=1, wasBroadcast=false, linkQuality=240, frame={"header":{"frameControl":{"frameType":0,"manufacturerSpecific":false,"direction":1,"disableDefaultResponse":false,"reservedBits":0},"transactionSequenceNumber":4,"commandIdentifier":10},"payload":[{"attrId":0,"dataType":16,"attrData":1}],"command":{"ID":10,"name":"report","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}]}}
[2025-01-23 11:18:36] debug: 	zh:controller:endpoint: ZCL command 0x2c1165fffe8f0c6b/1 genOnOff.defaultRsp({"cmdId":10,"statusCode":0}, {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":1,"reservedBits":0,"transactionSequenceNumber":4,"writeUndiv":false})
[2025-01-23 11:18:36] debug: 	zh:zstack: sendZclFrameToEndpointInternal 0x2c1165fffe8f0c6b:25873/1 (0,0,1)
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: --> SREQ: AF - dataRequest - {"dstaddr":25873,"destendpoint":1,"srcendpoint":1,"clusterid":6,"transid":1,"options":0,"radius":30,"len":5,"data":{"type":"Buffer","data":[24,4,11,10,0]}}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:writer: --> frame [254,15,36,1,17,101,1,1,6,0,1,0,30,5,24,4,11,10,0,95]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext []
[2025-01-23 11:18:36] debug: 	z2m: Received Zigbee message from '0x2c1165fffe8f0c6b', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0

[2025-01-23 11:18:36] info: 	z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0x2c1165fffe8f0c6b', payload '{"linkquality":240,"power_on_behavior_1":null,"power_on_behavior_2":null,"state_1":"ON","state_2":"OFF"}'

[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: <-- [254,1,100,1,0,100,254,3,68,128,0,1,1,199]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext [254,1,100,1,0,100,254,3,68,128,0,1,1,199]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --> parsed 1 - 3 - 4 - 1 - [0] - 100
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- SRSP: AF - dataRequest - {"status":0}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext [254,3,68,128,0,1,1,199]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --> parsed 3 - 2 - 4 - 128 - [0,1,1] - 199
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- AREQ: AF - dataConfirm - {"status":0,"endpoint":1,"transid":1}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext []
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: <-- [254,27,68,129,0,0,6,0,17,101,1,1,0,240,0,214,107,158,0,0,7,8,5,10,0,0,16,0,17,101,29,6]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext [254,27,68,129,0,0,6,0,17,101,1,1,0,240,0,214,107,158,0,0,7,8,5,10,0,0,16,0,17,101,29,6]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --> parsed 27 - 2 - 4 - 129 - [0,0,6,0,17,101,1,1,0,240,0,214,107,158,0,0,7,8,5,10,0,0,16,0,17,101,29] - 6
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- AREQ: AF - incomingMsg - {"groupid":0,"clusterid":6,"srcaddr":25873,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":240,"securityuse":0,"timestamp":10382294,"transseqnumber":0,"len":7,"data":{"type":"Buffer","data":[8,5,10,0,0,16,0]}}
[2025-01-23 11:18:36] debug: 	zh:controller: Received payload: clusterID=6, address=25873, groupID=0, endpoint=1, destinationEndpoint=1, wasBroadcast=false, linkQuality=240, frame={"header":{"frameControl":{"frameType":0,"manufacturerSpecific":false,"direction":1,"disableDefaultResponse":false,"reservedBits":0},"transactionSequenceNumber":5,"commandIdentifier":10},"payload":[{"attrId":0,"dataType":16,"attrData":0}],"command":{"ID":10,"name":"report","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}]}}
[2025-01-23 11:18:36] debug: 	zh:controller:endpoint: ZCL command 0x2c1165fffe8f0c6b/1 genOnOff.defaultRsp({"cmdId":10,"statusCode":0}, {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":1,"reservedBits":0,"transactionSequenceNumber":5,"writeUndiv":false})
[2025-01-23 11:18:36] debug: 	zh:zstack: sendZclFrameToEndpointInternal 0x2c1165fffe8f0c6b:25873/1 (0,0,1)
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: --> SREQ: AF - dataRequest - {"dstaddr":25873,"destendpoint":1,"srcendpoint":1,"clusterid":6,"transid":2,"options":0,"radius":30,"len":5,"data":{"type":"Buffer","data":[24,5,11,10,0]}}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:writer: --> frame [254,15,36,1,17,101,1,1,6,0,2,0,30,5,24,5,11,10,0,93]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext []
[2025-01-23 11:18:36] debug: 	z2m: Received Zigbee message from '0x2c1165fffe8f0c6b', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0

[2025-01-23 11:18:36] info: 	z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0x2c1165fffe8f0c6b', payload '{"linkquality":240,"power_on_behavior_1":null,"power_on_behavior_2":null,"state_1":"OFF","state_2":"OFF"}'

[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: <-- [254,1,100,1,0,100]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext [254,1,100,1,0,100]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --> parsed 1 - 3 - 4 - 1 - [0] - 100
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- SRSP: AF - dataRequest - {"status":0}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext []
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: <-- [254,3,68,128,0,1,2,196]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext [254,3,68,128,0,1,2,196]
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --> parsed 3 - 2 - 4 - 128 - [0,1,2] - 196
[2025-01-23 11:18:36] debug: 	zh:zstack:znp: <-- AREQ: AF - dataConfirm - {"status":0,"endpoint":1,"transid":2}
[2025-01-23 11:18:36] debug: 	zh:zstack:unpi:parser: --- parseNext []

@snksos
Copy link
Contributor Author

snksos commented Jan 23, 2025

btw, ZHA is normal , But Z2M...

If the custom converter is not connected, the effect will be the same. After turning on, it will immediately turn off. Pressing the physical switch has the same effect.

The same applies to version 1.42.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant