Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

Typescript LMAO #4

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3d2e4cb
Update to org
qm3ster Jan 11, 2019
7a389e1
Rename writeStrcut to writeStruct
qm3ster Jan 11, 2019
6cdadec
0.5.0-0
qm3ster Jan 11, 2019
78436e0
Fix travis deploy
qm3ster Jan 11, 2019
e330d75
0.5.0-1
qm3ster Jan 11, 2019
f47098e
Package the right files
qm3ster Jan 11, 2019
8bb50d9
0.5.0-2
qm3ster Jan 11, 2019
b2290f1
Update dependencies
qm3ster Jan 12, 2019
e4825f7
Initial Typescript conversion
qm3ster Jan 13, 2019
29df98d
Update travis config
qm3ster Jan 13, 2019
c3c9716
Initial TypeScript conversion
qm3ster Jan 13, 2019
16a79f2
Furter refactoring
qm3ster Jan 13, 2019
2162636
0.5.0-4
qm3ster Jan 13, 2019
cc932a3
Further refactors
qm3ster Jan 14, 2019
1914d51
0.5.0-5
qm3ster Jan 14, 2019
74f61e2
Format common.json
qm3ster Jan 15, 2019
30e03e3
Add otaStatus enum
qm3ster Jan 16, 2019
be3a14b
Format enum.ts
qm3ster Jan 16, 2019
ee6f00e
Revert "Add support for TRADFRI remote clusters. https://github.com/K…
qm3ster Jan 16, 2019
7162eb2
Initial commit of Hacks.md
qm3ster Jan 16, 2019
a74fc40
Add `structElms` to Hack.md
qm3ster Jan 16, 2019
78c2e58
Typos
qm3ster Jan 16, 2019
0d126fe
Add constructor
qm3ster Jan 17, 2019
8ab4a09
0.5.0-6
qm3ster Jan 17, 2019
e25fd3a
Add converter to new format
qm3ster Jan 18, 2019
b6b98b2
Write converted jsons with no spaces
qm3ster Jan 21, 2019
f66b6b5
Commit converted jsons
qm3ster Jan 21, 2019
c2c99fa
Switch accessors to new jsons, naively
qm3ster Jan 21, 2019
4f18e22
Move back from scoped name
qm3ster Jan 21, 2019
39adff7
Update dependencies
qm3ster Jan 21, 2019
c5923d5
Update dependencies
qm3ster Jan 22, 2019
bc547a2
Export the 3 new jsons in index
qm3ster Jan 23, 2019
a8ad3d8
Add prettier npm scripts
qm3ster Jan 27, 2019
0c08dde
Switch to Jest
qm3ster Jan 28, 2019
ad73664
Move zclmeta.ts from zcl-packet
qm3ster Jan 29, 2019
a74a8a6
Don't depend on old zcl_meta.json
qm3ster Jan 30, 2019
d9fc437
Remove "use strict" from ts file
qm3ster Jan 30, 2019
cc92804
Don't delete converted clusterDefs
qm3ster Jan 30, 2019
42cf090
Remove unused import
qm3ster Jan 30, 2019
637d0c2
Move knownBufLen calculation to zcl-packet
qm3ster Jan 30, 2019
26e7638
Fix some names to match ZCL docs
qm3ster Feb 10, 2019
2f540c0
Correct some parameter types to be more specific
qm3ster Feb 11, 2019
c902552
Update `discoverRsp` params to new format
qm3ster Feb 13, 2019
90ed42d
Update foundation parameters
qm3ster Feb 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules
dist
coverage

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "semi": false }
21 changes: 17 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
language: node_js
node_js:
- "0.12.10"
- "4.1.0"
- "6.9.2"
- "8.9.4"
- "6"
- "10"
jobs:
include:
- stage: deploy
script: skip
node_js:
- "10"
deploy:
skip_cleanup: true
provider: npm
email: [email protected]
api_key:
secure: nLt7kfU0lpjt1Pr6bPIZnhubnwjWU6YzNUhP5shWp3YGNUjBm2srB0+GX0qVoAEgjAu9mbz/943CDu9idTB8RH3Lp2HgXZ62ZoZbl5yHVNU6sM0mYCETiTixof/vfhKW2hyUnt1Ylvz2J4OyP0Q8fK3fPXouDsQkCNgL4qGDZh+VtQutqlVtiD0SxDkera3x5HxZ99Kq0k/bkhdJVrxvi0eC3a+NWKsTt9uSAa/fQuFJE2FZMzm6KOh5j2/188Beihw/hk0W7x3CDvGgTzlQCQGXyyxQY6NbhxU1XXQjfRedKGiCf9L77PntSAcPPCP+9t+T+yGGMV8aLy3xvNbaicDU5ElQm/Eaz0y54B9dB2SAPCpPJAcaMRMH+0xyky3005OniiHvTcf4lrzfb98eXQLheoN8klWX+nZ7FtzBNDZborF1mlYDJbOhNnqtlPC5qmRcnBGFwx7/LZrZfeJRi/UcASsFbVkPridClEIIMx8orIVJRhS49B9ncVGwoY+acGX1BR3BcorbH/tzXBM9Wglv6XtgNK+NCt/AB+mllo8TdgIJbX2vEdwXHBRtC9XGbGkvbmeNr9e1svs7/6wVBk+W7+8TE73KgDcajxTwdzIcEt3g9toN1A5RKvRawtbCBBsliFLWsw0NxZB7eDLU3it41DVF6YNvp7JNnSKenPM=
on:
tags: true
repo: ZigBeans/zcl-id
114 changes: 114 additions & 0 deletions Hacks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Hacks

