Added informative output to the zero reading stuff implemented in last commit
This commit is contained in:
@@ -71,6 +71,7 @@ class LGE320:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
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
|
||||||
|
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}")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return self.read()
|
return self.read()
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ if __name__ == "__main__": # if run from cli (not imported as a module)
|
|||||||
print(bcolors.WARNING + f"No serial port specified, trying {port}" + bcolors.ENDC)
|
print(bcolors.WARNING + f"No serial port specified, trying {port}" + bcolors.ENDC)
|
||||||
lge320 = LGE320(port)
|
lge320 = LGE320(port)
|
||||||
|
|
||||||
block_zero_reads = os.getenv('BLOCK_ZERO_READS', False)
|
block_zero_reads = os.getenv('BLOCK_ZERO_READS', True)
|
||||||
|
|
||||||
## define the clients
|
## define the clients
|
||||||
def on_connect(client, userdata, flags, reason_code, properties):
|
def on_connect(client, userdata, flags, reason_code, properties):
|
||||||
|
Reference in New Issue
Block a user