Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.14k stars 1.68k forks source link

Ikea Trafri Button #102

Closed ciB89 closed 5 years ago

ciB89 commented 6 years ago

Ikea offers a controller that goes along with its TRADFRI series link

It's not supported on the wiki, but I was wondering if it would work with zigbee2mqtt?

ciotlosm commented 6 years ago

@ciB89 if you have the controller, you can just try it, but it's more likely that will work with some tweaking.

tb-killa commented 6 years ago

@ciB89 @ciotlosm I wait for my Tradfri Controller but i´m at the moment I am busy with my work. I know that @Koenkk has also bought a controller and do some tests in the past. Maybe he could also help.

Do you already own the controller?

Maybe we could do some hacky like we do with the "Hue dimmer switch" https://github.com/Koenkk/zigbee2mqtt/issues/36 ?

From what I know we could do the same bind for "genOnOff". Edit: bind for "genLevelCtrl" should also work.

ciB89 commented 6 years ago

I've got one now. It seems that the switch wants to be paired directly to the device that you want to use it with, e.g. lamp or an LED power supply. There's a pairing button on it that you are supposed to press >10 seconds until a red light turns on that indicates that the remote is paring with that device (it can be linked to ten devices). The bridge is needed for this, although it is never paired with the bridge directly (as far as I can tell from the instructions). I tried pairing it with the zigbee stick on my HA, but the red light won't turn on and debug doesn't show anything interesting either.

tb-killa commented 6 years ago

Please provide your content of the database.db with your "paired" ikea device. It would also be great if you start your instance via DEBUG=* npm start like mentioned via wiki.

About this LED i could say after doing some manual pairing with the Hue Dimmer Switch the device light is turning on action.

We could test the same code sample if you like ?

Koenkk commented 6 years ago

I already spend quite some time on this:

tb-killa commented 6 years ago

@Koenkk Do you test via manual mapping like we do with the Hue Dimmer Switch ? I found some "SmartThings" groovy Code like we show for the Hue Device, there are also the two mentioned mappings. Sadly i doesn´t have such type of device now so maybe you could check if it could work ?

Koenkk commented 6 years ago

Do you have a link to the SmartThings code?

tb-killa commented 6 years ago

https://github.com/RichMercer/SmartThings/blob/master/ikea-tradfri-remote.groovy search for the "configure()"

For other one ( the second binding) has to wait until tomorrow so i could send from my PC because i save the URL on file.

Koenkk commented 6 years ago

@tb-killa that looks interesting, it binds the genOnOff cluster on endpoint 1 till 4 to the coordinator. Haven't tried that before, will run some tests tomorrow.

kirovilya commented 6 years ago

I have this remote control. It is successfully connected to coordinator. But coordinator not receive it's messages. I found why! http://faire-ca-soi-meme.fr/domotique/2018/03/14/une-telecommande-zigbee-pour-les-controler-tous/ It's send message to "group". Coordinator not endDevice in group and do not recived it's message.

I do not known what to do... May be put coordinator to group? But how?

ciB89 commented 6 years ago

