Skip to content

Commit 9b758b7

Browse files
authored
Merge pull request #52 from AlCalzone/fix-51
Don't include transitionTime=null in sent payloads
2 parents cbdb77f + da87fb9 commit 9b758b7

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ A DeviceInfo object contains general information about a device. It has the foll
504504

505505
#### NEXT:
506506
* (AlCalzone) Swallow `"CoapClient was reset"` promise rejections and emit an `"error"` instead
507+
* (AlCalzone) Avoid sending `5712: null` in payloads when a group's transition time is `null` for some reason
507508

508509
#### 0.9.1 (2018-03-09)
509510
* (AlCalzone) Fix properties which are wrongly reported by the gateway

build/lib/conversions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const saturation_in = (value /*, light: Light*/) => {
200200
// ===========================
201201
// TRANSITION TIME conversions
202202
// the sent value is in 10ths of seconds, we're working with seconds
203-
const transitionTime_out = val => val * 10;
203+
const transitionTime_out = val => val && val * 10; // "val && " avoids sending `null` if val is null for some reason
204204
// the sent value is in 10ths of seconds, we're working with seconds
205205
const transitionTime_in = val => val / 10;
206206
// ===========================

src/lib/conversions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const saturation_in: PropertyTransformKernel = (value /*, light: Light*/) => {
200200
// TRANSITION TIME conversions
201201

202202
// the sent value is in 10ths of seconds, we're working with seconds
203-
const transitionTime_out: PropertyTransformKernel = val => val * 10;
203+
const transitionTime_out: PropertyTransformKernel = val => val && val * 10; // "val && " avoids sending `null` if val is null for some reason
204204
// the sent value is in 10ths of seconds, we're working with seconds
205205
const transitionTime_in: PropertyTransformKernel = val => val / 10;
206206

src/lib/group.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ describe("ipso/group => basic functionality => ", () => {
4747
expect(group.serialize()).to.deep.equal(template);
4848
});
4949

50+
it(`should serialize correctly when transitionTime has the value "null"`, () => {
51+
// repro for issue#51
52+
const brokenGroup = group.clone();
53+
brokenGroup.transitionTime = null;
54+
const reference = brokenGroup.clone();
55+
brokenGroup.onOff = !brokenGroup.onOff;
56+
57+
expect(brokenGroup.serialize(reference)).to.deep.equal({
58+
5850: brokenGroup.onOff ? 1 : 0,
59+
});
60+
});
61+
5062
});
5163

5264
describe("ipso/group => simplified API => ", () => {

0 commit comments

Comments
 (0)