Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge πŸŒ‰, get rid of your proprietary Zigbee bridges πŸ”¨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.93k stars 1.66k forks source link

Device support: 'Nue' / '3A Smarthome' smart switch range #176

Closed highground88 closed 5 years ago

highground88 commented 6 years ago

Hi all,

I think I've hit a snag and would appreciate some tips if someone could? It's been quite a mission just to get this far, I'm not very experienced in linux and even getting a machine up and running wasn't much fun.

I've taken two " 'Nue' 2 gang smart switches " off the supplied 'Nue' hub, and believe I have updated the 'devices.js' appropriately as they are being detected (copy of terminal below). Here's the model info lines from both entries in the 'devices' file:

zigbeeModel: ['FB56+ZSW1HKJ2.5'] and zigbeeModel: ['FB56+ZSW1HKJ1.7']

Funnily enough I think these are the same model 2 switch devices.. Perhaps one is a later revision? Regardless, this is the two switch model. I am yet to test on the 1 switch, 3 switch, dimmer and also the 1 and four button 'scene' switches I have just installed. PRODUCT LINK

Once the 'devices.js' file is updated, and zigbee2mqtt is restarted, I'm struggling to see any immediate messages when the switches are turned on and off - there doesn't seem to be anything coming through, and no sort of pattern reflecting how I've switched them on/off.

Where should I go next?

I don't know if this is helpful or not, but others seem to have been attaching these switches to the SmartThigns hub, via a similar detection method which is supplied by the distributor - would this be useful? LINK TO PDF

Thanks!

PASTEBIN DUMP

highground88 commented 5 years ago

@Koenkk I've started clean after the above log and pulled your dev version in again, making the same change as above to the af.js file.

As I was going back through your documentation... something dawned on me when I re-read your debugging guide. I've been using DEBUG=zigbee-shepherd* npm start for all these logs when I think I should have been using just DEBUG=* npm start ...? :astonished:

Subsequently I now have a very much bigger and detailed log for you which I think might help with the communications..... very sorry if I've been doing this wrong all this time!

The 2 devices were already paired but I have re-paired each during the log and also actioned all switches. I really hope this is the breakthrough you need....

New 'COMPLETE' LOG

Koenkk commented 5 years ago

Can you point me to what output is produced when doing actions on the switches? (I don't see any useful in the current log)

highground88 commented 5 years ago

Not sure if useful it did look different than before, but I believe this is a switch message:

  zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object] +14ms
readRsp
  zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object] +1ms
readRsp
  serialport:poller received "readable" +38ms
  serialport:bindings read +67ms
  serialport:unixRead Starting read +39ms
  serialport:unixRead Finished read 33 bytes +1ms
  serialport:main binding.read finished +69ms
  cc-znp { sof: 254,
  cc-znp   len: 28,
  cc-znp   type: 'AREQ',
  cc-znp   subsys: 'AF',
  cc-znp   cmd: 'incomingMsg',
  cc-znp   payload:
  cc-znp    { groupid: 0,
  cc-znp      clusterid: 8,
  cc-znp      srcaddr: 8910,
  cc-znp      srcendpoint: 11,
  cc-znp      dstendpoint: 11,
  cc-znp      wasbroadcast: 0,
  cc-znp      linkquality: 76,
  cc-znp      securityuse: 0,
  cc-znp      timestamp: 1736982,
  cc-znp      transseqnumber: 0,
  cc-znp      len: 8,
  cc-znp      data: <Buffer 18 f4 01 00 00 00 20 f8> },
  cc-znp   fcs: 35,
  cc-znp   csum: 35 } +62ms
  serialport:main _read reading +10ms
  serialport:bindings read +11ms
  serialport:unixRead Starting read +11ms
  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 8, srcaddr: 8910, srcendpoint: 11, dstendpoint: 11, wasbroadcast: 0, linkquality: 76, securityuse: 0, timestamp: 1736982, transseqnumber: 0, len: 8, data: <Buffer 18 f4 01 00 00 00 20 f8> } +4ms

How do I donate to buy you a coffee or two?!?

Koenkk commented 5 years ago

That doesn't contain any useful information unfortunately, what code are you using for this device?

There is a donation link here: https://github.com/Koenkk/zigbee2mqtt/blob/master/README.md

highground88 commented 5 years ago
{
        zigbeeModel: ['FB56+ZSW1HKJ2.5', 'FB56+ZSW1HKJ1.7', 'FB56+ZSC05HG1.0'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'on/off',
        fromZigbee: [fz.nue_power_state, fz.ignore_onoff_change, fz.generic_state],
        toZigbee: [tz.on_off],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
        const ep16 = shepherd.find(ieeeAddr, 16);
        const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 10, repChange: 0};

            const actions = [
                (cb) => ep16.read('genOnOff', 'onOff', cb),
                (cb) => ep16.foundation('genOnOff', 'configReport', [cfg], foundationCfg, cb),
        ];

        execute(ep16, actions, callback);
      },
    },
Koenkk commented 5 years ago

Can you provide the database.db of FB56+ZSC05HG1.0

highground88 commented 5 years ago

Here you go, thanks:

