Skip to content

Commit

Permalink
MClimate Vicki updated decoder (#835)
Browse files Browse the repository at this point in the history
* New MClimate devices: 16ASPM, CO2 Display Lite

* New MClimate devices: 16ASPM, CO2 Display Lite

* MClimate Vicki updated decoder

---------

Co-authored-by: Yordan <[email protected]>
  • Loading branch information
MClimate and yordan-zaychev authored Oct 21, 2024
1 parent 584ec7f commit 5123d83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
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

0 comments on commit 5123d83

Please sign in to comment.