Skip to content

Commit

Permalink
Fix MClimate wireless thermostat decoder (#654)
Browse files Browse the repository at this point in the history
* MClimate - Vicki,T-valve,Flood,Ht,AQI

* update aqi sensors

* update device names

* remove scripts

* Key security fix

* fix yaml,

* fix reseller urls

* remove scripts

* remove reseller vicki

* remove ressellerUrls

* profile

* fix sensors

* img

* change flood img

* aqi, ht img

* prettier

* prettier

* prettier

* uplink decoders, update aqi info

* prettier again...

* Pretttier again...

* new Vicki uplinkDecoder, fix versions

* return shorter decoder

* update uplink decoders

* New mclimate device CO2 sensor

* new Vicki version and decoder

* new version Vicki, new decoder ht/co2, remove AQI

* add MClimate wireless thermostat

* mclimate wireless thermostat fix image name

* MClimate wireless thermostat prettier

* vicki 4.2

* fix vicki codec

* fix Mclimate wireless thermostat decoder

---------

Co-authored-by: Yordan Zaychev <[email protected]>
Co-authored-by: Johan Stokking <[email protected]>
Co-authored-by: Jaime Trinidad <[email protected]>
  • Loading branch information
4 people committed Aug 14, 2023
1 parent 5c44325 commit 3cde702
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions vendor/mclimate/wireless-thermostat.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@

function decodeUplink(input) {
try{
var bytes = input.bytes;
var data = {};
const toBool = value => value == '1';
var calculateTemperature = function (rawData){return (rawData - 400) / 10};
var calculateHumidity = function(rawData){return (rawData * 100) / 256};

var decbin = function (number) {
if (number < 0) {
number = 0xFFFFFFFF + number + 1
}
number = number.toString(2);
return "00000000".substr(number.length) + number;
}
function handleKeepalive(bytes, data){
var tempHex = '0' + bytes[1].toString(16) + bytes[2].toString(16);
var tempDec = parseInt(tempHex, 16);
var temperatureValue = calculateTemperature(tempDec);
var humidityValue = calculateHumidity(bytes[3]);
var batteryHex = '0' + bytes[4].toString(16) + bytes[5].toString(16);
var batteryVoltageCalculated = parseInt(batteryHex, 16)/1000;

var temperature = temperatureValue;
var humidity = humidityValue;
var batteryVoltage = batteryVoltageCalculated;
var batteryVoltage = parseInt(`${decbin(bytes[4])}${decbin(bytes[5])}`, 2)/1000;
var targetTemperature = bytes[6];
var powerSourceStatus = bytes[7];
var lux = parseInt('0' + bytes[8].toString(16) + bytes[9].toString(16), 16);
Expand Down Expand Up @@ -91,6 +95,12 @@ function decodeUplink(input) {
data.targetTemperature = parseInt(commands[i + 1], 16) ;
}
break;
case '30':
{
command_len = 1;
data.manualTargetTemperatureUpdate = parseInt(commands[i + 1], 16) ;
}
break;
case '32':
{
command_len = 1;
Expand Down Expand Up @@ -121,7 +131,7 @@ function decodeUplink(input) {
data = handleKeepalive(bytes, data);
}else{
data = handleResponse(bytes,data);
bytes = bytes.slice(-8);
bytes = bytes.slice(-11);
data = handleKeepalive(bytes, data);
}
return {data: data};
Expand Down

0 comments on commit 3cde702

Please sign in to comment.