{"id":3,"type":"Router","ieeeAddr":"0x00124b001545a430","nwkAddr":8910,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSC05HG1.0","epList":[11,13],"status":"online","joinTime":1547518256,"endpoints":{"11":{"profId":260,"epId":11,"devId":257,"inClusterList":[0,3,4,5,6,8],"outClusterList":[],"clusters":{"genBasic":{"dir":{"value":1},"attrs":{}},"genIdentify":{"dir":{"value":1},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{}},"genLevelCtrl":{"dir":{"value":1},"attrs":{}}}},"13":{"profId":49246,"epId":13,"devId":57694,"inClusterList":[4096],"outClusterList":[4096],"clusters":{"lightLink":{"dir":{"value":3},"attrs":{}}}}},"_id":"4UtIx3zVqzgjDM6y"}
{"id":2,"type":"Router","ieeeAddr":"0x00124b0014afe1fb","nwkAddr":14173,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSW1HKJ1.7","epList":[16,17],"status":"online","joinTime":1547518291,"endpoints":{"16":{"profId":260,"epId":16,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{"onOff":1}}}},"17":{"profId":260,"epId":17,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{"16393":1287651328,"hwVersion":0,"manufacturerName":"Feibit Inc co.  ","modelId":"FB56+ZSW1HKJ1.7","dateCode":"20161030        ","powerSource":1,"locationDesc":"                ","physicalEnv":0,"deviceEnabled":1}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{"onOff":0}}}}},"_id":"SYv4N45UlvOeo59l"}
{"id":1,"type":"Coordinator","ieeeAddr":"0x00124b0014bdea20","nwkAddr":0,"manufId":0,"epList":[1,2,3,4,5,6,11],"status":"online","joinTime":1547518207,"endpoints":{"1":{"profId":260,"epId":1,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"2":{"profId":257,"epId":2,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"3":{"profId":261,"epId":3,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"4":{"profId":263,"epId":4,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"5":{"profId":264,"epId":5,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"6":{"profId":265,"epId":6,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"11":{"profId":260,"epId":11,"devId":1024,"inClusterList":[0,1281,3],"outClusterList":[1280,1282,3],"clusters":{"genBasic":{"dir":{"value":1},"acls":{"zclVersion":"R","hwVersion":"R","manufacturerName":"R","modelId":"R","dateCode":"R","powerSource":"R","locationDesc":"RW","physicalEnv":"RW","deviceEnabled":"RW"},"attrs":{"zclVersion":1,"hwVersion":1,"manufacturerName":"sivann inc.","modelId":"hiver0001","dateCode":"20170407","powerSource":1,"locationDesc":"    ","physicalEnv":0,"deviceEnabled":1}},"ssIasAce":{"dir":{"value":1}},"ssIasZone":{"dir":{"value":2},"cmdRsps":{"enrollReq":{"exec":"_exec_"},"statusChangeNotification":{"exec":"_exec_"}}},"ssIasWd":{"dir":{"value":2}},"genIdentify":{"dir":{"value":3},"acls":{"identifyTime":"RW"},"attrs":{"identifyTime":0}}}}},"_id":"xyNF05O5uq7OmfpG"}
{"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
{"id":1,"type":"Coordinator","ieeeAddr":"0x00124b0014bdea20","nwkAddr":0,"manufId":0,"epList":[1,2,3,4,5,6],"status":"online","joinTime":1547518431,"endpoints":{"1":{"profId":260,"epId":1,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"2":{"profId":257,"epId":2,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"3":{"profId":261,"epId":3,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"4":{"profId":263,"epId":4,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"5":{"profId":264,"epId":5,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"6":{"profId":265,"epId":6,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}}},"_id":"xyNF05O5uq7OmfpG"}
{"id":3,"type":"Router","ieeeAddr":"0x00124b001545a430","nwkAddr":8910,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSC05HG1.0","epList":[11,13],"status":"offline","joinTime":null,"endpoints":{"11":{"profId":260,"epId":11,"devId":257,"inClusterList":[0,3,4,5,6,8],"outClusterList":[],"clusters":{"genBasic":{"dir":{"value":1},"attrs":{}},"genIdentify":{"dir":{"value":1},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{}},"genLevelCtrl":{"dir":{"value":1},"attrs":{}}}},"13":{"profId":49246,"epId":13,"devId":57694,"inClusterList":[4096],"outClusterList":[4096],"clusters":{"lightLink":{"dir":{"value":3},"attrs":{}}}}},"_id":"4UtIx3zVqzgjDM6y"}
{"id":2,"type":"Router","ieeeAddr":"0x00124b0014afe1fb","nwkAddr":14173,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSW1HKJ1.7","epList":[16,17],"status":"offline","joinTime":null,"endpoints":{"16":{"profId":260,"epId":16,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{"onOff":1}}}},"17":{"profId":260,"epId":17,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{"16393":1287651328,"hwVersion":0,"manufacturerName":"Feibit Inc co.  ","modelId":"FB56+ZSW1HKJ1.7","dateCode":"20161030        ","powerSource":1,"locationDesc":"                ","physicalEnv":0,"deviceEnabled":1}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{"onOff":0}}}}},"_id":"SYv4N45UlvOeo59l"}
{"id":1,"type":"Coordinator","ieeeAddr":"0x00124b0014bdea20","nwkAddr":0,"manufId":0,"epList":[1,2,3,4,5,6,11],"status":"online","joinTime":1547518431,"endpoints":{"1":{"profId":260,"epId":1,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"2":{"profId":257,"epId":2,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"3":{"profId":261,"epId":3,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"4":{"profId":263,"epId":4,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"5":{"profId":264,"epId":5,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"6":{"profId":265,"epId":6,"devId":5,"inClusterList":[],"outClusterList":[],"clusters":{}},"11":{"profId":260,"epId":11,"devId":1024,"inClusterList":[0,1281,3],"outClusterList":[1280,1282,3],"clusters":{"genBasic":{"dir":{"value":1},"acls":{"zclVersion":"R","hwVersion":"R","manufacturerName":"R","modelId":"R","dateCode":"R","powerSource":"R","locationDesc":"RW","physicalEnv":"RW","deviceEnabled":"RW"},"attrs":{"zclVersion":1,"hwVersion":1,"manufacturerName":"sivann inc.","modelId":"hiver0001","dateCode":"20170407","powerSource":1,"locationDesc":"    ","physicalEnv":0,"deviceEnabled":1}},"ssIasAce":{"dir":{"value":1}},"ssIasZone":{"dir":{"value":2},"cmdRsps":{"enrollReq":{"exec":"_exec_"},"statusChangeNotification":{"exec":"_exec_"}}},"ssIasWd":{"dir":{"value":2}},"genIdentify":{"dir":{"value":3},"acls":{"identifyTime":"RW"},"attrs":{"identifyTime":0}}}}},"_id":"xyNF05O5uq7OmfpG"}
{"$$deleted":true,"_id":"SYv4N45UlvOeo59l"}
{"id":4,"type":"Router","ieeeAddr":"0x00124b0014afe1fb","nwkAddr":64303,"manufId":0,"epList":[16,17],"status":"online","joinTime":1547518490,"endpoints":{"16":{"profId":260,"epId":16,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{}},"17":{"profId":260,"epId":17,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{}}},"_id":"k0zWxYEwPSPsJ3Sr"}
{"id":4,"type":"Router","ieeeAddr":"0x00124b0014afe1fb","nwkAddr":64303,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSW1HKJ1.7","epList":[16,17],"status":"online","joinTime":1547518490,"endpoints":{"16":{"profId":260,"epId":16,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{}},"17":{"profId":260,"epId":17,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{}}},"_id":"k0zWxYEwPSPsJ3Sr"}
{"id":4,"type":"Router","ieeeAddr":"0x00124b0014afe1fb","nwkAddr":64303,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSW1HKJ1.7","epList":[16,17],"status":"online","joinTime":1547518490,"endpoints":{"16":{"profId":260,"epId":16,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{}}}},"17":{"profId":260,"epId":17,"devId":2,"inClusterList":[0,4,5,6],"outClusterList":[0],"clusters":{"genBasic":{"dir":{"value":3},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{}}}}},"_id":"k0zWxYEwPSPsJ3Sr"}
{"id":3,"type":"Router","ieeeAddr":"0x00124b001545a430","nwkAddr":8910,"manufId":0,"manufName":"Feibit Inc co.  ","powerSource":"Mains (single phase)","modelId":"FB56+ZSC05HG1.0","epList":[11,13],"status":"online","joinTime":1547518522,"endpoints":{"11":{"profId":260,"epId":11,"devId":257,"inClusterList":[0,3,4,5,6,8],"outClusterList":[],"clusters":{"genBasic":{"dir":{"value":1},"attrs":{}},"genIdentify":{"dir":{"value":1},"attrs":{}},"genGroups":{"dir":{"value":1},"attrs":{}},"genScenes":{"dir":{"value":1},"attrs":{}},"genOnOff":{"dir":{"value":1},"attrs":{}},"genLevelCtrl":{"dir":{"value":1},"attrs":{}}}},"13":{"profId":49246,"epId":13,"devId":57694,"inClusterList":[4096],"outClusterList":[4096],"clusters":{"lightLink":{"dir":{"value":3},"attrs":{}}}}},"_id":"4UtIx3zVqzgjDM6y"}
Koenkk commented 5 years ago

Can you add the following to devices.js:

    {
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'on/off, brightness',
        fromZigbee: [],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
            ];

            execute(device, actions, callback);
      },
    },
highground88 commented 5 years ago

Latest Log

The button presses showed only as "readRsp" this time. I re-paired, but continued to do the same. I didn't delete the database first, just followed your instructions. Cheers

Koenkk commented 5 years ago

Can you try with:

    {
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'on/off, brightness',
        fromZigbee: [],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 3, repChange: 0};
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
                (cb) => device.foundation('genOnOff', 'configReport', [cfg], foundationCfg, cb),
                (cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb),
            ];

            execute(device, actions, callback);
      },
    },
highground88 commented 5 years ago

Sure. For info the "readRsp" is definitely a button press - it just happens that this dimming device rapidly sends the command even when briefly held down, hence why so many,

> zigbee2mqtt@1.0.1 start /opt/zigbee2mqtt
> node index.js

  zigbee2mqtt:info 1/16/2019, 11:11:06 AM Logging to directory: '/opt/zigbee2mqtt/data/log/2019-01-16.11-11-06'
  zigbee2mqtt:debug 1/16/2019, 11:11:07 AM Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11],"precfgkey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13]},"dbPath":"/opt/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
  zigbee2mqtt:debug 1/16/2019, 11:11:07 AM Loaded state from file /opt/zigbee2mqtt/data/state.json
  zigbee2mqtt:info 1/16/2019, 11:11:07 AM Starting zigbee2mqtt version 1.0.1 (commit #9605e72)
  zigbee2mqtt:info 1/16/2019, 11:11:07 AM Starting zigbee-shepherd
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM zigbee-shepherd started
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM Coordinator firmware version: '20181024'
  zigbee2mqtt:debug 1/16/2019, 11:11:08 AM zigbee-shepherd info: {"enabled":true,"net":{"state":"Coordinator","channel":11,"panId":"0x1a62","extPanId":"0xdddddddddddddddd","ieeeAddr":"0x00124b0014bdea20","nwkAddr":0},"firmware":{"transportrev":2,"product":0,"version":"2.6.3","revision":20181024},"startTime":1547637068,"joinTimeLeft":0}
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM Currently 2 devices are joined:
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM 0x00124b001545a430 (0x00124b001545a430): TODO - Nue ZigBee smart dimmer switch (Router)
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM 0x00124b0014afe1fb (0x00124b0014afe1fb): TODO - Nue Smart light switch - 2 gang (Router)
  zigbee2mqtt:warn 1/16/2019, 11:11:08 AM `permit_join` set to  `true` in configuration.yaml.
  zigbee2mqtt:warn 1/16/2019, 11:11:08 AM Allowing new devices to join.
  zigbee2mqtt:warn 1/16/2019, 11:11:08 AM Set `permit_join` to `false` once you joined all devices.
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM Zigbee: allowing new devices to join.
  zigbee2mqtt:info 1/16/2019, 11:11:08 AM Connecting to MQTT server at mqtt://192.168.0.101
  zigbee2mqtt:debug 1/16/2019, 11:11:09 AM Configuring 0x00124b001545a430 (0x00124b001545a430) ...
  zigbee2mqtt:debug 1/16/2019, 11:11:09 AM Configuring 0x00124b0014afe1fb (0x00124b0014afe1fb) ...
  zigbee2mqtt:info 1/16/2019, 11:11:09 AM zigbee-shepherd ready
  zigbee2mqtt:info 1/16/2019, 11:11:09 AM Connected to MQTT server
  zigbee2mqtt:info 1/16/2019, 11:11:09 AM MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
  zigbee2mqtt:debug 1/16/2019, 11:11:09 AM Mounted the cieApp (epId 11)
  zigbee2mqtt:error 1/16/2019, 11:11:10 AM Failed to configure 0x00124b0014afe1fb (0x00124b0014afe1fb) ('Error: AF data request fails, status code: 233. MAC no ack.')
defaultRsp
defaultRsp
  zigbee2mqtt:error 1/16/2019, 11:11:10 AM Failed to configure 0x00124b001545a430 (0x00124b001545a430) ('TypeError: Cannot read property 'status' of undefined')
readRsp
readRsp
readRsp
readRsp

Is something else in my setup possibly broken at the moment - would it be worth pulling it down again, and if so, would you like me to change the cie file or anything else? Thanks

Koenkk commented 5 years ago

If that is the case, can you add readRsp to this array: https://github.com/Koenkk/zigbee-shepherd/blob/master/lib/components/af.js#L687

highground88 commented 5 years ago

I've edited this file in "/opt/zigbee2mqtt/node_modules/zigbee-shepherd/lib/components"

     const cmdIDs = ['on', 'offWithEffect', 'step', 'stop', //Philips-RWL020-RWL021
                            'off', 'stepColorTemp', 'moveWithOnOff', 'move', 'readRsp', 'moveHue', 'moveToSat$
                            'stopWithOnOff', 'moveToLevelWithOnOff', 'toggle', 'tradfriArrowSingle', 'tradfri$

but unfortunately the output is the same.

Koenkk commented 5 years ago

Can you try with:

    {
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'on/off, brightness',
        fromZigbee: [],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 3, repChange: 0};
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
                (cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb),
            ];

            execute(device, actions, callback);
      },
    },
highground88 commented 5 years ago

No change sorry.... LOG

highground88 commented 5 years ago

This is the resulting log of both devices powered up on boot.

2 devices

Koenkk commented 5 years ago

Could you siff the zigbee traffic of the FB56+ZSC05HG1.0 ?

highground88 commented 5 years ago

Will do - but it will have to be tomorrow unfortunately as I have to flash the sniffer firmware again etc and the wife is into me for still being up... I'll get to it as soon as I can tomorrow and edit this. Thanks again for your help...

highground88 commented 5 years ago

Hi @Koenkk - my apologies for not getting back to you sooner, life and an unexpected rebuild of my LAN got in the way....

But I think I have some good news. My latest sniffing attempt of the FB56+ZSC05HG1.0 turned up another device trust centre key.... I had assumed the previously discovered key was a single key that might be manufacturer specific across all devices, but maybe not? The new key looks to have a different format too (see link below). I've also got the second CC2531 I ordered now so I can use the sniffer at the same time.

The latest capture shows the attribute fields that coincide with the button presses of the FB56+ZSC05HG1.0 and also the FB56+ZSW1HKJ1.7, using Zigbee HA and ZDP protocols. These are located here in pcap format with the necessary codes, it might be easier perhaps for you: LINK

I'm running two instances of HA to try to debug this and currently experiencing a few issues with the Hassbian flavour, but I am about to test out your latest dev build on my Hassio build, as I see you've been busy with the code and everyone elses issues.... thanks mate.

highground88 commented 5 years ago

I'm still not entirely sure how this part works, but in analysing the pcap files I think I have determined what each devices 'supports' from the attributes response. As far as determining precisely what to put in the from/to zigbee, I'm really only guessing and using previous device entries. This is the current devices.js entry:

{
        zigbeeModel: ['FB56+ZSW1HKJ1.7'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'Basic, On/Off, Scenes, Groups',
        fromZigbee: [fz.generic_state],
        toZigbee: [tz.on_off],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const ep16 = shepherd.find(ieeeAddr, 16);
            execute(ep16, [(cb) => ep16.bind('genOnOff', coordinator, cb)], () => {
                const ep17 = shepherd.find(ieeeAddr, 17);
                execute(ep17, [(cb) => ep17.bind('genOnOff', coordinator, cb)], callback);
            });
        },
    },
    {
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TESTING-DIMMER SWITCH',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'On/Off, Level Control, Scenes, Groups, ZLL Commissioning, Power Source, Identify',
        fromZigbee: [],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 3, repChange: 0};
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
                (cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb),
            ];

            execute(device, actions, callback);
        },
    },

I did notice the coordinator issue which looked like the switch messages were sent by the co-ord ID has gone, a new one perhaps has arrived. I've highlighted the true device details below (..1fb), followed by some random ID (...6f2) which seems to be the same bug as before, but with a different ID?

Device was FB56+ZSW1HKJ1.7.

2019-01-20T08:34:02.329Z zigbee-shepherd-converters:devices Configured '(cb) => ep17.bind('genOnOff', coordinator, cb)' with result 'OK'
  zigbee2mqtt:info 2019-1-20 18:34:02 Succesfully configured 0x00124b0014afe1fb (****0x00124b0014afe1fb****)
2019-01-20T08:35:02.104Z zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object]
2019-01-20T08:35:02.121Z zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0
2019-01-20T08:35:02.123Z zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object]
  zigbee2mqtt:debug 2019-1-20 18:35:02 Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":0}}' of device 'undefined' (****0x00124b0018df46f2****)
  zigbee2mqtt:debug 2019-1-20 18:35:02 Ignoring message from coordinator
2019-01-20T08:35:43.330Z zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object]
2019-01-20T08:35:43.337Z zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0
2019-01-20T08:35:43.338Z zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object]
  zigbee2mqtt:debug 2019-1-20 18:35:43 Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":0}}' of device 'undefined' (0x00124b0018df46f2)
  zigbee2mqtt:debug 2019-1-20 18:35:43 Ignoring message from coordinator
2019-01-20T08:36:04.641Z zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object]
2019-01-20T08:36:04.651Z zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0
2019-01-20T08:36:04.655Z zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object]
  zigbee2mqtt:debug 2019-1-20 18:36:04 Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'undefined' (0x00124b0018df46f2)
  zigbee2mqtt:debug 2019-1-20 18:36:04 Ignoring message from coordinator
2019-01-20T08:36:08.807Z zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object]
2019-01-20T08:36:08.844Z zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0
2019-01-20T08:36:08.845Z zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object]
  zigbee2mqtt:debug 2019-1-20 18:36:08 Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'undefined' (0x00124b0018df46f2)
  zigbee2mqtt:debug 2019-1-20 18:36:08 Ignoring message from coordinator

This is the Wireshark capture of the same device (FB56+ZSW1HKJ1.7) "on" of a single switch which in the debug outputs as above:

Frame 8: 52 bytes on wire (416 bits), 52 bytes captured (416 bits) on interface 0
    Interface id: 0 (-)
        Interface name: -
    Encapsulation type: IEEE 802.15.4 Wireless PAN (104)
    Arrival Time: Jan  1, 1970 10:00:37.973621000 AEST
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 37.973621000 seconds
    [Time delta from previous captured frame: 6.054649000 seconds]
    [Time delta from previous displayed frame: 6.054649000 seconds]
    [Time since reference or first frame: 36.150941000 seconds]
    Frame Number: 8
    Frame Length: 52 bytes (416 bits)
    Capture Length: 52 bytes (416 bits)
    [Frame is marked: True]
    [Frame is ignored: False]
    [Protocols in frame: wpan:zbee_nwk:zbee_aps:zbee_zcl]
IEEE 802.15.4 Data, Dst: 0x0000, Src: 0x4aab
    Frame Control Field: 0x8861, Frame Type: Data, Acknowledge Request, PAN ID Compression, Destination Addressing Mode: Short/16-bit, Frame Version: IEEE Std 802.15.4-2003, Source Addressing Mode: Short/16-bit
        .... .... .... .001 = Frame Type: Data (0x1)
        .... .... .... 0... = Security Enabled: False
        .... .... ...0 .... = Frame Pending: False
        .... .... ..1. .... = Acknowledge Request: True
        .... .... .1.. .... = PAN ID Compression: True
        .... ...0 .... .... = Sequence Number Suppression: False
        .... ..0. .... .... = Information Elements Present: False
        .... 10.. .... .... = Destination Addressing Mode: Short/16-bit (0x2)
        ..00 .... .... .... = Frame Version: IEEE Std 802.15.4-2003 (0)
        10.. .... .... .... = Source Addressing Mode: Short/16-bit (0x2)
    Sequence Number: 225
    Destination PAN: 0x1a62
    Destination: 0x0000
    Source: 0x4aab
    [Extended Source: TexasIns_00:14:af:e1:fb (00:12:4b:00:14:af:e1:fb)]
    [Origin: 2]
    FCS: 0xa1ee (Correct)
ZigBee Network Layer Data, Dst: 0x0000, Src: 0x4aab
    Frame Control Field: 0x0248, Frame Type: Data, Discover Route: Enable, Security Data
        .... .... .... ..00 = Frame Type: Data (0x0)
        .... .... ..00 10.. = Protocol Version: 2
        .... .... 01.. .... = Discover Route: Enable (0x1)
        .... ...0 .... .... = Multicast: False
        .... ..1. .... .... = Security: True
        .... .0.. .... .... = Source Route: False
        .... 0... .... .... = Destination: False
        ...0 .... .... .... = Extended Source: False
        ..0. .... .... .... = End Device Initiator: False
    Destination: 0x0000
    Source: 0x4aab
    Radius: 15
    Sequence Number: 126
    [Extended Source: TexasIns_00:14:af:e1:fb (00:12:4b:00:14:af:e1:fb)]
    [Origin: 2]
    ZigBee Security Header
        Security Control Field: 0x28, Key Id: Network Key, Extended Nonce
            ...0 1... = Key Id: Network Key (0x1)
            ..1. .... = Extended Nonce: True
        Frame Counter: 119
        Extended Source: TexasIns_00:14:af:e1:fb (00:12:4b:00:14:af:e1:fb)
        Key Sequence Number: 0
        Message Integrity Code: 8f9500f2
        [Key: 01030507090b0d0f00020406080a0c0d]
        [Key Label: NUE Dimmer Code Discovered]
ZigBee Application Support Layer Data, Dst Endpt: 11, Src Endpt: 16
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 11
    Cluster: On/Off (0x0006)
    Profile: Home Automation (0x0104)
    Source Endpoint: 16
    Counter: 27
ZigBee Cluster Library Frame, Command: Report Attributes, Seq: 8
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 8
    Command: Report Attributes (0x0a)
    Attribute Field
        Attribute: OnOff (0x0000)
        Data Type: 8-Bit Unsigned Integer (0x20)
        On/off Control: On (0x01)
Koenkk commented 5 years ago

It seems we have the same issue again, it looks like the messages are send by the coordinator.

I'm wondering if you are able to control the device

Can you send to zigbee2mqtt/0x00124b0014afe1fb/set payload ON or OFF

highground88 commented 5 years ago

Yes!!!! That (and 'off') now control a switch from the 2 gang (FB56+ZSW1HKJ1.7) switch! Great work!

How does the handler need to be setup (code wise) to reach the various different end-points for the different gang switches? This is something I still don't follow due to my lack of programming skills... Once I work this out I will start to compile a list of the models I have and hopefully get them up and running!

What else do you need me to try to help with in regards to some of the other bugs still present?

highground88 commented 5 years ago

Further to the above, after looking through the Z2M logs, I noticed the other dimmer device wasn't paired, so I have paired it. I'm unsure if it was this or something happened on its own when I was trying to send "on1", "on2" etc, but I left it for a bit while I reviewed the earlier sniffing logs and now the on/off commands do not work, and this error appears:

zigbee2mqtt:info 2019-1-24 12:36:26 Zigbee publish to device '0x00124b0014afe1fb', genOnOff - on
 - {} - {"manufSpec":0,"disDefaultRsp":0} - null

Z2M LOG OUTPUT

Koenkk commented 5 years ago

With the following you should be able to control both:

{
        zigbeeModel: ['FB56+ZSW1HKJ1.7'],
        model: 'TODO',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'Basic, On/Off, Scenes, Groups',
        fromZigbee: [fz.generic_state],
        toZigbee: [tz.on_off],
        ep: (device) => {
            return {'left': 16, 'right': 17};
        },
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const ep16 = shepherd.find(ieeeAddr, 16);
            execute(ep16, [(cb) => ep16.bind('genOnOff', coordinator, cb)], () => {
                const ep17 = shepherd.find(ieeeAddr, 17);
                execute(ep17, [(cb) => ep17.bind('genOnOff', coordinator, cb)], callback);
            });
        },
    }

Using: zigbee2mqtt/0x00124b0014afe1fb/left/set and zigbee2mqtt/0x00124b0014afe1fb/right/set

highground88 commented 5 years ago

Thanks Koen, yes this does indeed work for both switches! I've added the pull request and included the specific model.

I do get this message in the log - unsure if this needs to be addressed?

  zigbee2mqtt:debug 2019-1-27 14:04:03 Received zigbee message of type 'devChange' with data '{"cid":"genOnOff","data":{"onOff":0}}' of device 'FB56+ZSW1HKJ1.7' (0x00124b0014afe1fb)
  zigbee2mqtt:warn 2019-1-27 14:04:03 No converter available for 'HGZB-042' with cid 'genOnOff', type 'devChange' and data '{"cid":"genOnOff","data":{"onOff":0}}'

Moving forward, how would I learn what the device is wanting in regards to these strings? i.e., I have a three gang switch to also port in, I'd imagine this would work similarly, but I don't recall ever seeing and "lefts" or "rights" mentioned in the sniffer logs of the 2 gang switch. Is this a Zigbee standard thing or is this just based on your device handler?

Thanks again, I'll keep pushing forward with the rest of these.

Koenkk commented 5 years ago

@highground88 the left right thing is just a mapping done by zigbee2mqtt to address the right endpoint. You can name it whatever you want as long as it is in the following array: https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/extension/devicePublish.js#L8

Koenkk commented 5 years ago

Can you try adding to https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/zapp/cie.js#L15 cieClusters.init('genOnOff', 'dir', {value: 1}); and check when you press the button on the switch; if it is still reported by the coordinator?

Koenkk commented 5 years ago

Let me know if you are still interested in supporting this device, Ive probably found a way to.

highground88 commented 5 years ago

@koenkk , yes definitely mate, thank you. The next time I'm home to try will probably be this weekend

Koenkk commented 5 years ago

@highground88 good, you should use the following firmware: https://drive.google.com/open?id=1QPs4aDKQE4wTmaHlh-GBtDYrtuKCDml8

I have good confidence that this will fix the problems.

highground88 commented 5 years ago

Thanks very much Koen - shall I try with a vanilla Hassio install or ?

Koenkk commented 5 years ago

I prefer vanilla, as it allows for faster development (easier to change files).

highground88 commented 5 years ago

OK great - I'll try to rebuild a Pi for testing. I also found this: Feibit Chart which is from THIS THREAD for those following along...

highground88 commented 5 years ago

I am indeed getting feedback now with the new fw and Hassio (v1.1.1), thank you very much! @Koenkk

EDIT: About 24 hrs and 15 edits later.....progress. Very sorry about the length of this post....

FB56+ZSW1HKJ1.7 (2 GANG LIGHT SWITCH) I originally wasn't getting feedback MQTT messages from the device button presses, but after using this device handler (which was just experimentation from comparing other devices), I now get them. I don't know that these are correct/optimised even though they appear to work, so I'd like to check with you before creating a pull request and moving onto some of the other models.

devices.js

    {
        zigbeeModel: ['FB56+ZSW1HKJ1.7'],
        model: 'HGZB-042',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'Basic, On/Off, Scenes, Groups',
        fromZigbee: [fz.nue_power_state],
        ep: (device) => {
            return {'left': 16, 'right': 17};
        },
        toZigbee: [tz.on_off],
        ep: (device) => {
            return {'left': 16, 'right': 17};
        },
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const ep16 = shepherd.find(ieeeAddr, 16);
            execute(ep16, [(cb) => ep16.bind('genOnOff', coordinator, cb)], () => {
                const ep17 = shepherd.find(ieeeAddr, 17);
                execute(ep17, [(cb) => ep17.bind('genOnOff', coordinator, cb)], callback);
            });
        },
    },

I have some confusion with the MQTT status message below re the first 'state:' not changing (relevant?), and whether 'fz.ignore_onoff_change' and/or if 'fz.generic_state' is needed or would cause issues? The first state topic doesn't seem to reflect on whether left, right, both or none are on or off.

e.g: Left ON/OFF {"state":"OFF","linkquality":70,"state_left":"ON","state_right":"OFF"} {"state":"OFF","linkquality":70,"state_left":"OFF","state_right":"OFF"}

Right ON/OFF {"state":"OFF","linkquality":70,"state_left":"OFF","state_right":"ON"} {"state":"OFF","linkquality":70,"state_left":"OFF","state_right":"OFF"}

Both ON {"state":"OFF","linkquality":70,"state_left":"ON","state_right":"ON"}

The below manually added HA entities both work in all directions (more experimenting/guessing).

configuration.yaml

light:
  - platform: "mqtt"
    name: "TEST LEFT"
    state_topic: "zigbee2mqtt/2Gang"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_off: "OFF"
    payload_on: "ON"
    value_template: "{{ value_json.state_left }}"
    command_topic: "zigbee2mqtt/2Gang/left/set"
    unique_id: 0x00124b001xxxxxxbL

  - platform: "mqtt"
    name: "TEST RIGHT"
    state_topic: "zigbee2mqtt/2Gang"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_off: "OFF"
    payload_on: "ON"
    value_template: "{{ value_json.state_right }}"
    command_topic: "zigbee2mqtt/2Gang/right/set"
    unique_id: 0x00124b001xxxxxxbR

FB56+ZSC05HG1.0 (1 GANG DIMMER) I have not yet had as much luck with the dimmer, but I can see that the changes in the firmware are providing a difference in the feedback, just not sure what.... This is what I have so far but the dimming and switch doesn't get recognised. I have tested and determined that the brightness range is 0 to 254, but the attribute commands sent appear to be just OnOff (only On) and then a second message stating attribute 'Current Level' and then the brightness figure (0 to 254), both endpoint 11, regardless whether it is the up or down button being used. The button also really needs to be held down, so there are pairs of these messages rapidly sent and probably out of order (see below).

{

        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TESTING-DIMMER SWITCH',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'On/Off, Level Control, Scenes, Groups, ZLL Commissioning, Power Source, Identify',
        fromZigbee: [fz.generic_state, fz.ignore_onoff_change],
        toZigbee: [tz.on_off],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 3, repChange: 0};
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
                (cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb),
            ];

            execute(device, actions, callback);
        },
    },

