Skip to content

Commit ab5483b

Browse files
committed
don't include transitionTime=null in sent payloads
fixes: #51
1 parent cbdb77f commit ab5483b

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

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)