Skip to content

Commit 289b09a

Browse files
committed
Merge branch 'master' of github.com:domoticz/domoticz
2 parents c8ffbb9 + 7d73da0 commit 289b09a

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

hardware/MultiFun.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ MultiFun::MultiFun(const int ID, const std::string &IPAddress, const unsigned sh
119119

120120
m_isSensorExists[0] = false;
121121
m_isSensorExists[1] = false;
122+
m_isWeatherWork[0] = false;
123+
m_isWeatherWork[1] = false;
122124
}
123125

124126
MultiFun::~MultiFun()
@@ -240,7 +242,8 @@ bool MultiFun::WriteToHardware(const char *pdata, const unsigned char length)
240242

241243
float temp = therm->temp;
242244

243-
if (therm->id2 == 0x1F || therm->id2 == 0x20)
245+
if ((therm->id2 == 0x1F || therm->id2 == 0x20) ||
246+
((therm->id2 == 0x1C || therm->id2 == 0x1D) && m_isWeatherWork[therm->id2 - 0x1C]))
244247
{
245248
temp = temp * 5;
246249
temp = (int)temp | 0x8000;
@@ -346,7 +349,7 @@ void MultiFun::GetTemperatures()
346349

347350
if ((temp > -39) && (temp < 1000))
348351
{
349-
SendTempSensor(i, -1, temp, sensors[i].name);
352+
SendTempSensor(i, 255, temp, sensors[i].name);
350353
}
351354
if ((i == 1) || (i == 2))
352355
{
@@ -400,17 +403,17 @@ void MultiFun::GetRegisters(bool firstTime)
400403
{
401404
if (((*it).first & value) && !((*it).first & m_LastAlarms))
402405
{
403-
SendTextSensor(1, 0, -1, (*it).second, "Alarms");
406+
SendTextSensor(1, 0, 255, (*it).second, "Alarms");
404407
}
405408
else
406409
if (!((*it).first & value) && ((*it).first & m_LastAlarms))
407410
{
408-
SendTextSensor(1, 0, -1, "End - " + (*it).second, "Alarms");
411+
SendTextSensor(1, 0, 255, "End - " + (*it).second, "Alarms");
409412
}
410413
}
411414
if (((bool)m_LastAlarms != bool(value)) || firstTime)
412415
{
413-
SendAlertSensor(0, -1, value ? 4 : 1, "Alarm");
416+
SendAlertSensor(0, 255, value ? 4 : 1, "Alarm");
414417
}
415418
m_LastAlarms = value;
416419
break;
@@ -422,17 +425,17 @@ void MultiFun::GetRegisters(bool firstTime)
422425
{
423426
if (((*it).first & value) && !((*it).first & m_LastWarnings))
424427
{
425-
SendTextSensor(1, 1, -1, (*it).second, "Warnings");
428+
SendTextSensor(1, 1, 255, (*it).second, "Warnings");
426429
}
427430
else
428431
if (!((*it).first & value) && ((*it).first & m_LastWarnings))
429432
{
430-
SendTextSensor(1, 1, -1, "End - " + (*it).second, "Warnings");
433+
SendTextSensor(1, 1, 255, "End - " + (*it).second, "Warnings");
431434
}
432435
}
433436
if (((bool)m_LastWarnings != bool(value)) || firstTime)
434437
{
435-
SendAlertSensor(1, -1, value ? 3 : 1, "Warning");
438+
SendAlertSensor(1, 255, value ? 3 : 1, "Warning");
436439
}
437440
m_LastWarnings = value;
438441
break;
@@ -444,18 +447,18 @@ void MultiFun::GetRegisters(bool firstTime)
444447
{
445448
if (((*it).first & value) && !((*it).first & m_LastDevices))
446449
{
447-
SendGeneralSwitchSensor(2, -1, true, (*it).second.c_str(), (*it).first);
450+
SendGeneralSwitchSensor(2, 255, true, (*it).second.c_str(), (*it).first);
448451
}
449452
else
450453
if (!((*it).first & value) && ((*it).first & m_LastDevices))
451454
{
452-
SendGeneralSwitchSensor(2, -1, false, (*it).second.c_str(), (*it).first);
455+
SendGeneralSwitchSensor(2, 255, false, (*it).second.c_str(), (*it).first);
453456
}
454457
}
455458
m_LastDevices = value;
456459

457460
float level = (value & 0xFC00) >> 10;
458-
SendPercentageSensor(2, 1, -1, level, "BLOWER POWER");
461+
SendPercentageSensor(2, 1, 255, level, "BLOWER POWER");
459462
break;
460463
}
461464
case 0x03:
@@ -465,18 +468,18 @@ void MultiFun::GetRegisters(bool firstTime)
465468
{
466469
if (((*it).first & value) && !((*it).first & m_LastState))
467470
{
468-
SendTextSensor(3, 1, -1, (*it).second, "State");
471+
SendTextSensor(3, 1, 255, (*it).second, "State");
469472
}
470473
else
471474
if (!((*it).first & value) && ((*it).first & m_LastState))
472475
{
473-
SendTextSensor(3, 1, -1, "End - " + (*it).second, "State");
476+
SendTextSensor(3, 1, 255, "End - " + (*it).second, "State");
474477
}
475478
}
476479
m_LastState = value;
477480

478481
float level = (value & 0xFC00) >> 10;
479-
SendPercentageSensor(3, 1, -1, level, "Fuel Level");
482+
SendPercentageSensor(3, 1, 255, level, "Fuel Level");
480483
break;
481484
}
482485