Got the remote paired with HA after I paired the driver with HA first (see #104). Receive no messages though. Here is the database.db for the remote:

{"id":5,"type":"EndDevice","ieeeAddr":"0x90fd9ffffed97ed6","nwkAddr":24438,"manufId":4476,"epList":[1],"status":"online","joinTime":1528475316,"endpoints":{"1":{"profId":49246,"epId":1,"devId":2096,"inClusterList":[0,1,3,9,2821,4096],"outClusterList":[3,4,5,6,8,25,4096],"clusters":{}}},"_id":"v7bdc5jXYmRkWPrr"}
{"id":5,"type":"EndDevice","ieeeAddr":"0x90fd9ffffed97ed6","nwkAddr":24438,"manufId":4476,"manufName":"IKEA of Sweden","powerSource":"Battery","modelId":"TRADFRI remote control","epList":[1],"status":"online","joinTime":1528475316,"endpoints":{"1":{"profId":49246,"epId":1,"devId":2096,"inClusterList":[0,1,3,9,2821,4096],"outClusterList":[3,4,5,6,8,25,4096],"clusters":{}}},"_id":"v7bdc5jXYmRkWPrr"}
{"id":5,"type":"EndDevice","ieeeAddr":"0x90fd9ffffed97ed6","nwkAddr":24438,"manufId":4476,"manufName":"IKEA of Sweden","powerSource":"Battery","modelId":"TRADFRI remote control","epList":[1],"status":"online","joinTime":1528475316,"endpoints":{"1":{"profId":49246,"epId":1,"devId":2096,"inClusterList":[0,1,3,9,2821,4096],"outClusterList":[3,4,5,6,8,25,4096],"clusters":{"genBasic":{"dir":{"value":1},"attrs":{}},"genPowerCfg":{"dir":{"value":1},"attrs":{"65533":1,"batteryVoltage":29,"batteryPercentageRemaining":74}},"genIdentify":{"dir":{"value":3},"attrs":{"65533":1,"identifyTime":0}},"genGroups":{"dir":{"value":2},"attrs":{}},"genScenes":{"dir":{"value":2},"attrs":{}},"genOnOff":{"dir":{"value":2},"attrs":{}},"genLevelCtrl":{"dir":{"value":2},"attrs":{}},"genAlarms":{"dir":{"value":1},"attrs":{"65533":1}},"genOta":{"dir":{"value":2},"attrs":{}},"haDiagnostic":{"dir":{"value":1},"attrs":{"65533":1}},"lightLink":{"dir":{"value":3},"attrs":{"65533":1}}}}},"_id":"v7bdc5jXYmRkWPrr"}
Koenkk commented 6 years ago

I don't know if the coordinator can be put in a group, that article shows how to use the TRADFRI remote to control a Xiaomi plug, but still it doesn't send events to the coordinator.

tb-killa commented 6 years ago

@ciB89 : please add this to your devices.js

{
        zigbeeModel: ['TRADFRI remote control'],
        model: 'TODO',
        vendor: 'IKEA',
        description: 'TODO',
        supports: 'TODO',
        fromZigbee: [],
        toZigbee: [],
    },

and this to lib/zigbee.js into the handleReady function

        // TEMP: Bind Ikea Remote Control to coordinator.
        let ikearemote = '0x90fd9ffffed97ed6';
        ikearemote = this.shepherd.find(ikearemote, 1);
        let coordinator = this.shepherd.list().find((d) => d.type === 'Coordinator');
        coordinator = this.shepherd.find(coordinator.ieeeAddr, 1);
        ikearemote.bind('genOnOff', coordinator, (err) => {
            if (err) {
                console.log('FAILED TO BIND genOnOff :(');
            } else {
                console.log('GOOD TO BIND genOnOff !');
            }
        });
        //
        ikearemote.bind('genLevelCtrl', coordinator, (err) => {
            if (err) {
                console.log('FAILED TO BIND genLevelCtrl :(');
            } else {
                console.log('GOOD TO BIND genLevelCtrl !');
            }
        });

After that please start you zigbee2mqtt instance via DEBUG=* npm start and let the Remote Control in pairing mode while the instance start up. Please provide log after you wait some time and push some of the buttons of the remote control.

ciB89 commented 6 years ago

Restarting the docker in Hassio resets the custom changes to the files... I'll setup a second SD-card with Hassbian and I'll test again.

ciB89 commented 6 years ago

Got the following error while running. Just to make clear: The remote is currently NOT paired with the shephard.

2018-6-11 15:37:37 INFO zigbee-shepherd started
2018-6-11 15:37:37 INFO Currently 0 devices are joined:
2018-6-11 15:37:37 INFO Connecting to MQTT server at mqtt://192.168.0.41
2018-6-11 15:37:38 INFO zigbee-shepherd ready
/opt/zigbee2mqtt/lib/zigbee.js:92
        ikearemote.bind('genOnOff', coordinator, (err) => {
                   ^

TypeError: Cannot read property 'bind' of undefined
    at Zigbee.handleReady (/opt/zigbee2mqtt/lib/zigbee.js:92:20)
    at emitNone (events.js:106:13)
    at ZShepherd.emit (events.js:208:7)
    at Immediate._onImmediate (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/lib/shepherd.js:89:18)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@0.1.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zigbee2mqtt@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
tb-killa commented 6 years ago

@ciB89 This failure seems to be come forward if we use this type of debugging Code without first has got the Enddevice in the database (pairing). So lets do some practise first: Comment out the Code Section for binding (zigbee.js). Restart zigbee2mqtt and pair the device like a normal device so we get the needing information at startup inside the zigbee database. After that stop zigbee2mqtt and bring the code section in work, and restart them into debug=*

If we use the new code from @Koenkk we could do the binding from the converter themselve but we would test it first :)

ciB89 commented 6 years ago

The binding did work ("GOOD TO BIND genOnOff !"), but the debug does not show me anything when pressing buttons..

This only shows up periodically:

  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +55s
  cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 5512, nwkaddrofinterest: 5512 } +55s
  serialport write 9 bytes of data +55s
  cc-znp:SRSP <-- ZDO:nodeDescReq, { status: 0 } +23ms
  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +5s
  cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 5512, nwkaddrofinterest: 5512 } +5s
  serialport write 9 bytes of data +5s
  cc-znp:SRSP <-- ZDO:nodeDescReq, { status: 0 } +19ms