This document addresses the usecases that need to be supported which are currently implemented through hacks to the core modules that violate the separation of concerns and compliance with the Zigbee specifications.

If you know of any hacks that aren't listed here, please submit a PR to this document.

1. [@splitice] adding his proprietary `"zeaker": 2540` cluster for HalleyAssist https://github.com/Koenkk/zcl-id/pull/2

**Solution**: `extend` hook before `.json`s are processed.

1. [@kirovilya] adding Xiaomi struct parsing to attribute `65281`.
**Description**: Xiaomi devices send packed multi-value data as type `string` (aka Character string, 0x42, 62) which `zcl-packet` makes the mistake of parsing with the `string` parser of the `"dissolve"` module, which calls `.toString("utf8")` on the underlying `Buffer`. This would coincidentally be fine, since Zigbee specifies ISO 646 ASCII character encoding for this datatype. (Although the correct encoding would have been `"ascii"`)

**However**, actual devices in the wild, eg the Xiaomi mentioned, send bytes in the full range `0x00..0xFF`. Parsing these as as `"utf"` causes invalid characters, and parsing as `"ascii"` drops the high bit, in both cases losing data and necessitating intervention into `zcl-packet`.

**Solution**:

1. Revert commits:

- https://github.com/zigbeer/zcl-packet/commit/d5128f0fb2f1adf707e582a7b469af6dfed37426
- https://github.com/zigbeer/zcl-packet/commit/0c23e47b383428e48a84db586f24d19c3e94bb30#commitcomment-31959124

