Skip to content

Commit f189757

Browse files
author
steplebr
committed
modified blind command type/subtype
solved compilation issues translated comments and public members of bt_openwebnet added who/what->text conversion
1 parent 3c74459 commit f189757

File tree

13 files changed

+457
-295
lines changed

13 files changed

+457
-295
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ hardware/NefitEasy.cpp
263263
hardware/Nest.cpp
264264
hardware/Netatmo.cpp
265265
hardware/OpenWebNet.cpp
266+
hardware/openwebnet/bt_openwebnet.cpp
266267
hardware/OpenZWave.cpp
267268
hardware/openzwave/control_panel/ozwcp.cpp
268269
hardware/openzwave/control_panel/zwavelib.cpp

hardware/OpenWebNet.cpp

Lines changed: 178 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void COpenWebNet::MonitorFrames()
169169

170170
for (vector<bt_openwebnet>::iterator iter = responses.begin(); iter != responses.end(); iter++) {
171171
if (iter->IsNormalFrame()) {
172-
AddDeviceIfNotExits(iter->Extract_chi(), iter->Extract_dove());
172+
AddDeviceIfNotExits(iter->Extract_who(), iter->Extract_where());
173173
}
174174
_log.Log(LOG_STATUS, "COpenWebNet : received=%s", frameToString(*iter).c_str());
175175
}
@@ -182,33 +182,33 @@ void COpenWebNet::MonitorFrames()
182182

