kopia lustrzana https://github.com/sq9atk/sr0wx
Naprawa modułu Radioactive
rodzic
f894a0f857
commit
3841c835aa
|
@ -31,12 +31,12 @@ class RadioactiveSq9atk(SR0WXModule):
|
|||
return ""
|
||||
|
||||
def isSensorMatchedById(self, sensorId, string):
|
||||
pos = string.find(","+str(sensorId)+", ")
|
||||
pos = string.find("Details sensor "+str(sensorId))
|
||||
return pos >= 0
|
||||
|
||||
def isSensorRow(self, string):
|
||||
string = " "+string # na początku trzeba dodac spację bo inaczej find nie znajduje pierwszego znaku
|
||||
pos = string.find("Overlay(createMarker(")
|
||||
pos = string.find("Last sample")
|
||||
return pos >= 0
|
||||
|
||||
def cleanUpString(self, string):
|
||||
|
@ -44,37 +44,31 @@ class RadioactiveSq9atk(SR0WXModule):
|
|||
string = string.replace("<br>","<br/>")
|
||||
string = string.replace("'","")
|
||||
|
||||
string = string.replace("Last contact: ","")
|
||||
string = string.replace("Overlay(createMarker(new GLatLng","")
|
||||
string = string.replace(" Last sample: ","")
|
||||
string = string.replace("24 hours average: ","")
|
||||
string = string.replace(" uSv/h","")
|
||||
|
||||
string = string.replace("(","")
|
||||
string = string.replace(")","")
|
||||
return string
|
||||
|
||||
def prepareSensorData(self, string):
|
||||
def extractSensorData(self, string):
|
||||
string = self.cleanUpString(string)
|
||||
arr = string.split("<br/>")
|
||||
tmpArr = string.split("<br/>")
|
||||
|
||||
arrPart = arr[0].split(",")
|
||||
arr += arrPart
|
||||
return arr
|
||||
arrPart = tmpArr[0].split(".bindPopup(")
|
||||
tmpArr[0] = arrPart[1]
|
||||
|
||||
tmpCurrent = tmpArr[0].split("Last sample: ");
|
||||
tmpAverage = tmpArr[2].split("24 hours average: ");
|
||||
|
||||
current = tmpCurrent[1].split(" ")[0]
|
||||
average = tmpAverage[1].split(" ")[0]
|
||||
|
||||
return {"current":current, "average": average}
|
||||
|
||||
def getSensorData(self, html):
|
||||
dataArr = html.split("map.add")
|
||||
data = {}
|
||||
|
||||
dataArr = html.split("L.marker([")
|
||||
ret = {}
|
||||
for row in dataArr:
|
||||
if self.isSensorRow(row):
|
||||
if self.isSensorMatchedById(self.__sensor_id, row):
|
||||
sensorDataArr = self.prepareSensorData(row)
|
||||
|
||||
data['time'] = sensorDataArr[1]
|
||||
data['current'] = sensorDataArr[10]
|
||||
data['average'] = sensorDataArr[2]
|
||||
return data
|
||||
ret = self.extractSensorData(row)
|
||||
return ret
|
||||
|
||||
def get_data(self):
|
||||
self.__logger.info("::: Pobieram dane...")
|
||||
|
|
Ładowanie…
Reference in New Issue