Z2M LOG output on switching:

2019-02-19T10:20:23.012Z zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object]
2019-02-19T10:20:23.273Z zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object]
2019-02-19T10:20:23.281Z zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0
ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 255
    Frame Control Field: Profile-wide (0x18)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...1 .... = Disable Default Response: True
    Sequence Number: 255
    Command: Read Attributes Response (0x01)
    Status Record
        Attribute: OnOff (0x0000)
        Status: Success (0x00)
        Data Type: 8-Bit Unsigned Integer (0x20)
        On/off Control: On (0x01)
ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 250
    Frame Control Field: Profile-wide (0x18)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...1 .... = Disable Default Response: True
    Sequence Number: 250
    Command: Read Attributes Response (0x01)
    Status Record
        Attribute: Current Level (0x0000)
        Status: Success (0x00)
        Data Type: 8-Bit Unsigned Integer (0x20)
        Current Level: 116
Koenkk commented 5 years ago

Let's do one device at a time and start with FB56+ZSW1HKJ1.7.

Can you try with:

devices.js

    {
        zigbeeModel: ['FB56+ZSW1HKJ1.7'],
        model: 'HGZB-042',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'on/off',
        fromZigbee: [fz.generic_state_multi_ep],
        toZigbee: [tz.on_off],
        ep: (device) => {
            return {'left': 16, 'right': 17};
        },
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const ep16 = shepherd.find(ieeeAddr, 16);
            execute(ep16, [(cb) => ep16.bind('genOnOff', coordinator, cb)], () => {
                const ep17 = shepherd.find(ieeeAddr, 17);
                execute(ep17, [(cb) => ep17.bind('genOnOff', coordinator, cb)], callback);
            });
        },
    },

