Skip to content

Commit

Permalink
Follow the FVM page format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amaximus committed May 10, 2024
1 parent 234ce88 commit 75b4c2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/water_quality_fvm/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Water Quality FVM",
"documentation": "https://github.com/amaximus/water_quality_fvm",
"issue_tracker": "https://github.com/amaximus/water_quality_fvm/issues",
"version": "0.3.5",
"version": "0.3.6",
"dependencies": [],
"codeowners": ["@amaximus"],
"iot_class": "cloud_polling",
Expand Down
18 changes: 14 additions & 4 deletions custom_components/water_quality_fvm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import timedelta
import json
import logging
import re
import time
import voluptuous as vol

Expand Down Expand Up @@ -87,21 +88,30 @@ async def async_get_wqdata(self):
jsonstr += ']}'
else:
jsonstr += ','
if jsonstr is not None:
_LOGGER.debug("result: " + str(jsonstr))
if jsonstr is not None:
_LOGGER.debug("jsonstr: " + jsonstr)
wqjson = json.loads(jsonstr)
wqjson = json.loads(jsonstr.replace(',,,,',',').replace('},]}','}]}'))
return wqjson

def _get_location(region):
return region.replace('<tr><th colspan="3">','').\
replace('</th></tr>','')

def _get_wquality(wqstring):
return wqstring.replace('<tr><td class="name">','{\"name\":\"').\
replace('</td><td class="value">','\",\"value\":\"').\
replace('</td><td class="measurment">','\",\"unit\":\"').\
HTMLCOMMENT = re.compile('<!--.*-->')
wqstring1 = re.sub(HTMLCOMMENT,'',wqstring)

wqstring2 = wqstring1.replace('<tr><td class="name">','{\"name\":\"').\
replace('</td><td class="value text-right">','\",\"value\":\"').\
replace('</td></tr>','\"}')

NUMBER = re.compile('([0-9]+,*[0-9]*) ')
wqstring = re.sub(NUMBER,'\\1\",\"unit\":\"',wqstring2)

return wqstring

def _get_wq_limit(argument):
switcher = {
"Szabad aktív klór": "1000",
Expand Down
6 changes: 3 additions & 3 deletions tracker.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"water_quality_fvm": {
"version": "0.3.1",
"updated_at": "2024-03-26",
"version": "0.3.6",
"updated_at": "2024-05-10",
"visit_repo": "https://github.com/amaximus/water_quality_fvm",
"changelog": "https://github.com/amaximus/water_quality_fvm/releases/0.3.1"
"changelog": "https://github.com/amaximus/water_quality_fvm/releases/0.3.6"
}
}

0 comments on commit 75b4c2a

Please sign in to comment.