@@ -491,6 +494,7 @@ void MultiFun::GetRegisters(bool firstTime)
491494
{
492495
temp = (value & 0x0FFF) * 0.2;
493496
}
497+
m_isWeatherWork[i - 0x1C] = (value & 0x8000) == 0x8000;
494498
SendSetPointSensor(i, 1, 1, temp, name);
495499
break;
496500
}
@@ -514,7 +518,7 @@ void MultiFun::GetRegisters(bool firstTime)
514518
}
515519
else
516520
{
517-
//SendGeneralSwitchSensor(i, -1, value, name, 1); // TODO - send level (dimmer)
521+
//SendGeneralSwitchSensor(i, 255, value, name, 1); // TODO - send level (dimmer)
518522
}
519523
break;
520524
}
@@ -526,12 +530,12 @@ void MultiFun::GetRegisters(bool firstTime)
526530
{
527531
if (((*it).first & value) && !((*it).first & m_LastQuickAccess))
528532
{
529-
SendGeneralSwitchSensor(0x21, -1, true, (*it).second.c_str(), (*it).first);
533+
SendGeneralSwitchSensor(0x21, 255, true, (*it).second.c_str(), (*it).first);
530534
}
531535
else
532536
if ((!((*it).first & value) && ((*it).first & m_LastQuickAccess)) || firstTime)
533537
{
534-
SendGeneralSwitchSensor(0x21, -1, false, (*it).second.c_str(), (*it).first);
538+
SendGeneralSwitchSensor(0x21, 255, false, (*it).second.c_str(), (*it).first);
535539
}
536540
}
537541
m_LastQuickAccess = value;
@@ -625,7 +629,7 @@ int MultiFun::SendCommand(const unsigned char* cmd, const unsigned int cmdLength
625629
{
626630
if (databuffer[8] >= 1 && databuffer[8] <= 4)
627631
{
628-
_log.Log(LOG_ERROR, "MultiFun: Receive error (%s)", errors[databuffer[8]].c_str());
632+
_log.Log(LOG_ERROR, "MultiFun: Receive error (%s)", errors[databuffer[8] - 1].c_str());
629633
}
630634
else
631635
{

hardware/MultiFun.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MultiFun : public CDomoticzHardwareBase
3232
int m_LastState;
3333
int m_LastQuickAccess;
3434
bool m_isSensorExists[2];
35+
bool m_isWeatherWork[2];
3536

3637
bool StartHardware();
3738
bool StopHardware();

0 commit comments

Comments
 (0)