fromZigbee.js

    generic_state_multi_ep: {
        cid: 'genOnOff',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
            const ep = msg.endpoints[0];
            const key = `state_${getKey(model.ep(ep.device), ep.epId)}`;
            const payload = {};
            payload[key] = msg.data.data['onOff'] === 1 ? 'ON' : 'OFF';
            return payload;
        },
    },
highground88 commented 5 years ago

Thanks @Koenkk . Is there a better way to modify the fromZigbee.js files than using a seperate install of Hassbian and the CLI via Putty on a Windows machine? I really hate+struggle with vi. I've tried using the Portainer addon and it's CLI, but obviously the changes aren't persistent.

The setup prior I did with Hassio 1.1.1, the almost instant modifications of the devices.js file is awesome.

highground88 commented 5 years ago

I'm getting the following error:


pi@hassbian:/opt/zigbee2mqtt $ npm start

> zigbee2mqtt@1.1.1 start /opt/zigbee2mqtt
> node index.js

  zigbee2mqtt:info 2/21/2019, 1:03:05 PM Logging to directory: 'data/log/2019-02-21.13-03-05'
  zigbee2mqtt:debug 2/21/2019, 1:03:05 PM Removing old log directory 'data/log/2019-02-21.12-19-44'
  zigbee2mqtt:debug 2/21/2019, 1:03:06 PM Using zigbee-shepherd with settings: '{"net":{"panId":6754,"channelList":[11],"precfgkey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13]},"dbPath":"/opt/zigbee2mqtt/data/database.db","sp":{"baudRate":115200,"rtscts":true}}'
  zigbee2mqtt:debug 2/21/2019, 1:03:06 PM Loaded state from file /opt/zigbee2mqtt/data/state.json
  zigbee2mqtt:info 2/21/2019, 1:03:06 PM Starting zigbee2mqtt version 1.1.1 (commit #92d88b6)
  zigbee2mqtt:info 2/21/2019, 1:03:06 PM Starting zigbee-shepherd
  zigbee2mqtt:info 2/21/2019, 1:03:07 PM zigbee-shepherd started
  zigbee2mqtt:info 2/21/2019, 1:03:07 PM Coordinator firmware version: '20190217'
  zigbee2mqtt:debug 2/21/2019, 1:03:07 PM zigbee-shepherd info: {"enabled":true,"net":{"state":"Coordinator","channel":11,"panId":"0x1a62","extPanId":"0xdddddddddddddddd","ieeeAddr":"0x00124b0014bdea20","nwkAddr":0},"firmware":{"transportrev":2,"product":0,"version":"2.6.3","revision":20190217},"startTime":1550754187,"joinTimeLeft":0}
  zigbee2mqtt:info 2/21/2019, 1:03:07 PM Currently 0 devices are joined:
  zigbee2mqtt:warn 2/21/2019, 1:03:07 PM `permit_join` set to  `true` in configuration.yaml.
  zigbee2mqtt:warn 2/21/2019, 1:03:07 PM Allowing new devices to join.
  zigbee2mqtt:warn 2/21/2019, 1:03:07 PM Set `permit_join` to `false` once you joined all devices.
  zigbee2mqtt:info 2/21/2019, 1:03:07 PM Zigbee: allowing new devices to join.
  zigbee2mqtt:info 2/21/2019, 1:03:07 PM Connecting to MQTT server at mqtt://192.168.0.101
  zigbee2mqtt:info 2/21/2019, 1:03:08 PM zigbee-shepherd ready
  zigbee2mqtt:info 2/21/2019, 1:03:08 PM Connected to MQTT server
  zigbee2mqtt:info 2/21/2019, 1:03:08 PM MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
  zigbee2mqtt:debug 2/21/2019, 1:03:08 PM Mounted the cieApp (epId 11)
  zigbee2mqtt:error 2/21/2019, 1:04:05 PM Cannot get the Node Descriptor of the Device: 0x00124b0014afe1fb (Error: Timed out after 10000 ms)
Koenkk commented 5 years ago

@highground88 can you try to repair the device? (I don't understand why you didn't get this error before, what has been changed?)

highground88 commented 5 years ago

The above log was whilst trying to re-pair.

Not really sure what broke - I upgraded to 0.88.0, and also the latest Z2M, then did the changes you suggested. I will try having a play around to see if anything fixes it.

highground88 commented 5 years ago

I've not been able to determine what happened, but I've started fresh with a new 0.88.1 build, and the new code does produce accurate MQTT feedback ({"state_left":"ON","linkquality":52,"state_right":"ON"}).

I can't fault anything function wise now, but I have the following message appearing in Z2M:

zigbee2mqtt:debug 2/22/2019, 12:44:15 PM Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'FB56+ZSW1HKJ1.7' (0x00124b0014afe1fb)

zigbee2mqtt:info 2/22/2019, 12:44:15 PM MQTT publish: topic 'zigbee2mqtt/0x00124b0014afe1fb', payload '{"state_left":"ON","linkquality":52,"state_right":"ON"}'

zigbee2mqtt:debug 2/22/2019, 12:44:15 PM Received zigbee message of type 'devChange' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'FB56+ZSW1HKJ1.7' (0x00124b0014afe1fb)

 zigbee2mqtt:warn 2/22/2019, 12:44:15 PM No converter available for 'HGZB-042' with cid 'genOnOff', type 'devChange' and data '{"cid":"genOnOff","data":{"onOff":1}}'

Is it normal that the model 'HGZB-042' would appear rather than zigbee model 'FB56+ZSW1HKJ1.7'?

Koenkk commented 5 years ago

Yes, that's the model you mapped it to:

Can you try with (should get rid of no converter available message)

devices.js

    {
        zigbeeModel: ['FB56+ZSW1HKJ1.7'],
        model: 'HGZB-042',
        vendor: 'Nue',
        description: 'Smart light switch - 2 gang',
        supports: 'on/off',
        fromZigbee: [fz.generic_state_multi_ep, fz.ignore_onoff_change],
        toZigbee: [tz.on_off],
        ep: (device) => {
            return {'left': 16, 'right': 17};
        },
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const ep16 = shepherd.find(ieeeAddr, 16);
            execute(ep16, [(cb) => ep16.bind('genOnOff', coordinator, cb)], () => {
                const ep17 = shepherd.find(ieeeAddr, 17);
                execute(ep17, [(cb) => ep17.bind('genOnOff', coordinator, cb)], callback);
            });
        },
    },

