valueStr added with quality
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Marcel Nijenhof
2021-08-30 21:41:34 +02:00
parent 6a732a33c8
commit 8d4a40389c
3 changed files with 34 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
from dateutil import tz
""" Version info changed by git hook """
__version__ = '0.1.7'
__version__ = '0.1.8'
class LmwSip:
"""Class to connect to the LMW Standard Interface prototcol (sip)
@@ -812,6 +812,33 @@ Returns:
raise LmwCmdWarn(cmdstr, d)
return (d[2:-1])
def valueStr(self, process, location, parameter, day = None,
time_of_day = None):
"""value(process, location, parameter, [day], [time_of_day]):
Parameters:
process: <WN|VW|AS>
location: <lmw location (e.g. HOEK)>
parameter: <lmw parameter (e.g. H10)>
day: [date = now()]
time_of_day: [time = now()]
The default returns the last value string including quality.
Example:
lmw.data_string("WN", "HOEK", "H10")
Returns a single string value with quality
"""
if (day == None or time_of_day == None):
last = self.lasttime(parameter)
if (day==None):
day=last["day"]
if (time_of_day==None):
time_of_day=last["time_of_day"]
return(self.cmd(process, location, parameter, "+00:00", day,
time_of_day, "DATA"))
def value(self, process, location, parameter, day = None,
time_of_day = None):
"""value(process, location, parameter, [day], [time_of_day]):
@@ -830,14 +857,7 @@ Example:
Returns a single string value or None
"""
if (day == None or time_of_day == None):
last = self.lasttime(parameter)
if (day==None):
day=last["day"]
if (time_of_day==None):
time_of_day=last["time_of_day"]
res = self.cmd(process, location, parameter, "+00:00", day,
time_of_day, "DATA")
res = self.valueStr(process, location, parameter, day, time_of_day)
value=re.sub("/.*$", "", res)
if (value == "99999"):
value=""

View File

@@ -85,6 +85,10 @@ class lmwsipTest(unittest.TestCase):
self.login()
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H1")), str)
def test_valueStr(self):
self.login()
self.assertEqual(type(self.sip.valueStr("WN", "DUMMY", "H10")), str)
def test_logout(self):
self.login()
self.assertEqual(self.sip.logout(), None)

View File

@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="lmwsip", # Replace with your own username
version="0.1.7",
version="0.1.8",
author="Marcel Nijenhof",
author_email="pip@marceln.org",
description="Interface for the lmw sip protocol",