Zigbee2mqtt: - TypeError: net.precfgkey should be an array with 16 uint8 integers

I have used two different CC2531, re-flash multiple times and reinstall hassio with the same errors below. I also did try the edge version. Please help

./run.sh: line 13: [Info] Configuration backup found in /share/zigbee2mqtt/.configuration.yaml.bk. Skipping config backup.: No such file or directory
2019-07-20T18:56:56: PM2 log: Launching in no daemon mode
2019-07-20T18:56:56: PM2 log: App [npm:0] starting in -fork mode-
2019-07-20T18:56:57: PM2 log: App [npm:0] online
> [email protected] start /zigbee2mqtt-1.5.1
> node index.js
  zigbee2mqtt:info 7/20/2019, 6:57:01 PM Logging to directory: '/share/zigbee2mqtt/log/2019-07-20.18-57-00'
  zigbee2mqtt:info 7/20/2019, 6:57:01 PM Starting zigbee2mqtt version 1.5.1 (commit #unknown)
  zigbee2mqtt:info 7/20/2019, 6:57:01 PM Starting zigbee-shepherd
/zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/dist/lib/components/controller.js:429
                    throw new TypeError('net.precfgkey should be an array with 16 uint8 integers.');
                    ^
TypeError: net.precfgkey should be an array with 16 uint8 integers.
    at /zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/dist/lib/components/controller.js:429:27
    at Object._.forOwn (/zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/node_modules/busyman/index.js:242:27)
    at Object._.forEach (/zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/node_modules/busyman/index.js:415:18)
    at Controller.setNvParams (/zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/dist/lib/components/controller.js:414:7)
    at new ZShepherd (/zigbee2mqtt-1.5.1/node_modules/zigbee-herdsman/dist/lib/shepherd.js:28:21)
    at Zigbee.start (/zigbee2mqtt-1.5.1/lib/zigbee.js:57:25)
    at startupLogVersion (/zigbee2mqtt-1.5.1/lib/controller.js:167:25)
    at utils.getZigbee2mqttVersion (/zigbee2mqtt-1.5.1/lib/controller.js:193:13)
    at git.getLastCommit (/zigbee2mqtt-1.5.1/lib/util/utils.js:102:9)
    at /zigbee2mqtt-1.5.1/node_modules/git-last-commit/source/index.js:44:5
npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm
 ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2019-07-21T01_57_01_535Z-debug.log

Could you post your z2m config as well please. It a missing piece of the puzzle.

Thanks Kris, here it is

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "decices.yaml",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": true,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://10.0.0.65:1883",
    "user": "mqtt",
    "password": "mqtt"
  },
  "serial": {
    "port": "/dev/ttyACM0"
  },
  "advanced": {
    "pan_id": 6754,
    "channel": 11,
    "network_key": []
  }
}

Getting the same error message as of a few hours ago too.

1 Like

I have the same issue after moving to 1.5.1. My config is similar to @tedtvo

 "network_key": []

Needs to be filled in. like this example:
1-255 I believe are valid numbers. All sixteen places need to be filled.

[1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13]

Hope its of help.

Have a look at | Zigbee2MQTT

Change Zigbee network encryption key

Changing the network key requires repairing of all devices!

Zigbee2mqtt uses a known default encryption key (Zigbee Transport Key). Therefore it is recommended to use a different one. To use a different encryption key add the following to your configuration.yaml:

Do not use this exact key.

advanced:
  network_key: [7, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 11, 12, 13]

The network encryption key size is 128-bit which is essentially 16 decimal values between 0 and 255 or 16 hexadecimal values between 0x00and 0xFF.

If you need to transform your decimals to hexadecimals (or vice versa) please use a converter. Example: 92 (decimal) would become 5C (hexadecimal).

You can generate a valid key with the following command in most linux systems:

dd if=/dev/urandom bs=1 count=16 2>/dev/null | od -A n -t x1 | awk '{printf "["} {for(i = 1; i< NF; i++) {printf "0x%s, ", $i}} {printf "0x%s]\n", $NF}'

If you don’t change your network key, anyone can get into your MQTT network, it’s the same as if you have an unsecured open WiFI.

1 Like

Anyone know if rolling back to 1.5 is an option on Hass.io? I was automatically upgraded to 1.5.1, now nothing Zigbee works, and I don’t have time today to repair everything.

1 Like

@buntix it DOESN’T work. Just tried it. @danielwelch any ideas if there’s a temporary fix for those of us who don’t have time today (or tomorrow!) to repair all our Xiaomi devices? Thanks!

same here
broke all my sensor/light :frowning:
logs here : https://pastebin.com/d1P8cVq5
i reinstalled with stock configuration, and addon not start

trying to restore my last snapshot

Ok the solution if you don’t won’t repair all the devices is to use the default network key:
network_key: [1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13]
I confirm that using it the 1.5.1 starts working again ( no need to re pair all the devices…)
Ps credit goes to @dzungpv

5 Likes