fromZigbee.js

    generic_state_multi_ep: {
        cid: 'genOnOff',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
            const ep = msg.endpoints[0];
            const key = `state_${getKey(model.ep(ep.device), ep.epId)}`;
            const payload = {};
            payload[key] = msg.data.data['onOff'] === 1 ? 'ON' : 'OFF';
            return payload;
        },
    },

If everything works, please make a PR.

highground88 commented 5 years ago

Great! Well done, the FB56+ZSW1HKJ1.7 is now working! I've created a PR (sorry I made 2, couldnt work out how to merge the 2 files into 1 PR).

Are you happy to help me get the tough looking one (FB56+ZSC05HG1.0 dimmer) supported or have I worn out my welcome? :-) Thanks @Koenkk πŸ₯‡

Koenkk commented 5 years ago

Let's continue with the FB56+ZSW1HKJ1.7 indeed, is this a 1 or 2 gang switch?

Can you try with, this should allow you to control on/off and brightness:

{
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TESTING-DIMMER SWITCH',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'on/off, brightness',
        fromZigbee: [tz.on_off, tz.light_brightness],
        toZigbee: [fz.state, fz.ignore_onoff_change],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 3, repChange: 0};
            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.bind('genLevelCtrl', coordinator, cb),
                (cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb),
            ];

            execute(device, actions, callback);
        },
    },
