Skip to content

Commit

Permalink
Add AC Control commands 0x193A, 0x193B
Browse files Browse the repository at this point in the history
  • Loading branch information
caligo-mentis committed Feb 28, 2020
1 parent 95cffca commit 08e0d87
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Fix channels info for scene status commands (`0x0003`, `0xEFFF`)
* Fix parsing of "Response Read Sensors Status" (`0x1605`)
* Add Panel buttons control commands (`0xE012`, `0xE14E`)
* Add AC Control commands (`0x193A`, `0x193B`)

**BREAKING:**

Expand Down
93 changes: 91 additions & 2 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,86 @@ var date = {
}
};

var AC = {
modes: ['cooling', 'heating', 'fan', 'auto', 'dry'],
speeds: ['auto', 'high', 'medium', 'low'],

parse: function(buffer) {
var mode = buffer.readUInt8(7);
var temperature = buffer.readUInt8(11);

var swing = buffer.readUInt8(12);

return {
ac: buffer.readUInt8(0),

temperature: {
type: buffer.readUInt8(1) ? 'F' : 'C',

current: buffer.readUInt8(2),

cooling: buffer.readUInt8(3),
heating: buffer.readUInt8(4),
auto: buffer.readUInt8(5),
dry: buffer.readUInt8(6)
},

current: {
mode: AC.modes[mode >> 4],
speed: AC.speeds[mode & 15]
},

status: Boolean(buffer.readUInt8(8)),

setup: {
mode: AC.modes[buffer.readUInt8(9)],
speed: AC.speeds[buffer.readUInt8(10)],
temperature: temperature
},

swing: {
enabled: Boolean(swing >> 4),
active: Boolean(swing & 15)
}
};
},

encode: function(data) {
var buffer = new Buffer(13);

var temperature = data.temperature || {};
var current = data.current || {};
var setup = data.setup || {};
var swing = data.swing || {};

var modes = AC.modes;
var speeds = AC.speeds;

buffer.writeUInt8(data.ac, 0);

buffer.writeUInt8(temperature.type === 'F' ? 1 : 0, 1);
buffer.writeUInt8(temperature.current, 2);
buffer.writeUInt8(temperature.cooling, 3);
buffer.writeUInt8(temperature.heating, 4);
buffer.writeUInt8(temperature.auto, 5);
buffer.writeUInt8(temperature.dry, 6);

buffer.writeUInt8(
modes.indexOf(current.mode) << 4 | speeds.indexOf(current.speed), 7);

buffer.writeUInt8(data.status ? 1 : 0, 8);

buffer.writeUInt8(modes.indexOf(setup.mode), 9);
buffer.writeUInt8(speeds.indexOf(setup.speed), 10);
buffer.writeUInt8(setup.temperature, 11);

buffer.writeUInt8(
((swing.enabled ? 1 : 0) << 4) | (swing.active ? 1 : 0), 12);

return buffer;
}
};

/*
Commands as decribed in "Operation Code of HDL Buspro v1.111.pdf"
from http://hdlautomation.com
Expand Down Expand Up @@ -964,10 +1044,19 @@ module.exports = {
// 0x1939

// 10.1.3 Control AC Status
// 0x193A
// Documetation is wrong
0x193A: {
parse: AC.parse,
encode: AC.encode,

response: 0x193B
},

// 10.1.4 Response Control AC Status
// 0x193B
0x193B: {
parse: AC.parse,
encode: AC.encode
},

/* 11.1 Floor Heating Control from DLP */

Expand Down
68 changes: 68 additions & 0 deletions test/fixtures/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,74 @@ module.exports = {
{ payload: new Buffer('0E32', 'hex'), data: { key: 14, value: 50 } },
],

/* 10. AC Control */

// 10.1.1 Read AC Status
// 0x1938

// 10.1.2 Response Read AC Status
// 0x1939

// 10.1.3 Control AC Status
'0x193A': {
payload: new Buffer('01001C10131516230101001311', 'hex'),
data: {
ac: 1,
temperature: {
type: 'C',
current: 28,
cooling: 16,
heating: 19,
auto: 21,
dry: 22
},
current: {
mode: 'fan',
speed: 'low'
},
status: true,
setup: {
mode: 'heating',
speed: 'auto',
temperature: 19
},
swing: {
enabled: true,
active: true
}
}
},

// 10.1.4 Response Control AC Status
'0x193B': {
payload: new Buffer('01001C10131516010100001000', 'hex'),
data: {
ac: 1,
temperature: {
type: 'C',
current: 28,
cooling: 16,
heating: 19,
auto: 21,
dry: 22
},
current: {
mode: 'cooling',
speed: 'high'
},
status: true,
setup: {
mode: 'cooling',
speed: 'auto',
temperature: 16
},
swing: {
enabled: false,
active: false
}
}
},

/* 11.1 Floor Heating Control from DLP */

// 11.1.1 Read Floor Heating Status
Expand Down

0 comments on commit 08e0d87

Please sign in to comment.