THANK YOU - back up and running without having to re-pair. THANK YOU

it works!

I love you :heart:

Still not working after using the standard key :frowning:

> [email protected] start /zigbee2mqtt-1.5.1
> node index.js
  zigbee2mqtt:info 7/21/2019, 12:39:44 PM Logging to directory: '/share/zigbee2mqtt/log/2019-07-21.12-39-43'
  zigbee2mqtt:info 7/21/2019, 12:39:44 PM Starting zigbee2mqtt version 1.5.1 (commit #unknown)
  zigbee2mqtt:info 7/21/2019, 12:39:44 PM Starting zigbee-shepherd
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM zigbee-shepherd started
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM Coordinator firmware version: '20190223'
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM Currently 11 devices are joined:
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM unknown (0x000b57fffe499b87): L1527 - IKEA FLOALT LED light panel, dimmable, white spectrum (30x30 cm) (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM unknown (0x000b57fffe4fb28d): E1524 - IKEA TRADFRI remote control (EndDevice)
  zigbee2mqtt:info 7/21/2019, 12:39:46 PM unknown (0x00158d0002c4e48b): DJT11LM - Xiaomi Aqara vibration sensor (EndDevice)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x00158d0002b216ae): DJT11LM - Xiaomi Aqara vibration sensor (EndDevice)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffe9f7a5f): E1603/E1702 - IKEA TRADFRI control outlet (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffe9c01a2): E1603/E1702 - IKEA TRADFRI control outlet (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffed0a4cd): E1603/E1702 - IKEA TRADFRI control outlet (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffe9c51ba): E1603/E1702 - IKEA TRADFRI control outlet (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffeaeb4ca): E1603/E1702 - IKEA TRADFRI control outlet (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x000d6ffffed3cb9f): E1743 - IKEA TRADFRI ON/OFF switch (EndDevice)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM unknown (0x7cb03eaa0a06d68b): AB3257001NJ - OSRAM Smart+ plug (Router)
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM Zigbee: disabling joining new devices.
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM Connecting to MQTT server at mqtt://homeassistant
  zigbee2mqtt:info 7/21/2019, 12:39:47 PM zigbee-shepherd ready
events.js:174
      throw er; // Unhandled 'error' event
      ^
Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:1076:15)
    at MqttClient._handlePacket (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:365:12)
    at work (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:283:12)
    at Writable.writable._write (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:294:5)
    at doWrite (/zigbee2mqtt-1.5.1/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/zigbee2mqtt-1.5.1/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at Writable.write (/zigbee2mqtt-1.5.1/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at Socket.ondata (_stream_readable.js:693:20)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
Emitted 'error' event at:
    at MqttClient._handleConnack (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:1078:10)
    at MqttClient._handlePacket (/zigbee2mqtt-1.5.1/node_modules/mqtt/lib/client.js:365:12)
    [... lines matching original stack trace ...]
    at addChunk (_stream_readable.js:288:12)
npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm
 ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR!
 Failed at the [email protected] 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!     /root/.npm/_logs/2019-07-21T10_39_47_678Z-debug.log
2019-07-21T12:39:50: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
2019-07-21T12:39:50: PM2 log: App [npm:0] starting in -fork mode-
2019-07-21T12:39:50: PM2 log: App [npm:0] online

ATTENTION TO EVERYONE

Since the update, the config file will be doubled with parameters!
eg.

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "[]",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": true,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://hassio.local",
    "user": "sensored",
    "password": "sensored"
  },
  "serial": {
    "port": "/dev/ttyACM0"
  },
  "advanced": {
    "pan_id": 6754,
    "channel": 11,
    "network_key": [
    ]
  },
 "server": "mqtt://hassio.local",
    "user": "sensored",
    "password": "sensored"
}

Or similar. The bottom part which declares again server, user password etc MUST be deleted along with the previous “,” mark above it!
Also you will have to write server WITH port (eg. “server”: “mqtt://8.8.8.8:1883”) , your mqtt username and password.
Last, you have to declare a password. If you already knew that, you would do it since you don’t care about setting up your devices again. But since most of us don’t want that, simply edit the network key like this:
“network_key” : [1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13]
Save.
Assuming you already stopped the addon, start it. If you didn’t, now is a good time to stop it and start it.
If all goes well like mine did, you should be up and running like you never updated!

3 Likes

thanks a lot ! :star_struck:

Hey, did you add the mqtt port on the “server” side? Like

"server": "mqtt://8.8.8.8:1883"

Your error seems to be a rejection from mqtt server, so check your credentials, ip and port your mqtt is using

EDIT:
Just saw it. Your configuration is incorrect. For server side you have “mqtt://homeassistant” . This is not a valid broker. If your broker is internal to home assistant it should be “mqtt://ipofhass:1883” , eg. “mqtt://192.168.1.50:1883”
Probably other portions of your config are invalid if you missed that. Please post your config to check

Thanks a lot, I fixed that, strange that it worked before the recent update.

Thanks so much. It works.