-
Notifications
You must be signed in to change notification settings - Fork 0
/
SensorMeteo.py
48 lines (32 loc) · 1.12 KB
/
SensorMeteo.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
#!/usr/bin/env python
##
# @package SensorMeteo Package contains the method to create the CSV payload for METEO sensor
#
import logging
from ModbusConsts import ModbusConsts
class SensorMeteo:
LOG = logging.getLogger( __name__ )
##
#
def getMeteoPayload( self, decodedData, recordTime ):
labels = []
values = []
slaveId = decodedData.get( ModbusConsts.SLAVE_ID )
try:
data = decodedData.get( ModbusConsts.DATA )
print("data in CSV: ", data)
if "IRRADIANCE" in data:
value = data.get( "IRRADIANCE" )
labels.append(f'IRRADIANCE_{slaveId}')
values.append(value)
if "CELL_TEMP" in data:
value = data.get( "CELL_TEMP" )
labels.append(f'CELL_TEMP_{slaveId}')
values.append(value)
if "EXT_TEMP" in data:
value = data.get( "EXT_TEMP" )
labels.append(f'EXT_TEMP_{slaveId}')
values.append(value)
except Exception as e:
pass
return (labels,values)