Skip to content

Commit 69cd1ed

Browse files
authored
Merge pull request #1192 from Spugna85/master
OpenWebNet: fix device status update with unofficial gateway
2 parents 61daee0 + 64438e8 commit 69cd1ed

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

hardware/OpenWebNetTCP.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,12 @@ void COpenWebNetTCP::UpdateDeviceValue(vector<bt_openwebnet>::iterator iter)
535535
string who = iter->Extract_who();
536536
string where = iter->Extract_where();
537537
string what = iter->Extract_what();
538+
std::vector<std::string> whatParam = iter->Extract_whatParameters();
538539
string dimension = iter->Extract_dimension();
539540
string value = iter->Extract_value(0);
540541
string sInterface = iter->Extract_interface();
541542
string devname;
543+
int app_value;
542544

543545
switch (atoi(who.c_str())) {
544546
case WHO_LIGHTING:
@@ -550,24 +552,20 @@ void COpenWebNetTCP::UpdateDeviceValue(vector<bt_openwebnet>::iterator iter)
550552
devname = OPENWEBNET_LIGHT;
551553
devname += " " + where; // 1
552554

553-
if (atoi(what.c_str()) == 1000) // What = 1000 (Command translation)
554-
{
555-
if (what[4] == '#')
556-
what = what.substr(5);
557-
else
558-
_log.Log(LOG_ERROR, "COpenWebNetTCP: Who=%s what=%s", who.c_str(), what.c_str());
559-
}
555+
app_value = atoi(what.c_str());
556+
if (app_value == 1000) // What = 1000 (Command translation)
557+
app_value = atoi(whatParam[0].c_str());
560558

561559
//pTypeGeneralSwitch, sSwitchLightT1
562-
UpdateSwitch(WHO_LIGHTING, atoi(where.c_str()), atoi(what.c_str()), atoi(sInterface.c_str()), 100, devname.c_str(), sSwitchLightT1);
560+
UpdateSwitch(WHO_LIGHTING, atoi(where.c_str()), app_value, atoi(sInterface.c_str()), 255, devname.c_str(), sSwitchLightT1);
563561
break;
564562
case WHO_AUTOMATION:
565563
if(!iter->IsNormalFrame())
566564
{
567565
_log.Log(LOG_ERROR, "COpenWebNetTCP: Who=%s frame error!", who.c_str());
568566
return;
569567
}
570-
int app_value;
568+
571569
switch(atoi(what.c_str()))
572570
{
573571
case AUTOMATION_WHAT_STOP: // 0
@@ -580,12 +578,13 @@ void COpenWebNetTCP::UpdateDeviceValue(vector<bt_openwebnet>::iterator iter)
580578
app_value = gswitch_sOn;
581579
break;
582580
default:
581+
_log.Log(LOG_ERROR, "COpenWebNetTCP: Who=%s, What=%s invalid!", who.c_str(), what.c_str());
583582
return;
584583
}
585584
devname = OPENWEBNET_AUTOMATION;
586585
devname += " " + where;
587586
//pTypeGeneralSwitch, sSwitchBlindsT1
588-
UpdateBlinds(WHO_AUTOMATION, atoi(where.c_str()), app_value, atoi(sInterface.c_str()), 100, devname.c_str()); // 2
587+
UpdateBlinds(WHO_AUTOMATION, atoi(where.c_str()), app_value, atoi(sInterface.c_str()), 255, devname.c_str()); // 2
589588
break;
590589
case WHO_TEMPERATURE_CONTROL:
591590
if(!iter->IsMeasureFrame())
@@ -597,7 +596,7 @@ void COpenWebNetTCP::UpdateDeviceValue(vector<bt_openwebnet>::iterator iter)
597596
{
598597
devname = OPENWEBNET_TEMPERATURE;
599598
devname += " " + where;
600-
UpdateTemp(WHO_TEMPERATURE_CONTROL, atoi(where.c_str()), static_cast<float>(atof(value.c_str()) / 10.), 100, devname.c_str());
599+
UpdateTemp(WHO_TEMPERATURE_CONTROL, atoi(where.c_str()), static_cast<float>(atof(value.c_str()) / 10.), 255, devname.c_str());
601600
}
602601

603602
else

0 commit comments

Comments
 (0)