Pragmatismo/Pigrow

dht22 log format

Closed this issue · 1 comments

xevxx commented

Hi,

I added a dht22 to the system but was unable to graph the results, all entries disposed of for bad parsing. On investigation my dht22_log (adding throught the sesors modular gui was outputing in log format:

time=2020-09-27 19:22:02.292349>humid=44.9>temperature=29.8

which didn't match the expected format in the graphing script. I made it work by editing the graph script switching the order of temp/ time and adding in some new lines to parse the above format.

try:
item = logitem[curr_line]
item = item.split(">")
date = item[date_pos].split(".")
date0 = date[0]
if "=" in date[0]:
date0 = date[0].split("=")[1]
date = datetime.datetime.strptime(date0, '%Y-%m-%d %H:%M:%S')
if not oldest_allowed_date == "all":
if date < oldest_allowed_date:
print("Stopping reading log at " + str(oldest_allowed_date))
break
temp = item[temp_pos]
if "=" in temp:
temp = temp.split("=")[1]
temp = float(temp)
if temp_unit == 'f':
temp = (1.8*temp) + 32
log_temp.append(temp)
log_date.append(date)
curr_line = curr_line - 1

also changed for humidity section.

was there a better way to do this? modifying log creation commands?

thanks for the hard work

xevxx commented

adding to reddit instead