highground88 commented 5 years ago

Thanks again mate.

So this switch is a single output switch, the centre button being on/off, and then the top/bottom switches control the dimming (vertically orientated, top is increase).

The above code results in: zigbee2mqtt:error 2/24/2019, 1:13:58 AM Failed to configure 0x00124b001545a430 (0x00124b001545a430) ('TypeError: Cannot read property 'status' of undefined')

Debug output:

  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 8, srcaddr: 3112, srcendpoint: 11, dstendpoint: 1, wasbroadcast: 0, linkquality: 81, securityuse: 0, timestamp: 15444799, transseqnumber: 0, len: 5, data: <Buffer 18 01 0b 06 82> } +5ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object] +21ms
  zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0 +37ms
  serialport:unixRead waiting for readable because of code: EAGAIN +21ms
  serialport:poller Polling for "readable" +36ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object] +21ms
  zigbee-shepherd-converters:devices Configured '(cb) => device.report('genLevelCtrl', 'currentLevel', 0, 3, 0, cb)' with result 'TypeError: Cannot read property 'status' of undefined' +549ms
  zigbee2mqtt:error 2/24/2019, 1:18:33 AM Failed to configure 0x00124b001545a430 (0x00124b001545a430) ('TypeError: Cannot read property 'status' of undefined')

