Skip to content

Commit

Permalink
remove ct1 and Msg check, check for valid alphanumeric input name and…
Browse files Browse the repository at this point in the history
… numeric value instead
  • Loading branch information
glynhudson committed Feb 19, 2018
1 parent 4577dcb commit 7aae5e9
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/interfacers/EmonHubTx3eInterfacer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import serial
import time
import Cargo
import re
from emonhub_interfacer import EmonHubInterfacer

"""class EmonHubTx3eInterfacer
Expand Down Expand Up @@ -90,17 +91,27 @@ def read(self):
# Parse the ESP format string
values=[]
names=[]
if f.startswith('Msg:') or f.startswith('ct1:'):
for item in f.split(',')[:]:

for item in f.split(','):
parts = item.split(':')
names.append(parts[0])
values.append(parts[1])

self._log.debug(self._settings["nodename"])
if len(parts)==2:
# check for alphanumeric input name
if re.match('^[\w-]+$',parts[0]):
# check for numeric value
if parts[1].isdigit():
names.append(parts[0])
values.append(parts[1])
# log errors
else: self._log.debug("input value is not numeric: "+parts[1])
else: self._log.debug("invalid input name: "+parts[0])

c.nodename = self._settings["nodename"]
c.nodeid = self._settings["nodename"]
c.realdata = values
c.names = names

if len(values)==0:
return False

return c

Expand Down

0 comments on commit 7aae5e9

Please sign in to comment.