From 3841c835aaf5a815f1686fcd9d1c799b75885107 Mon Sep 17 00:00:00 2001
From: sq9atk <48794340+sq9atk@users.noreply.github.com>
Date: Wed, 20 Jul 2022 08:35:03 +0200
Subject: [PATCH] =?UTF-8?q?Naprawa=20modu=C5=82u=20Radioactive?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
radioactive_sq9atk.py | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/radioactive_sq9atk.py b/radioactive_sq9atk.py
index 57f1398..a4e688e 100755
--- a/radioactive_sq9atk.py
+++ b/radioactive_sq9atk.py
@@ -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("
","
")
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("
")
+ tmpArr = string.split("
")
- 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...")