This is a previous sniffing session of this device (device is 0x9430) LINK

Let me know if you need anything else. Thank you.

Koenkk commented 5 years ago

Do you get any output when switching on/off? Can you switch the device on/off via zigbee2mqtt?

highground88 commented 5 years ago

No, no MQTT messages and no feedback when physically pressing the switch

Koenkk commented 5 years ago

Every wireshark line has a number (No.), can you provide the numbers of the commands when manually turning the switch on/off?

highground88 commented 5 years ago

I've just created two new files for you (previous link) that have only the ON/OFF, and an INCREASE (both momentarily pressed and held). Let me know if this is okay

Koenkk commented 5 years ago

The device isn't reporting anything, can you try with:

{
        zigbeeModel: ['FB56+ZSC05HG1.0'],
        model: 'TESTING-DIMMER SWITCH',
        vendor: 'Nue',
        description: 'ZigBee smart dimmer switch',
        supports: 'on/off, brightness',
        fromZigbee: [tz.on_off, tz.light_brightness],
        toZigbee: [fz.state, fz.ignore_onoff_change],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 11);
            const cfg = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 1000, repChange: 0};

            const actions = [
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.foundation('genOnOff', 'configReport', [cfg], foundationCfg, cb),
            ];

            execute(device, actions, callback);
        },
    },