ciB89 commented 6 years ago

After restarting the shephard it fails the binding although I reproduce every step I had taken sofar..

tb-killa commented 6 years ago

Bring the Device in pairing mode again, maybe it need this twice because of standby or another situation. It could need some sort of multiple restarts of zigbee2mqtt instance or maybe multiple usage of on / off button pressing to bring the needing informations on top.

fails could be the situations mentioned on top because i get this on the "Hue dimmer switch" too.

tb-killa commented 6 years ago

We should also add some debugging console.log to check the raw data:

try put console.log after zigbee-shepherd\lib\components\af.js:693 and after zigbee-shepherd\lib\components\af.js:572

sample like this:

// Original
var coord = af.controller.getCoord();
// Added
console.log(type, msg)

and

//Original
zcl.parse(msg.data, function (err, zclData) {
                if (!err)
                    zclIncomingParsedMsgEmitter(msg, zclData);
                    // Added
                    console.log(type, msg)
            });

Now we could check deeper with DEBUG=* npm start

ciB89 commented 6 years ago

So, I took out the batteries and reinserted them and that worked really well - it seems that just pressing the pairing button only works for the IKEA stuff, not so much for the shephard (the red light indicator for pairing only turns on if e.g. the driver is plugged in).

Button presses on the remote still have no effect. I spotted this though: 2018-06-11T17:51:14.477Z - error: Cannot get the Node Descriptor of the Device: 0x90fd9ffffed97ed6 (Error: Timed out after 10000 ms) I will add the additional debugging stuff next.

ciB89 commented 6 years ago

This is the full log. BTW, my log.txt doesn't actually show the entire log. How can I change that? Pressing any button on the remote has still no effect/debug output.

ciotlosm commented 6 years ago

Use hastebin next time to reduce message length. This is bloating the topic too much

james-fry commented 6 years ago

IIRC this device and the tradfri dimmer are working with zigate and deconz. I think the coordinator creates a dummy group (with zero members) and then the controller joins that group. I saw some info about it on the HA community forum. Will see if I can find it again...

james-fry commented 6 years ago

See here: https://community.home-assistant.io/t/use-ikea-tradfri-dimmer-in-home-assistant/33211/35

