Skip to content

Commit

Permalink
SPZB0001: improve eurotronic_host_flags
Browse files Browse the repository at this point in the history
- set system_mode
- parse bitset into hash
  • Loading branch information
sjorge committed Dec 15, 2019
1 parent 5bb9d04 commit 39dbdd1
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -2152,19 +2152,44 @@ const converters = {
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options) => {
const result = converters.thermostat_att_report.convert(model, msg, publish, options);
// system_mode is always 'heat', we set it below based on eurotronic_host_flags
if (result.system_mode) {
delete result['system_mode'];
}
if (typeof msg.data[0x4003] == 'number') {
result.current_heating_setpoint =
precisionRound(msg.data[0x4003], 2) / 100;
}
if (typeof msg.data[0x4008] == 'number') {
result.eurotronic_host_flags = msg.data[0x4008];
const resultHostFlags = {
'mirror_display': false,
'boost': false,
'window_open': false,
'child_protection': false,
};
if ((result.eurotronic_host_flags & 1 << 2) != 0) {
result.system_mode = common.thermostatSystemModes[1]; // boost => auto
// system_mode => 'heat', boost mode
result.system_mode = common.thermostatSystemModes[4];
resultHostFlags.boost = true;
} else if ((result.eurotronic_host_flags & (1 << 4)) != 0 ) {
result.system_mode = common.thermostatSystemModes[0]; // off
// system_mode => 'off', window open detected
result.system_mode = common.thermostatSystemModes[0];
resultHostFlags.window_open = true;
} else {
result.system_mode = common.thermostatSystemModes[4]; // heat
// system_mode => 'auto', default
result.system_mode = common.thermostatSystemModes[1];
}
if ((result.eurotronic_host_flags & (1 << 1)) != 0 ) {
// mirror_display
resultHostFlags.mirror_display = true;
}
if ((result.eurotronic_host_flags & (1 << 7)) != 0 ) {
// child protection
resultHostFlags.child_protection = true;
}
// result.eurotronic_system_mode = result.eurotronic_host_flags;
result.eurotronic_host_flags = resultHostFlags;
}
if (typeof msg.data[0x4002] == 'number') {
result.eurotronic_error_status = msg.data[0x4002];
Expand Down

0 comments on commit 39dbdd1

Please sign in to comment.