Now really fixed the issue
This commit is contained in:
@@ -43,6 +43,7 @@ class LGE320:
|
|||||||
# formula: (((b1*256)+b2)*256+b3)*256+b4
|
# formula: (((b1*256)+b2)*256+b3)*256+b4
|
||||||
#result[energy_value] = ((( watthours[0]*256 ) + watthours[1] )*256 + watthours[2])*256 + watthours[3]
|
#result[energy_value] = ((( watthours[0]*256 ) + watthours[1] )*256 + watthours[2])*256 + watthours[3]
|
||||||
result[energy_value] = int.from_bytes(watthours, "big", signed=True)
|
result[energy_value] = int.from_bytes(watthours, "big", signed=True)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
@@ -70,12 +71,14 @@ class LGE320:
|
|||||||
"P": read_buffer[read_buffer.find(b'\x07\x01\x00\x10\x07\x00\xFF'):read_buffer.find(b'\x01\x01\x01\x63')], # current power
|
"P": read_buffer[read_buffer.find(b'\x07\x01\x00\x10\x07\x00\xFF'):read_buffer.find(b'\x01\x01\x01\x63')], # current power
|
||||||
}
|
}
|
||||||
|
|
||||||
if block_zero_reads and (float(energy_values["T1"]) == 0.0 or float(energy_values["T2"]) == 0.0): # zero reads may happen when the read head is taken from the meter
|
result = self._get_energy_values(energy_values) # extract and convert binary data
|
||||||
print(f"{bcolors.WARNING}Received zero readings: {bcolors.ENDC} @{bcolors.OKBLUE}{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{bcolors.ENDC} | {bcolors.OKCYAN}T1.8.0:{bcolors.ENDC} {bcolors.BOLD}{(data['T1'])/10}{bcolors.ENDC} | {bcolors.OKCYAN}T2.8.0:{bcolors.ENDC} {bcolors.BOLD}{(data['T2'])/10}{bcolors.ENDC} | {bcolors.FAIL}Ignoring these (because of BLOCK_ZERO_READS) and waiting for 1s before trying again.{bcolors.ENDC}")
|
|
||||||
|
if block_zero_reads and (float(result["T1"]) == 0.0 or float(result["T2"]) == 0.0): # zero reads may happen when the read head is taken from the meter
|
||||||
|
print(f"{bcolors.WARNING}Received zero readings: {bcolors.ENDC} @{bcolors.OKBLUE}{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{bcolors.ENDC} | {bcolors.OKCYAN}T1.8.0:{bcolors.ENDC} {bcolors.BOLD}{(result['T1'])/10}{bcolors.ENDC} | {bcolors.OKCYAN}T2.8.0:{bcolors.ENDC} {bcolors.BOLD}{(result['T2'])/10}{bcolors.ENDC} | {bcolors.FAIL}Ignoring these (because of BLOCK_ZERO_READS) and waiting for 1s before trying again.{bcolors.ENDC}")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return self.read()
|
return self.read()
|
||||||
|
|
||||||
return self._get_energy_value(energy_values)
|
return result
|
||||||
|
|
||||||
|
|
||||||
# report data to influxdb (every 10s) and mqtt (as often as possible; when new data is received)
|
# report data to influxdb (every 10s) and mqtt (as often as possible; when new data is received)
|
||||||
|
Reference in New Issue
Block a user