ciB89 commented 6 years ago

Is there any progress on this yet?

Koenkk commented 6 years ago

Not from my side, I don't know how to create a fake group using zigbee-shepherd.

tb-killa commented 6 years ago

@Koenkk @kirovilya : I use the latest Version from git INFO Starting zigbee2mqtt version 0.0.0 (commit #4c4fcd7)

If i bring my remote control in pairing i got this:

zigbee-shepherd:msgHdlr IND <-- ZDO:tcDeviceInd +9s
spinlock: false []
  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +75ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd +7ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:nodeDescRsp +984ms
  zigbee-shepherd:request REQ --> ZDO:activeEpReq +5ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:activeEpRsp +1s
  zigbee-shepherd:request REQ --> ZDO:simpleDescReq +3ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:simpleDescRsp +1s
  zigbee-shepherd:request REQ --> AF:dataRequest, transId: 1 +85ms
  zigbee-shepherd:request RSP <-- AF:dataRequest, status: 0 +20ms
  zigbee-shepherd:msgHdlr IND <-- AF:dataConfirm, transId: 1 +949ms
/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:683
        ru[dataType](name)(this);
                    ^

TypeError: ru[dataType] is not a function
    at Dissolve.<anonymous> (/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:683:21)
    at Dissolve._transform (/opt/zigbee2mqtt/node_modules/dissolve/index.js:80:16)
    at Dissolve.Transform._read (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Dissolve.Transform._write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at Dissolve.Writable.write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at Dissolve.Writable.end (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
    at FoundPayload._getObj (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:242:12)
    at getObjCB (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:51:22)
Koenkk commented 6 years ago

What if you do:

rm -rf node_modules
npm install
kirovilya commented 6 years ago

@tb-killa I do not seen this error before.

if it repeated, try put console.log in point of error, to see what dataType and name?

tb-killa commented 6 years ago

@Koenkk Its a complete fresh installation, do this alright before posting. @kirovilya this looks interesting: After restart in Debug:

6/19/2018, 10:23:10 PM INFO Currently 1 devices are joined:
6/19/2018, 10:23:10 PM INFO unknown (0x90fd9ffffed17c15): unkown - undefined unknown (EndDevice)

It seems to be that zigbee2mqtt doesnt collect the right data from the remote.

kirovilya commented 6 years ago

@tb-killa It is normal for me :) Just put block in devices.js of zigbee-shepherd-converters:

    {
        zigbeeModel: ['TRADFRI remote control'],
        model: 'E1524',
        vendor: 'IKEA',
        description: 'TRADFRI remote control',
        supports: '',
        fromZigbee: [],
        toZigbee: [],
    },
kirovilya commented 6 years ago

@tb-killa or try remove and rejoin remote

tb-killa commented 6 years ago

@kirovilya converter entry was present. I remove and add the device multiple times.

I insert some log output inside the foundation.js file

ru.clause('variable', function (name, dataTypeParam) {
    if (!dataTypeParam) dataTypeParam = 'dataType';

    this.tap(function () {
        var dataType = getDataType(this.vars[dataTypeParam]);
        console.log(dataType)
        console.log(name)
        ru[dataType](name)(this);
    });
});

and got this log

zigbee-shepherd:msgHdlr IND <-- ZDO:tcDeviceInd +3s
spinlock: false []
  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +88ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd +5ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:nodeDescRsp +997ms
  zigbee-shepherd:request REQ --> ZDO:activeEpReq +2ms
  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +103ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:activeEpRsp +917ms
  zigbee-shepherd:request REQ --> ZDO:simpleDescReq +3ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:simpleDescRsp +1s
  zigbee-shepherd:request REQ --> AF:dataRequest, transId: 1 +37ms
  zigbee-shepherd:request RSP <-- AF:dataRequest, status: 0 +17ms
  zigbee-shepherd:msgHdlr IND <-- AF:dataConfirm, transId: 1 +977ms
strPreLenUint8
attrData
undefined
attrData
/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:685
        ru[dataType](name)(this);
                    ^

TypeError: ru[dataType] is not a function
    at Dissolve.<anonymous> (/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:685:21)
    at Dissolve._transform (/opt/zigbee2mqtt/node_modules/dissolve/index.js:80:16)
    at Dissolve.Transform._read (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Dissolve.Transform._write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at Dissolve.Writable.write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at Dissolve.Writable.end (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
    at FoundPayload._getObj (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:242:12)
    at getObjCB (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:51:22)
kirovilya commented 6 years ago

@tb-killa need log dataTypeParam too. unknown datatype - strange...

tb-killa commented 6 years ago

I extend the needing output

6/20/2018, 6:58:20 PM INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'
  cc-znp:AREQ <-- ZDO:activeEpRsp, { srcaddr: 52708, status: 0, nwkaddr: 52708, activeepcount: 1, activeeplist: <Buffer 01> } +72ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:activeEpRsp +5ms
  zigbee-shepherd:request REQ --> ZDO:simpleDescReq +6ms
  cc-znp:SRSP <-- ZDO:mgmtPermitJoinReq, { status: 0 } +18ms
  cc-znp:AREQ <-- ZDO:permitJoinInd, { duration: 255 } +1ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:permitJoinInd +1ms
  cc-znp:AREQ <-- ZDO:mgmtPermitJoinRsp, { srcaddr: 0, status: 0 } +1ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:mgmtPermitJoinRsp +1ms
  cc-znp:SREQ --> ZDO:simpleDescReq, { dstaddr: 52708, nwkaddrofinterest: 52708, endpoint: 1 } +1ms
  serialport write 10 bytes of data +3ms
  cc-znp:SRSP <-- ZDO:simpleDescReq, { status: 0 } +15ms
  cc-znp:AREQ <-- ZDO:simpleDescRsp, { srcaddr: 52708, status: 0, nwkaddr: 52708, len: 34, endpoint: 1, profileid: 49246, deviceid: 2096, deviceversion: 2, numinclusters: 6, inclusterlist: <Buffer 00 00 01 00 03 00 09 00 05 0b 00 10>, numoutclusters: 7, outclusterlist: <Buffer 03 00 04 00 05 00 06 00 08 00 19 00 00 10> } +911ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:simpleDescRsp +2ms
  zigbee-shepherd:request REQ --> AF:dataRequest, transId: 1 +36ms
  cc-znp:SREQ --> AF:dataRequest, { dstaddr: 52708, destendpoint: 1, srcendpoint: 1, clusterid: 0, transid: 1, options: 48, radius: 30, len: 9, data: <Buffer 00 01 00 04 00 05 00 07 00> } +3ms
  serialport write 24 bytes of data +4ms
  cc-znp:SRSP <-- AF:dataRequest, { status: 0 } +13ms
  zigbee-shepherd:request RSP <-- AF:dataRequest, status: 0 +2ms
  cc-znp:AREQ <-- AF:dataConfirm, { status: 0, endpoint: 1, transid: 1 } +972ms
  zigbee-shepherd:msgHdlr IND <-- AF:dataConfirm, transId: 1 +9ms
  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 0, srcaddr: 52708, srcendpoint: 1, dstendpoint: 1, wasbroadcast: 0, linkquality: 0, securityuse: 0, timestamp: 6222012, transseqnumber: 0, len: 54, data: <Buffer 18 01 01 04 00 00 42 0e 49 4b 45 41 20 6f 66 20 53 77 65 64 65 6e 05 00 00 42 16 54 52 41 44 46 5249 20 72 65 6d 6f 74 65 20 63 6f 6e 74 72 6f 6c 07 ... > } +11ms
undefined
strPreLenUint8
attrData
undefined
undefined
attrData
/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:686
        ru[dataType](name)(this);
                    ^

TypeError: ru[dataType] is not a function
    at Dissolve.<anonymous> (/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:686:21)
    at Dissolve._transform (/opt/zigbee2mqtt/node_modules/dissolve/index.js:80:16)
    at Dissolve.Transform._read (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Dissolve.Transform._write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at Dissolve.Writable.write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at Dissolve.Writable.end (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
    at FoundPayload._getObj (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:242:12)
    at getObjCB (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:51:22)
tb-killa commented 6 years ago

@kirovilya I started with fresh flashed stick and new zigbee2mqtt instance:

Sadly i got the error again:


  cc-znp:AREQ <-- ZDO:endDeviceAnnceInd, { srcaddr: 20585, nwkaddr: 20585, ieeeaddr: '0x90fd9ffffed17c15', capabilities: 128 } +2m
spinlock: false []
  zigbee-shepherd:request REQ --> ZDO:nodeDescReq +6ms
  cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 20585, nwkaddrofinterest: 20585 } +3ms
  serialport write 9 bytes of data +4ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd +3ms
  cc-znp:SRSP <-- ZDO:nodeDescReq, { status: 0 } +51ms
  cc-znp:AREQ <-- ZDO:nodeDescRsp, { srcaddr: 20585, status: 0, nwkaddr: 20585, logicaltype_cmplxdescavai_userdescavai: 2, apsflags_freqband: 64, maccapflags: 128, manufacturercode: 4476, maxbuffersize: 82, maxintransfersize: 82, servermask: 0, maxouttransfersize: 82, descriptorcap: 0 } +2s
  zigbee-shepherd:msgHdlr IND <-- ZDO:nodeDescRsp +8ms
  zigbee-shepherd:request REQ --> ZDO:activeEpReq +12ms
  cc-znp:SREQ --> ZDO:activeEpReq, { dstaddr: 20585, nwkaddrofinterest: 20585 } +5ms
  serialport write 9 bytes of data +3ms
  cc-znp:SRSP <-- ZDO:activeEpReq, { status: 0 } +22ms
  cc-znp:AREQ <-- ZDO:activeEpRsp, { srcaddr: 20585, status: 0, nwkaddr: 20585, activeepcount: 1, activeeplist: <Buffer 01> } +990ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:activeEpRsp +2ms
  zigbee-shepherd:request REQ --> ZDO:simpleDescReq +9ms
  cc-znp:SREQ --> ZDO:simpleDescReq, { dstaddr: 20585, nwkaddrofinterest: 20585, endpoint: 1 } +2ms
  serialport write 10 bytes of data +2ms
  cc-znp:SRSP <-- ZDO:simpleDescReq, { status: 0 } +12ms
  cc-znp:AREQ <-- ZDO:simpleDescRsp, { srcaddr: 20585, status: 0, nwkaddr: 20585, len: 34, endpoint: 1, profileid: 49246, deviceid: 2096, deviceversion: 2, numinclusters: 6, inclusterlist: <Buffer 00 00 01 00 03 00 09 00 05 0b 00 10>, numoutclusters: 7, outclusterlist: <Buffer 03 00 04 00 05 00 06 00 08 00 19 00 00 10> } +998ms
  zigbee-shepherd:msgHdlr IND <-- ZDO:simpleDescRsp +10ms
  zigbee-shepherd:request REQ --> AF:dataRequest, transId: 1 +33ms
  cc-znp:SREQ --> AF:dataRequest, { dstaddr: 20585, destendpoint: 1, srcendpoint: 1, clusterid: 0, transid: 1, options: 48, radius: 30, len: 9, data: <Buffer 00 01 00 04 00 05 00 07 00> } +3ms
  serialport write 24 bytes of data +3ms
  cc-znp:SRSP <-- AF:dataRequest, { status: 0 } +12ms
  zigbee-shepherd:request RSP <-- AF:dataRequest, status: 0 +1ms
  cc-znp:AREQ <-- AF:dataConfirm, { status: 0, endpoint: 1, transid: 1 } +972ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: dataConfirm, msg: [object Object] +3ms
  zigbee-shepherd:msgHdlr IND <-- AF:dataConfirm, transId: 1 +4ms
  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 0, srcaddr: 20585, srcendpoint: 1, dstendpoint: 1, wasbroadcast: 0, linkquality: 18, securityuse: 0,timestamp: 16490997, transseqnumber: 0, len: 54, data: <Buffer 18 01 01 04 00 00 42 0e 49 4b 45 41 20 6f 66 20 53 77 65 64 65 6e 05 00 00 42 16 54 52 41 44 46 52 49 20 72 65 6d 6f 74 65 20 63 6f 6e 74 72 6f 6c 07 ... > } +9ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object] +3ms
/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:683
        ru[dataType](name)(this);
                    ^

TypeError: ru[dataType] is not a function
    at Dissolve.<anonymous> (/opt/zigbee2mqtt/node_modules/zcl-packet/lib/foundation.js:683:21)
    at Dissolve._transform (/opt/zigbee2mqtt/node_modules/dissolve/index.js:80:16)
    at Dissolve.Transform._read (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Dissolve.Transform._write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at Dissolve.Writable.write (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at Dissolve.Writable.end (/opt/zigbee2mqtt/node_modules/dissolve/node_modules/readable-stream/lib/_stream_writable.js:426:10)
    at FoundPayload._getObj (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:242:12)
    at getObjCB (/opt/zigbee2mqtt/node_modules/zigbee-shepherd/node_modules/zcl-packet/lib/foundation.js:51:22)

I often reset the remote device via 4 pushes of the button on the back and get the device leaving message complete. But after the device seems to paire again, it crashed ...

kirovilya commented 6 years ago

@tb-killa It is the same error like https://github.com/Koenkk/zigbee2mqtt/issues/129 ... Something in your zigbee-network want to connect but can't :)

tb-killa commented 6 years ago

@kirovilya Yes it seems to be some of this error. I will flash the original Firmware from TI Source themselve back to my stick because i think there is some sort of break in our diy firmware. Or maybe also use some sort of older snapshot of zigbee2mqtt from github to check if we didn´t break something in the last time.

I only know that with an older release the remote device work one time. after that i updated and after that its broke and i got on different devices in pairing mode this crazy "crash".

kirovilya commented 6 years ago

@tb-killa Yes, try to rollback to the original firmware and zigbee2mqtt. Then check the operation of the devices.

tb-killa commented 6 years ago

I got it now:

spinlock: false []
spinlock: true []
2018-7-4 21:54:44 INFO Connecting with device...
2018-7-4 21:54:44 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:54:49 INFO Connecting with device...
2018-7-4 21:54:49 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:54:59 INFO Connecting with device...
2018-7-4 21:54:59 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:06 INFO Connecting with device...
2018-7-4 21:55:06 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:13 INFO Connecting with device...
2018-7-4 21:55:13 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:20 INFO Connecting with device...
2018-7-4 21:55:20 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:27 INFO Connecting with device...
2018-7-4 21:55:27 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:34 INFO Connecting with device...
2018-7-4 21:55:34 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:41 INFO Connecting with device...
2018-7-4 21:55:41 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:48 INFO Connecting with device...
2018-7-4 21:55:48 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:55 INFO Connecting with device...
2018-7-4 21:55:55 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-7-4 21:55:55 INFO Device incoming...
2018-7-4 21:55:55 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'
2018-7-4 21:55:55 INFO New device with address 0x90fd9ffffed17c15 connected!
2018-7-4 21:55:55 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/log', payload: '{"type":"device_connected","message":"0x90fd9ffffed17c15"}'
2018-7-4 21:55:55 WARN Device with modelID 'TRADFRI remote control' is not supported.
2018-7-4 21:55:55 WARN Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices
2018-7-4 21:55:55 WARN Device with modelID 'TRADFRI remote control' is not supported.
2018-7-4 21:55:55 WARN Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices

this is my database.db entry:

{"id":4,"type":"EndDevice","ieeeAddr":"0x90fd9ffffed17c15","nwkAddr":30452,"manufId":4476,"manufName":"IKEA of Sweden","powerSource":"Battery","modelId":"TRADFRI remote control","epList":[1],"status":"online","joinTime":1530734067,"endpoints":{"1":{"profId":49246,"epId":1,"devId":2096,"inClusterList":[0,1,3,9,2821,4096],"outClusterList":[3,4,5,6,8,25,4096],"clusters":{"genBasic":{"dir":{"value":1},"attrs":{"10":{},"65533":1,"zclVersion":1,"appVersion":17,"stackVersion":87,"hwVersion":1,"manufacturerName":"IKEA of Sweden","modelId":"TRADFRI remote control","dateCode":"20170302","powerSource":3,"swBuildId":"1.2.214"}},"genPowerCfg":{"dir":{"value":1},"attrs":{"65533":1,"batteryVoltage":23,"batteryPercentageRemaining":5}},"genIdentify":{"dir":{"value":3},"attrs":{}},"genGroups":{"dir":{"value":2},"attrs":{}},"genScenes":{"dir":{"value":2},"attrs":{}},"genOnOff":{"dir":{"value":2},"attrs":{}},"genLevelCtrl":{"dir":{"value":2},"attrs":{}},"genAlarms":{"dir":{"value":1},"attrs":{}},"genOta":{"dir":{"value":2},"attrs":{}},"haDiagnostic":{"dir":{"value":1},"attrs":{}},"lightLink":{"dir":{"value":3},"attrs":{}}}}},"_id":"iZKH6uOfcdRWxh97"}
kirovilya commented 6 years ago

I get this error too:

/node_modules/zcl-packet/lib/foundation.js:683
        ru[dataType](name)(this);
                    ^

TypeError: ru[dataType] is not a function

Will fix like here https://github.com/Koenkk/zigbee2mqtt/issues/150#issuecomment-402549850 after success

tb-killa commented 6 years ago

@kirovilya Maybe you could check my log (DEBUG=*) for Data. Maybe we see some infos about how we gould bind the device ?? https://pastebin.com/E7x33r4t

kirovilya commented 6 years ago

@tb-killa it is only "pairing" log. Here no new info for me. How I undestanging, Remote Control operate with group of EndDevice and send them messages. But in our coordinator we can not see this messages cause we not EndDevice and not in group with Remote Control. If we create in coordinator any endpoint like EndDevice and bind it to group of Remote - we see messages. But I do not known how to do it...

tb-killa commented 6 years ago

@Koenkk @kirovilya Does somebody test the extension frameworks ? https://github.com/zigbeer/zive/wiki https://github.com/zigbeer/ziee/wiki https://github.com/zigbeer/zapp-cie/wiki

Maybe we could build simple zive or ziee application who build sample endpoint with needing acl and attributes and simple bind our endpoint 1 to this ?

I´v read the zapp-cie sample app, it provide iaszone samples too, maybe with this we could also simple integrate our motion / windows - sensors ??

kirovilya commented 6 years ago

no, I did not try.

Koenkk commented 6 years ago

I also didn't, but it calls the same code as we did.

tb-killa commented 6 years ago

I thought that we could use Zive or Ziee for building endpoint fake Group so Devices like ikea remote or motion sensor could be Bind to it? But if its also same as we used actually.. We have to Show..

worf0r commented 6 years ago

I closed the other Issue. I have some of this Buttons and sadly can't use them with this soultion. How did you pair the button? 10 Seconds button pressing and then?

Koenkk commented 6 years ago

@worf0r press the reset button quickly 4 times (red light flashes) while keeping it close to the coordinator.