Skip to content

Commit

Permalink
Add new sensors (lightning, weird avg10m wind stuff)
Browse files Browse the repository at this point in the history
  • Loading branch information
garbled1 committed Jul 18, 2020
1 parent 1ad5e8b commit 79dba37
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
55 changes: 41 additions & 14 deletions pyecowitt/ecowitt.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,25 @@ def convert_units(self, data):
data["humidity"] = int(data["humidity"])
if "winddir" in data:
data["winddir"] = int(data["winddir"])
if "winddir_avg10m" in data:
data["winddir_avg10m"] = int(data["winddir_avg10m"])
if "uv" in data:
data["uv"] = int(data["uv"])
if "solarradiation" in data:
data["solarradiation"] = float(data["solarradiation"])

# lightning
if "lightning_time" in data:
if (data["lightning_time"] is not None and
data["lightning_time"] != ''):
data["lightning_time"] = int(data["lightning_time"])
if "lightning_num" in data:
data["lightning_num"] = int(data["lightning_num"])
if "lightning" in data:
if (data["lightning"] is not None and
data["lightning"] != ''):
data["lightning"] = int(data["lightning"])

# temperatures
if "tempf" in data:
data["tempf"] = float(data["tempf"])
Expand Down Expand Up @@ -144,6 +158,12 @@ def convert_units(self, data):
data["maxdailygust"] = float(data["maxdailygust"])
data["maxdailygustkmh"] = round(data["maxdailygust"] * mph_kmh, 2)
data["maxdailygustms"] = round(data["maxdailygust"] * mph_ms, 2)
if "windspdmph_avg10m" in data:
data["windspdmph_avg10m"] = float(data["windspdmph_avg10m"])
data["windspdkmh_avg10m"] = float(data["windspdmph_avg10m"]
* mph_kmh, 2)
data["windspdms_avg10m"] = float(data["windspdmph_avg10m"]
* mph_ms, 2)

# distances
if "rainratein" in data:
Expand Down Expand Up @@ -205,23 +225,30 @@ def convert_units(self, data):
data[pma] = float(data[pma])

# Batteries
if "wh68batt" in data:
data["wh68batt"] = float(data["wh68batt"])
if "wh40batt" in data:
data["wh40batt"] = float(data["wh40batt"])
if "wh26batt" in data:
data["wh26batt"] = float(data["wh26batt"])
if "wh65batt" in data:
data["wh65batt"] = float(data["wh65batt"])
for j in range(1, 9):
sm = f"soilbatt{j}"
if sm in data:
data[sm] = float(data[sm])
for j in range(1, 9):
sm = f"batt{j}"
bat_names = [
"wh68",
"wh40",
"wh26",
"wh65",
"wh57",
]
bat_range_names = [
"soil",
"", # for just 'batt'
"pm25",
]

for prefix in bat_names:
sm = f"{prefix}batt"
if sm in data:
data[sm] = float(data[sm])

for r_prefix in bat_range_names:
for j in range(1, 9):
sm = f"{r_prefix}batt{j}"
if sm in data:
data[sm] = float(data[sm])

return(data)

async def handler(self, request: web.BaseRequest):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def readme():


setup(name='pyecowitt',
version='0.8',
version='0.9',
description='Module to communicate with the Ecowitt procotol',
long_description='Module to communicate with the Ecowitt protocol',
url='https://github.com/garbled1/pyecowitt',
Expand Down

0 comments on commit 79dba37

Please sign in to comment.