|
@@ -395,6 +395,7 @@ def parseRXCode(rx_code, source_cul):
|
|
|
receivedForDevice = None
|
|
|
receivedCmnd = None
|
|
|
receivedValue = None
|
|
|
+ skipPublishing = False
|
|
|
|
|
|
if rx_code.startswith("i"):
|
|
|
# parse Intertechno RX code
|
|
@@ -444,13 +445,59 @@ def parseRXCode(rx_code, source_cul):
|
|
|
receivedCmnd = RXcodesToDevFunction_IT[rx_code_stripped][1]
|
|
|
|
|
|
receivedValue = rx_code[-3:]
|
|
|
+ tmpReceivedValue = int(receivedValue, base=16)
|
|
|
|
|
|
- # convert value to decimal if enabled for this device
|
|
|
- if "convertValueToDecimal" in devdata[receivedForDevice]:
|
|
|
+ if debug: log_write(" RAW receivedValue=" + hex(tmpReceivedValue))
|
|
|
+
|
|
|
+
|
|
|
+ # sensor type DS18B20
|
|
|
+ # -> convert raw data to temperature °C
|
|
|
+ if "isSensorType" in devdata[receivedForDevice]:
|
|
|
+ if devdata[receivedForDevice]["isSensorType"] == "DS18B20":
|
|
|
+ if debug:
|
|
|
+ log_write(" is sensor type DS18B20")
|
|
|
+ log_write(" converting RAW data...")
|
|
|
+
|
|
|
+ if tmpReceivedValue == 0xfff or tmpReceivedValue == 0xffe:
|
|
|
+ _battState = ""
|
|
|
+ # this is a low battery warning
|
|
|
+ # -> send warning on MQTT if configured and skip value transmitting
|
|
|
+ if "battTopic" in devdata[receivedForDevice]:
|
|
|
+ if devdata[receivedForDevice]["battTopic"] is not None:
|
|
|
+ if tmpReceivedValue == 0xfff:
|
|
|
+ _battState = "OK"
|
|
|
+ elif tmpReceivedValue == 0xffe:
|
|
|
+ _battState = "LOW"
|
|
|
+ mqttc.publish(devdata[receivedForDevice]["battTopic"], _battState, qos=0, retain=False)
|
|
|
+ skipPublishing = True # no data will be published this time
|
|
|
+ else:
|
|
|
+ # left shift 2 bits as sender right shifts it
|
|
|
+ tmpReceivedValue = tmpReceivedValue << 2
|
|
|
+
|
|
|
+ if debug: log_write(" receivedValue=" + str(tmpReceivedValue))
|
|
|
+
|
|
|
+ # if MSB (bit 13) == 1 -> negative value
|
|
|
+ if tmpReceivedValue >= 8192:
|
|
|
+ tmpReceivedValue = tmpReceivedValue - 16384
|
|
|
+
|
|
|
+ tmpReceivedValue = round(0.0078125 * tmpReceivedValue, 1)
|
|
|
+ if debug: log_write(" converted value=" + str(tmpReceivedValue))
|
|
|
+
|
|
|
+ if tmpReceivedValue >= -50 and tmpReceivedValue <= 125:
|
|
|
+ receivedValue = str(tmpReceivedValue)
|
|
|
+ else:
|
|
|
+ log_write(" WARN: value out of range - skipping")
|
|
|
+ skipPublishing = True # no data will be published this time
|
|
|
+
|
|
|
+
|
|
|
+ # not a "special" sensor but convertValueToDecimal is enabled
|
|
|
+ # -> convert value to decimal if enabled for this device
|
|
|
+ elif "convertValueToDecimal" in devdata[receivedForDevice]:
|
|
|
if devdata[receivedForDevice]["convertValueToDecimal"] == True:
|
|
|
if debug: log_write(" converting value to decimal")
|
|
|
receivedValue = str(int(receivedValue, base=16))
|
|
|
|
|
|
+
|
|
|
sucessfullyParsedITCode = True
|
|
|
if debug: log_write(" DEV: " + receivedForDevice + ", CMD: " + receivedCmnd + ", VALUE: " + receivedValue + ", RX: " + rx_code_stripped)
|
|
|
if verbose:
|
|
@@ -481,7 +528,7 @@ def parseRXCode(rx_code, source_cul):
|
|
|
#if debug:
|
|
|
# log_write(" DEV: " + str(receivedForDevice) + ", CMD: " + str(receivedCmnd) + ", RX: " + rx_code)
|
|
|
|
|
|
- if receivedForDevice != None and receivedCmnd != None and receivedForDevice != False and receivedCmnd != False:
|
|
|
+ if receivedForDevice != None and receivedCmnd != None and receivedForDevice != False and receivedCmnd != False and not skipPublishing:
|
|
|
publish_device_statusupdate(receivedForDevice, receivedCmnd, receivedValue)
|
|
|
|
|
|
def decodeInterTechnoRX(rx_code):
|
|
@@ -667,7 +714,7 @@ def cul_received(payload, source_cul):
|
|
|
# split string and extract last row as we dont need the rest
|
|
|
splitPayload = payload.split(' ')
|
|
|
actualPayload = splitPayload[len(splitPayload)-1]
|
|
|
- if debug: log_write(" actualPayload: '" + actualPayload)
|
|
|
+ if debug: log_write(" actualPayload: " + actualPayload)
|
|
|
|
|
|
ignoreCommand = False
|
|
|
|