Browse Source

added support for some IT-like Remote Controls ("Brennenstuhl"),
small bugfixes

FloKra 2 years ago
parent
commit
0dcc41236a
1 changed files with 24 additions and 4 deletions
  1. 24 4
      cul2mqtt.py

+ 24 - 4
cul2mqtt.py

@@ -381,19 +381,39 @@ def publish_device_statusupdate(device, cmd):
 def parseRXCode(rx_code, source_cul):
     receivedForDevice = None
     receivedCmnd = None
+    
     if rx_code.startswith("i"):
         # parse InterTechno RX code
         if debug: log_write("INTERTECHNO PROTOCOL")
+        sucessfullyParsedITCode = False
+        
+        # look if this code is in the device_config
         if rx_code in RXcodesToDevFunction_IT:
             receivedForDevice = RXcodesToDevFunction_IT[rx_code][0]
             receivedCmnd = RXcodesToDevFunction_IT[rx_code][1]
+            sucessfullyParsedITCode = True
             if debug: log_write("DEV: " + receivedForDevice + ", CMD: " + receivedCmnd + ", RX: " + rx_code)
             if verbose: 
                 log_write("")
                 log_write("CUL '" + source_cul + "' received '" + rx_code + "' => DEV: " + receivedForDevice + ", CMD: " + receivedCmnd)
-        else:
+        
+        # if this had no result -> try again with removed last 2 chars as it is in many cases omitted as its only RSSI and not part of the code
+        rx_code = rx_code[0:-2]
+        if not sucessfullyParsedITCode and rx_code in RXcodesToDevFunction_IT:
+            receivedForDevice = RXcodesToDevFunction_IT[rx_code][0]
+            receivedCmnd = RXcodesToDevFunction_IT[rx_code][1]
+            sucessfullyParsedITCode = True
+            if debug: log_write("DEV: " + receivedForDevice + ", CMD: " + receivedCmnd + ", RX: " + rx_code)
+            if verbose: 
+                log_write("")
+                log_write("CUL '" + source_cul + "' received '" + rx_code + "' => DEV: " + receivedForDevice + ", CMD: " + receivedCmnd)
+        
+        # if this also did not work, try to parse it as "default/cheap" IT code... 
+        if not sucessfullyParsedITCode:
             receivedForDevice, receivedCmnd = decodeInterTechnoRX(rx_code)
-            if debug: log_write(receivedForDevice + ", " + receivedCmnd)
+            if debug: 
+                log_write(str(receivedForDevice) + ", " + str(receivedCmnd))
+            
     else:
         # parse other/RAW RX code
         if debug: log_write("OTHER/RAW PROTOCOL")
@@ -406,9 +426,9 @@ def parseRXCode(rx_code, source_cul):
                 log_write("CUL '" + source_cul + "' received '" + rx_code + "' => DEV: " + receivedForDevice + ", CMD: " + receivedCmnd)
     
     if debug: 
-        log_write("DEV: " + receivedForDevice + ", CMD: " + receivedCmnd + ", RX: " + rx_code)
+        log_write("DEV: " + str(receivedForDevice) + ", CMD: " + str(receivedCmnd) + ", RX: " + rx_code)
     
-    if receivedForDevice != None and receivedCmnd != None:
+    if receivedForDevice != None and receivedCmnd != None and receivedForDevice != False and receivedCmnd != False:
         publish_device_statusupdate(receivedForDevice, receivedCmnd)
 
 def decodeInterTechnoRX(rx_code):