-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhydro_data.py
59 lines (45 loc) · 1.27 KB
/
hydro_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import time
from datetime import timedelta, date
import os
import sys
import atlas_hydro
from sensor_worker import dispatch_sensor_data
hydroData = atlas_hydro.read_sensors()
def format_data():
if hydroData:
for sensor in hydroData:
if sensor["sensor_type"] == "atlas_scientific_ec":
ec_data = {
"hydro_ec": str(sensor["ec"]),
"role": sensor["sensor_type"],
"sensor_num": sensor["serial_number"],
"type": "hydro_ec"
}
dispatch_sensor_data(ec_data)
ppm_data = {
"hydro_ppm": str(sensor["ppm"]),
"role": sensor["sensor_type"],
"sensor_num": sensor["serial_number"],
"type": "hydro_ppm"
}
dispatch_sensor_data(ppm_data)
if sensor["sensor_type"] == "atlas_scientific_temp":
temp_data = {
"hydro_temp": str(sensor["sensor_reading"]),
"role": sensor["sensor_type"],
"sensor_num": sensor["serial_number"],
"type": "hydro_temp"
}
dispatch_sensor_data(temp_data)
if sensor["sensor_type"] == "atlas_scientific_ph":
ph_data = {
"hydro_ph": str(sensor["sensor_reading"]),
"role": sensor["sensor_type"],
"sensor_num": sensor["serial_number"],
"type": "hydro_ph"
}
dispatch_sensor_data(ph_data)
format_data()