highground88 commented 5 years ago

No errors with that code, but no feedback via MQTT or on Z2M (except in shepherd debug). I also deleted the database. However sending "zigbee2mqtt/0x00124b001545a430/set ON" ends up crashing Z2M.

  zigbee2mqtt:info 2/25/2019, 1:42:27 AM Device incoming...
  zigbee2mqtt:info 2/25/2019, 1:42:27 AM MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"pairing","message":"device incoming"}'
  zigbee2mqtt:debug 2/25/2019, 1:42:27 AM Configuring 0x00124b001545a430 (0x00124b001545a430) ...
  zigbee2mqtt:debug 2/25/2019, 1:42:27 AM Received zigbee message of type 'devStatus' with data '"online"' of device 'FB56+ZSC05HG1.0' (0x00124b001545a430)
  zigbee2mqtt:info 2/25/2019, 1:42:28 AM Succesfully configured 0x00124b001545a430 (0x00124b001545a430)
  zigbee2mqtt:debug 2/25/2019, 1:42:54 AM Received MQTT message on 'zigbee2mqtt/0x00124b001545a430/set' with data 'ON'
/opt/zigbee2mqtt/lib/extension/devicePublish.js:140
            const converter = converters.find((c) => c.key.includes(key));
                                                       ^

TypeError: Cannot read property 'key' of undefined
    at converters.find (/opt/zigbee2mqtt/lib/extension/devicePublish.js:140:56)
    at Array.find (<anonymous>)
    at keys.forEach (/opt/zigbee2mqtt/lib/extension/devicePublish.js:140:42)
    at Array.forEach (<anonymous>)
    at DevicePublish.onMQTTMessage (/opt/zigbee2mqtt/lib/extension/devicePublish.js:139:14)
    at results.extensions.filter.map (/opt/zigbee2mqtt/lib/controller.js:134:27)
    at Array.map (<anonymous>)
    at Controller.onMQTTMessage (/opt/zigbee2mqtt/lib/controller.js:134:14)
    at MQTT.onMessage (/opt/zigbee2mqtt/lib/mqtt.js:81:18)
    at MqttClient.emit (events.js:189:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@1.1.1 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zigbee2mqtt@1.1.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-02-25T01_42_55_088Z-debug.log

In that linked folder is the debug log 2019-02-25T01_50_26_446Z-debug.log

I've also done a full itemised capture, named DIMMER -JOIN,ON,OFF,UP,DOWN,CRASH.pcapng

PCAP capture:

  1. Z2M & Wireshark started.
  2. Pairing from [No. 7] to around [113].
  3. Physical switch currently off.
  4. [118] physical ON pressed.
  5. [122] physical OFF pressed.
  6. [~127] physical UP pressed once.
  7. [137] physical DOWN pressed once.
  8. [142] DOWN held briefly.
  9. [~153] MQTT ON message sent, Z2M crashes.
  10. End of capture.

The logs don't seem to be representative of what I'm seeing in the console with debug activated in configuration.yaml. This is the snippet from a ON press:

  zigbee2mqtt:info 2/25/2019, 2:24:49 AM MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"pairing","message":"device incoming"}'
  zigbee2mqtt:debug 2/25/2019, 2:24:49 AM Received zigbee message of type 'devStatus' with data '"online"' of device 'FB56+ZSC05HG1.0' (0x00124b001545a430)
  zigbee-shepherd Device: 0x00124b001545a430 already in network +31s
  serialport:poller received "readable" +1m
  serialport:bindings read +1m
  serialport:unixRead Starting read +1m
  serialport:unixRead Finished read 8 bytes +1ms
  serialport:main binding.read finished +1m
  cc-znp { sof: 254,
  cc-znp   len: 3,
  cc-znp   type: 'AREQ',
  cc-znp   subsys: 'ZDO',
  cc-znp   cmd: 'srcRtgInd',
  cc-znp   payload: { dstaddr: 18909, relaycount: 0, relaylist: <Buffer > },
  cc-znp   fcs: 22,
  cc-znp   csum: 22 } +1m
  serialport:main _read reading +12ms
  serialport:bindings read +15ms
  serialport:unixRead Starting read +14ms
  cc-znp:AREQ <-- ZDO:srcRtgInd, { dstaddr: 18909, relaycount: 0, relaylist: <Buffer > } +7ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:srcRtgInd +1m
  serialport:unixRead Finished read 33 bytes +4ms
  serialport:main binding.read finished +6ms
  cc-znp { sof: 254,
  cc-znp   len: 28,
  cc-znp   type: 'AREQ',
  cc-znp   subsys: 'AF',
  cc-znp   cmd: 'incomingMsg',
  cc-znp   payload:
  cc-znp    { groupid: 0,
  cc-znp      clusterid: 6,
  cc-znp      srcaddr: 18909,
  cc-znp      srcendpoint: 11,
  cc-znp      dstendpoint: 1,
  cc-znp      wasbroadcast: 0,
  cc-znp      linkquality: 84,
  cc-znp      securityuse: 0,
  cc-znp      timestamp: 15186867,
  cc-znp      transseqnumber: 0,
  cc-znp      len: 8,
  cc-znp      data: <Buffer 18 f0 01 00 00 00 20 01> },
  cc-znp   fcs: 160,
  cc-znp   csum: 160 } +13ms
  serialport:main _read reading +15ms
  serialport:bindings read +21ms
  serialport:unixRead Starting read +16ms
  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 6, srcaddr: 18909, srcendpoint: 11, dstendpoint: 1, wasbroadcast: 0, linkquality: 84, securityuse: 0, timestamp: 15186867, transseqnumber: 0, len: 8, data: <Buffer 18 f0 01 00 00 00 20 01> } +7ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object] +1m
  zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0 +29ms
  serialport:unixRead waiting for readable because of code: EAGAIN +14ms
  serialport:poller Polling for "readable" +51ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object] +12ms

Just a reminder (and I'm not sure if relevant?), this switch has a different encryption key than the other models.... it's listed in the folder.

I hate this switch. Thanks Koen.