183183
bool COpenWebNet:: WriteToHardware(const char *pdata, const unsigned char length)
184184
{
185-
tRBUF *pCmd = (tRBUF*)pdata;
185+
_tGeneralSwitch *pCmd = (_tGeneralSwitch*)pdata;
186+
187+
unsigned char packetlength = pCmd->len;
188+
unsigned char packettype = pCmd->type;
189+
unsigned char subtype = pCmd->subtype;
186190

187-
unsigned char packetlength = pCmd->ICMND.packetlength;
188-
unsigned char packettype = pCmd->ICMND.packettype;
189-
unsigned char subtype = pCmd->ICMND.subtype;
190-
unsigned char seqnbr = pCmd->ICMND.seqnbr;
191191

192192
int who;
193193
int what;
194194
int where;
195195

196-
if (packettype == pTypeBlinds && subtype == sTypeBlindsT12){
196+
if (packettype == pTypeGeneralSwitch && subtype == sSwitchBlindsT1){
197197
//Blinds/Window command
198-
int blindId = pCmd->BLINDS1.id1;
198+
int blindId = pCmd->unitcode;
199199

200200
who = WHO_AUTOMATION;
201201
where = blindId;
202202

203-
if (pCmd->BLINDS1.cmnd == blinds_sOpen)
203+
if (pCmd->cmnd == gswitch_sOff)
204204
{
205205
what = AUTOMATION_WHAT_UP;
206206
}
207-
else if (pCmd->BLINDS1.cmnd == blinds_sClose)
207+
else if (pCmd->cmnd == gswitch_sOn)
208208
{
209209
what = AUTOMATION_WHAT_DOWN;
210210
}
211-
else if (pCmd->BLINDS1.cmnd == blinds_sStop)
211+
else if (pCmd->cmnd == gswitch_sStop)
212212
{
213213
what = AUTOMATION_WHAT_STOP;
214214
}
@@ -351,8 +351,8 @@ bool COpenWebNet::AddDeviceIfNotExits(string who, string where)
351351

352352
switch (atoi(who.c_str())) {
353353
case WHO_AUTOMATION:
354-
devType = pTypeBlinds;
355-
subType = sTypeBlindsT12;
354+
devType = pTypeGeneralSwitch;
355+
subType = sSwitchBlindsT1;
356356
switchType = STYPE_Blinds;
357357
devname = OPENWEBNET_AUTOMATION;
358358
devname += " " + where;
@@ -397,8 +397,8 @@ bool COpenWebNet::FindDevice(int who, int where, int* used)
397397

398398
switch (who) {
399399
case WHO_AUTOMATION :
400-
devType = pTypeBlinds;
401-
subType = sTypeBlindsT12;
400+
devType = pTypeGeneralSwitch;
401+
subType = sSwitchBlindsT1;
402402
break;
403403
default:
404404
return "";
@@ -464,46 +464,46 @@ string COpenWebNet::frameToString(bt_openwebnet& frame)
464464
{
465465
frameStr << "NORMAL FRAME";
466466

467-
if (frame.estesa) {
467+
if (frame.extended) {
468468
frameStr << " - EXTENDED";
469469
}
470470

471-
frameStr << " - who=" << frame.Extract_chi();
472-
frameStr << " - what=" << frame.Extract_cosa();
473-
frameStr << " - where=" << frame.Extract_dove();
474-
if (!frame.Extract_quando().empty()) {
475-
frameStr << " - when=" << frame.Extract_quando();
471+
frameStr << " - who=" << getWhoDescription(frame.Extract_who());
472+
frameStr << " - what=" << getWhatDescription(frame.Extract_who(), frame.Extract_what());
473+
frameStr << " - where=" << frame.Extract_where();
474+
if (!frame.Extract_when().empty()) {
475+
frameStr << " - when=" << frame.Extract_when();
476476
}
477-
if (!frame.Extract_livello().empty()) {
478-
frameStr << " - level=" << frame.Extract_livello();
477+
if (!frame.Extract_level().empty()) {
478+
frameStr << " - level=" << frame.Extract_level();
479479
}
480-
if (!frame.Extract_interfaccia().empty()) {
481-
frameStr << " - interface=" << frame.Extract_interfaccia();
480+
if (!frame.Extract_interface().empty()) {
481+
frameStr << " - interface=" << frame.Extract_interface();
482482
}
483-
if (!frame.Extract_grandezza().empty()) {
484-
frameStr << " - dimension=" << frame.Extract_grandezza();
483+
if (!frame.Extract_dimension().empty()) {
484+
frameStr << " - dimension=" << frame.Extract_dimension();
485485
}
486486

487-
string indirizzo = frame.Extract_indirizzo(0);
487+
string indirizzo = frame.Extract_address(0);
488488
if (!indirizzo.empty()) {
489489
int i = 1;
490490
frameStr << " - address=";
491491
while (!indirizzo.empty()) {
492492
frameStr << indirizzo;
493-
indirizzo = frame.Extract_indirizzo(i++);
493+
indirizzo = frame.Extract_address(i++);
494494
if (!indirizzo.empty()) {
495495
frameStr << ", ";
496496
}
497497
}
498498
}
499499

500-
string valori = frame.Extract_valori(0);
500+
string valori = frame.Extract_value(0);
501501
if (!valori.empty()) {
502502
int i = 1;
503503
frameStr << " - value=";
504504
while (!valori.empty()) {
505505
frameStr << valori;
506-
indirizzo = frame.Extract_valori(i++);
506+
indirizzo = frame.Extract_value(i++);
507507
if (!valori.empty()) {
508508
frameStr << ", ";
509509
}
@@ -512,4 +512,151 @@ string COpenWebNet::frameToString(bt_openwebnet& frame)
512512
}
513513

514514
return frameStr.str();
515+
}
516+
517+
string COpenWebNet::getWhoDescription(string who)
518+
{
519+
if (who == "0") {
520+
return "Scenario";
521+
}
522+
if (who == "1") {
523+
return "Lighting";
524+
}
525+
if (who == "2") {
526+
return "Automation";
527+
}
528+
if (who == "3") {
529+
return "Load control";
530+
}
531+
if (who == "4") {
532+
return "Temperature control";
533+
}
534+
if (who == "5") {
535+
return "Burglar alarm";
536+
}
537+
if (who == "6") {
538+
return "Door entry system";
539+
}
540+
if (who == "7") {
541+
return "Multimedia";
542+
}
543+
if (who == "9") {
544+
return "Auxiliary";
545+
}
546+
if (who == "13") {
547+
return "Gateway interfaces management";
548+
}
549+
if (who == "14") {
550+
return "Light shutter actuator lock";
551+
}
552+
if (who == "15") {
553+
return "Scenario Scheduler Switch";
554+
}
555+
if (who == "16") {
556+
return "Audio";
557+
}
558+
if (who == "17") {
559+
return "Scenario programming";
560+
}
561+
if (who == "18") {
562+
return "Energy management";
563+
}
564+
if (who == "24") {
565+
return "Lighting management";
566+
}
567+
if (who == "25") {
568+
return "Scenario scheduler buttons";
569+
}
570+
if (who == "1000") {
571+
return "Diagnostic";
572+
}
573+
if (who == "1001") {
574+
return "Automation diagnostic";
575+
}
576+
if (who == "1004") {
577+
return "Thermoregulation diagnostic failure";
578+
}
579+
if (who == "1013") {
580+
return "Device diagnostic";
581+
}
582+
583+
return who;
584+
}
585+
586+
string COpenWebNet::getWhatDescription(string who, string what)
587+
{
588+
if (who == "0") {
589+
// "Scenario";
590+
}
591+
if (who == "1") {
592+
// "Lighting";
593+
}
594+
if (who == "2") {
595+
// "Automation";
596+
if (what == "0") {
597+
return "Stop";
598+
}
599+
if (what == "1") {
600+
return "Up";
601+
}
602+
if (what == "2") {
603+
return "Down";
604+
}
605+
}
606+
if (who == "3") {
607+
// "Load control";
608+
}
609+
if (who == "4") {
610+
// "Temperature control";
611+
}
612+
if (who == "5") {
613+
// "Burglar alarm";
614+
}
615+
if (who == "6") {
616+
// "Door entry system";
617+
}
618+
if (who == "7") {
619+
// "Multimedia";
620+
}
621+
if (who == "9") {
622+
// "Auxiliary";
623+
}
624+
if (who == "13") {
625+
// "Gateway interfaces management";
626+
}
627+
if (who == "14") {
628+
// "Light shutter actuator lock";
629+
}
630+
if (who == "15") {
631+
// "Scenario Scheduler Switch";
632+
}
633+
if (who == "16") {
634+
// "Audio";
635+
}
636+
if (who == "17") {
637+
// "Scenario programming";
638+
}
639+
if (who == "18") {
640+
// "Energy management";
641+
}
642+
if (who == "24") {
643+
// "Lighting management";
644+
}
645+
if (who == "25") {
646+
// "Scenario scheduler buttons";
647+
}
648+
if (who == "1000") {
649+
// "Diagnostic";
650+
}
651+
if (who == "1001") {
652+
// "Automation diagnostic";
653+
}
654+
if (who == "1004") {
655+
// "Thermoregulation diagnostic failure";
656+
}
657+
if (who == "1013") {
658+
// "Device diagnostic";
659+
}
660+
661+
return what;
515662
}

hardware/OpenWebNet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@ class COpenWebNet : public CDomoticzHardwareBase
7171
bool FindDevice(int who, int where, int *used);
7272
bool AddDeviceIfNotExits(string who, string where);
7373
string frameToString(bt_openwebnet& frame);
74+
string getWhoDescription(string who);
75+
string getWhatDescription(string who, string what);
7476
};

hardware/hardwaretypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
#define sSwitchTypeFunkbus 0x4c
139139
#define sSwitchTypeNice 0x4d
140140
#define sSwitchTypeForest 0x4e
141+
#define sSwitchBlindsT1 0x4f
141142

142143
//Switch commands
143144
#define gswitch_sOff 0x00

0 commit comments

Comments
 (0)