Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MClimate Vicki updated decoder #835

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions vendor/mclimate/vicki-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ uplinkDecoder:
calibrationFailed: false
perceiveAsOnline: false
antiFreezeProtection: false
motorOpenness: 17
targetTemperatureFloat: '29.00'
valveOpenness: 17
targetTemperatureFloat: 29
normalizedOutput:
data:
- air:
Expand Down
15 changes: 7 additions & 8 deletions vendor/mclimate/vicki.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ function decodeUplink(input) {
batteryTmp = ("0" + bytes[7].toString(16)).substr(-2)[0];
batteryVoltageCalculated = 2 + parseInt("0x" + batteryTmp, 16) * 0.1;

decbin = function(number) {
let decbin = (number) => {
if (number < 0) {
number = 0xFFFFFFFF + number + 1
}
number = number.toString(2);
return "00000000".substr(number.length) + number;
}
byte7Bin = decbin(bytes[8]);
byte7Bin = decbin(bytes[7]);
openWindow = byte7Bin[4];
highMotorConsumption = byte7Bin[5];
lowMotorConsumption = byte7Bin[6];
Expand Down Expand Up @@ -67,9 +67,9 @@ function decodeUplink(input) {
data.attachedBackplate = toBool(attachedBackplate);
data.perceiveAsOnline = toBool(perceiveAsOnline);
data.antiFreezeProtection = toBool(antiFreezeProtection);
data.motorOpenness = Math.round((1-(motorPosition/motorRange))*100);
data.valveOpenness = motorRange != 0 ? Math.round((1-(motorPosition/motorRange))*100) : 0;
if(!data.hasOwnProperty('targetTemperatureFloat')){
data.targetTemperatureFloat = bytes[1].toFixed(2);
data.targetTemperatureFloat = parseFloat(bytes[1])
}
return data;
}
Expand Down Expand Up @@ -169,8 +169,7 @@ function decodeUplink(input) {
{
// get default keepalive if it is not available in data
command_len = 2;
var deviceKeepAlive = 5;
var wdpC = commands[i + 1] == '00' ? false : commands[i + 1] * deviceKeepAlive + 7;
var wdpC = commands[i + 1] == '00' ? false : parseInt(commands[i + 1], 16);
var wdpUc = commands[i + 2] == '00' ? false : parseInt(commands[i + 2], 16);
var dataJ = { watchDogParams: { wdpC: wdpC, wdpUc: wdpUc } };
resultToPass = merge_obj(resultToPass, dataJ);
Expand Down Expand Up @@ -311,14 +310,14 @@ function decodeUplink(input) {
case '4d':
{
command_len = 2;
var data = { maxAllowedIntegralValue : (parseInt(`${commands[i + 1]}${commands[i + 2]}`, 16))/10 };
var data = { piMaxIntegratedError : (parseInt(`${commands[i + 1]}${commands[i + 2]}`, 16))/10 };
resultToPass = merge_obj(resultToPass, data);
}
break;
case '50':
{
command_len = 2;
var data = { valveOpennessRangeInPercentage: { min: parseInt(commands[i + 1], 16), max: parseInt(commands[i + 2], 16) } };
var data = { effectiveMotorRange: { minValveOpenness: 100 - parseInt(commands[i + 2], 16), maxValveOpenness: 100 - parseInt(commands[i + 1], 16) } };
resultToPass = merge_obj(resultToPass, data);
}
break;
Expand Down
Loading