2. Parse the buffers as `"latin1"`(aka `"binary"`), which is a whole-byte encoding, a strict superset of `"ascii"`, and fully equivalent to [this code](https://github.com/open-zigbee/zigbee-bridge-packet/commit/dc2e8711a336020c18da0545144e666de7903718) by [@itsmepetrov]:

```js
function bufToAscii(buffer) {
const data = []
for (let i = 0; i < buffer.length; i++) {
data.push(String.fromCharCode(buffer[i]))
}

return data.join("")
}
```

3. Implement a Xiaomi buffer parser based on [@itsmepetrov's code here](https://github.com/itsmepetrov/homebridge-zigbee/blob/10cee93e40f875180c1d884feaea296457ea37c8/lib/utils/xiaomi.js#L4-L16) and [@kirovilya's code here](https://github.com/zigbeer/zcl-packet/blob/3dca38f46e97768d377496768f75158b84aed592/lib/foundation.js#L648-L675), probably as a separate package.

1. [@koenkk] adding group commands that are issued by a tradfri remote to the `"genScenes": 5` cluster.
Commands:

```json
"tradfriArrowSingle": 7,
"tradfriArrowHold": 8,
"tradfriArrowRelease": 9
```

Payloads:

```json
"tradfriArrowSingle":{
"params":[
{"value":"uint16"}
],
"dir":1},
"tradfriArrowHold":{
"params":[
{"value":"uint16"}
],
"dir":1},
"tradfriArrowRelease":{
"params":[
{"value":"uint16"}
],
"dir":1}
```

**Solution**:

1. Revert commits:

- https://github.com/zigbeer/zcl-packet/pull/10/commits/9fdecf5d684fb664b416bde982436c4a22187062
- https://github.com/Koenkk/zcl-id/commit/9a27ea86063627c5e36f529d7f9113702a18662b

2. Enable adding these commands with `extend` hook.
3. Ask IKEA what the meaning of these command IDs is, and why they are in this cluster.
4. Follow up with issue https://github.com/Koenkk/zigbee2mqtt/issues/102

1. [@kirovilya] copying [`this.vars.attrData = this.vars.structElms`](https://github.com/ZigBeans/zcl-packet/commit/a2b39c1b5239317bf8cd58ebf665319a5c039456) in the `attrValStruct` parser

This is allegedly necessitated by [`notifData.data[attrIdString] = rec.attrData` here](https://github.com/zigbeer/zigbee-shepherd/blob/b536bcdc4fe89b6433c58a8ba09672c88b0002c6/lib/shepherd.js#L131), wherein only the attrData is put on the event object. If this is the case, `attrVal` parser would also fail to report its `elmVals` field.

However, [parsing-framing tests](https://github.com/zigbeer/zcl-packet/blob/351c4204ab64a21668b01f8da68063a50835fe9c/test/zcl.test.js#L175-L177) suggest that these fields end up in an object under the `attrData` field, and so should be accessible on the event without this modification.

**Solution**:

1. Revert commit https://github.com/ZigBeans/zcl-packet/commit/a2b39c1b5239317bf8cd58ebf665319a5c039456#diff-9f0b814c660e5e38b20eed3e82ba2512R731
2. Try to access this value in the event handler.

1. [@splitice] added multiple zcl_meta entries for the same command, `imageBlockRsp`
```json
"imageBlockRspSuccess": {
"params": [
{ "status": "uint8" },
{ "manufacturerCode": "uint16" },
{ "imageType": "uint16" },
{ "fileVersion": "uint32" },
{ "fileOffset": "uint32" },
{ "dataLen": "preLenUint8" },
{ "data": "dynUint8" }
],
"dir": 1
},
"imageBlockRspAbort": {
"params": [{ "status": "uint8" }],
"dir": 1
},
```
**Solution**:
Make the structure of `params` suitable for variable data shapes.

[@splitice]: https://github.com/splitice
[@kirovilya]: https://github.com/kirovilya
[@itsmepetrov]: https://github.com/itsmepetrov
[@koenkk]: https://github.com/Koenkk
4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
# zcl-id
An utility for getting ZCL identifiers defined by ZigBee Cluster Library.

[![Travis branch](https://img.shields.io/travis/zigbeer/zcl-id/master.svg?maxAge=2592000)](https://travis-ci.org/zigbeer/zcl-id)
An utility for getting ZCL identifiers defined by ZigBee Cluster Library.

[![Build Status](https://travis-ci.com/zigbeer/zcl-id.svg?branch=master)](https://travis-ci.com/zigbeer/zcl-id)
[![npm](https://img.shields.io/npm/v/zcl-id.svg?maxAge=2592000)](https://www.npmjs.com/package/zcl-id)
[![npm](https://img.shields.io/npm/l/zcl-id.svg?maxAge=2592000)](https://www.npmjs.com/package/zcl-id)

<br />

## Documentation
## Documentation

Please visit the [Wiki](https://github.com/zigbeer/zcl-id/wiki).

<br />

## Overview
## Overview

**zcl-id** is a dictionary of identifiers defined by [_ZigBee Cluster Library Specification_](https://github.com/zigbeer/documents/blob/master/zcl-id/ZIGBEE_CLUSTER_LIBRARY_SPECIFICATION.pdf).
**zcl-id** is a dictionary of identifiers defined by [_ZigBee Cluster Library Specification_](https://github.com/zigbeer/documents/blob/master/zcl-id/ZIGBEE_CLUSTER_LIBRARY_SPECIFICATION.pdf).

<br />

## Installation
## Installation

> \$ npm install zcl-id --save

> $ npm install zcl-id --save

<br />

## Usage
## Usage

See [Usage](https://github.com/zigbeer/zcl-id/wiki#Usage) on the Wiki.
See [Usage](https://github.com/zigbeer/zcl-id/wiki#Usage) on the Wiki.

<br />

## License
## License

Licensed under [MIT](https://github.com/zigbeer/zcl-id/blob/master/LICENSE).
36 changes: 0 additions & 36 deletions definitions/clusterWithNewFormat.js

This file was deleted.

Loading