Cynical Network: Parse Error

Posted on
Sat Apr 04, 2015 4:53 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Cynical Network: Parse Error

Hi There,

I'm using Cynical Network to interface with my HVAC. When I try to receive a temperature, I get an error like you see below. I think it's because the degree symbol is returned with the result. Is there anything I can do with the code to trap / fix the problem?

It should work like this...
Code: Select all
s1oat?
s1oat:050˚F


but I get this error...

Code: Select all
2015-04-04 17:20:30.244   Action Group   HVAC Get Outside Air Temperature
2015-04-04 17:20:31.502   Error   XML Parse Error: not well-formed (invalid token)
2015-04-04 17:20:31.503   Error   On character 351 of line number 1.
2015-04-04 17:20:41.513   Cynical Network Error   in runConcurrentThread: Traceback (most recent call last):
  File ".../Server Plugin/cyin/debugging.py", line 46, in diagnostic_log
    yield
  File ".../Server Plugin/cyin/debugging.py", line 56, in diagnose_call
    return method(*args, **kwargs)
  File ".../Server Plugin/cyin/asynplugin.py", line 52, in runConcurrentThread
    self.run()
  File ".../Server Plugin/asyn/inject.py", line 49, in run
    asyn.Controller.run(self)
  File ".../Server Plugin/asyn/controller.py", line 91, in run
    item._can_read()
  File ".../Server Plugin/asyn/selectable.py", line 212, in _can_read
    self._scan(input)
  File ".../Server Plugin/asyn/scan.py", line 53, in _scan
    result = self.scan.scan(self._rbuf, self.callout)
  File ".../Server Plugin/asyn/scan.py", line 108, in scan
    callout(ctx, *m.groups())
  File ".../Server Plugin/asyn/core.py", line 140, in callout
    results = [cb(ctx, *args) for cb in list(self._callbacks)]   # latch callback list
  File "plugin.py", line 140, in _event
    self.lastinput_var = matches[0]
  File ".../Server Plugin/cyin/attr.py", line 358, in __set__
    indigo.variable.updateValue(self._variable(obj), str(value))
StandardError: ServerCommunicationError -- timeout waiting for response

2015-04-04 17:20:41.513   Cynical Network Error   plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Wed Apr 22, 2015 9:46 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Cynical Network: Parse Error

Anyone have any suggestions on other ways to tackle this problem, either with a different plugin that can access the Global Cache device, or by editing this plugin? I assume that filtering high-bit characters would fix the problem, but this particular script is quite complex and I really have no clue how to deal with it.

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Mon May 11, 2015 8:34 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Cynical Network: Parse Error

A bump. Nobody has any alternate ways to tackle this problem?

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Sat May 23, 2015 1:10 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Cynical Network: Parse Error

I've not seen many users using the Cynical Network plugin, which may be why nobody has replied.

I'm not overly familiar with XML, but are you able to print what xml is being returned (not just what your expecting)?

I'm not offering to fix this, but I will offer advice.

Peter

Posted on
Sat May 23, 2015 3:11 am
kw123 offline
User avatar
Posts: 8382
Joined: May 12, 2013
Location: Dallas, TX

Re: Cynical Network: Parse Error

fist step you could try is to replace str() with unicode() in
indigo.variable.updateValue(self._variable(obj), str(value))


I guess you know how to edit the python code in a plugin: right click on plugin, show contents, go through directory , double-click on attr.py and find line 358 ..
and save, restart plugin

Karl

Posted on
Sat May 23, 2015 9:27 am
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Cynical Network: Parse Error

Hi Karl & thanks for looking at this for me! I made the change and did change the error message, so you've set me on the right track. Any thoughts on how to clear the UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 8: ordinal not in range(128) error?

Code: Select all
May 23, 2015, 10:24:47 AM
  Action Group                    HVAC Get Outside Air Temperature
  Cynical Network Error           in runConcurrentThread: Traceback (most recent call last):
  File ".../Server Plugin/cyin/debugging.py", line 46, in diagnostic_log
    yield
  File ".../Server Plugin/cyin/debugging.py", line 56, in diagnose_call
    return method(*args, **kwargs)
  File ".../Server Plugin/cyin/asynplugin.py", line 52, in runConcurrentThread
    self.run()
  File ".../Server Plugin/asyn/inject.py", line 49, in run
    asyn.Controller.run(self)
  File ".../Server Plugin/asyn/controller.py", line 91, in run
    item._can_read()
  File ".../Server Plugin/asyn/selectable.py", line 212, in _can_read
    self._scan(input)
  File ".../Server Plugin/asyn/scan.py", line 53, in _scan
    result = self.scan.scan(self._rbuf, self.callout)
  File ".../Server Plugin/asyn/scan.py", line 108, in scan
    callout(ctx, *m.groups())
  File ".../Server Plugin/asyn/core.py", line 140, in callout
    results = [cb(ctx, *args) for cb in list(self._callbacks)]   # latch callback list
  File "plugin.py", line 140, in _event
    self.lastinput_var = matches[0]
  File ".../Server Plugin/cyin/attr.py", line 358, in __set__
    indigo.variable.updateValue(self._variable(obj), unicode(value))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 8: ordinal not in range(128)

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Sat May 23, 2015 9:37 am
kw123 offline
User avatar
Posts: 8382
Joined: May 12, 2013
Location: Dallas, TX

Re: Cynical Network: Parse Error

try value.encode('utf8') instead of unicode(value)..

or value.encode('utf8')

or unicode(value,'utf8')

one of those should do it . I believe..

Posted on
Sat May 23, 2015 2:58 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Cynical Network: Parse Error

Karl, you pointed me in the right direction!

I added the ignore errors keyword and that resolved the problem enough for me. Ignore is probably bad form, but it gets the job done.

Code: Select all
      indigo.variable.updateValue(self._variable(obj), unicode(value, errors="ignore"))


Thanks!

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Mon Jun 22, 2015 10:50 am
tornado offline
User avatar
Posts: 108
Joined: Jun 30, 2014

Re: Cynical Network: Parse Error

I'm having a similar error:

Code: Select all
  Action Group                    Turn Heat Or Cool Off Upper Floor
  Error                           XML Parse Error: not well-formed (invalid token)
  Error                           On character 367 of line number 1.
  Cynical Network Error           in runConcurrentThread: Traceback (most recent call last):
  File ".../Server Plugin/cyin/debugging.py", line 46, in diagnostic_log
    yield
  File ".../Server Plugin/cyin/debugging.py", line 56, in diagnose_call
    return method(*args, **kwargs)
  File ".../Server Plugin/cyin/asynplugin.py", line 52, in runConcurrentThread
    self.run()
  File ".../Server Plugin/asyn/inject.py", line 49, in run
    asyn.Controller.run(self)
  File ".../Server Plugin/asyn/controller.py", line 91, in run
    item._can_read()
  File ".../Server Plugin/asyn/selectable.py", line 212, in _can_read
    self._scan(input)
  File ".../Server Plugin/asyn/scan.py", line 53, in _scan
    result = self.scan.scan(self._rbuf, self.callout)
  File ".../Server Plugin/asyn/scan.py", line 108, in scan
    callout(ctx, *m.groups())
  File ".../Server Plugin/asyn/core.py", line 140, in callout
    results = [cb(ctx, *args) for cb in list(self._callbacks)]   # latch callback list
  File "plugin.py", line 140, in _event
    self.lastinput_var = matches[0]
  File ".../Server Plugin/cyin/attr.py", line 358, in __set__
    indigo.variable.updateValue(self._variable(obj), str(value))
StandardError: ServerCommunicationError -- timeout waiting for response

  Cynical Network Error           plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)


I've tried
Code: Select all
   def __set__(self, obj, value):
      value.encode('utf8')   
      indigo.variable.updateValue(self._variable(obj), str(value))


but that doesn't seem to fix anything.

The string attempting to be sent is :

Code: Select all
SN2 M=OFF


Not sure why that would cause an issue but it does (only after a while. If I restart the plugin it works just fine.)

I'm not sure how to troubleshoot this issue. Again, if I click the plugin off, then on, it all works again, for an indescriminate amount of time. Any help or guidance appreciated (Python is not something I speak very well, though I am a programmer and can fudge my way around it). What would be ideal is for me to somehow be able to log what is being sent to this plugin and see which string(s) trip it up like Bollar was able to figure out...

Posted on
Mon Jun 22, 2015 10:56 am
tornado offline
User avatar
Posts: 108
Joined: Jun 30, 2014

Re: Cynical Network: Parse Error

By the way, when I change the same line that Bollar did too:

Code: Select all
      indigo.variable.updateValue(self._variable(obj), unicode(value, errors="ignore"))


I get the same error:

Code: Select all
  Action Group                    Turn Heat Or Cool Off Upper Floor
  Error                           XML Parse Error: not well-formed (invalid token)
  Error                           On character 367 of line number 1.
  Cynical Network Error           in runConcurrentThread: Traceback (most recent call last):
  File ".../Server Plugin/cyin/debugging.py", line 46, in diagnostic_log
    yield
  File ".../Server Plugin/cyin/debugging.py", line 56, in diagnose_call
    return method(*args, **kwargs)
  File ".../Server Plugin/cyin/asynplugin.py", line 52, in runConcurrentThread
    self.run()
  File ".../Server Plugin/asyn/inject.py", line 49, in run
    asyn.Controller.run(self)
  File ".../Server Plugin/asyn/controller.py", line 91, in run
    item._can_read()
  File ".../Server Plugin/asyn/selectable.py", line 212, in _can_read
    self._scan(input)
  File ".../Server Plugin/asyn/scan.py", line 53, in _scan
    result = self.scan.scan(self._rbuf, self.callout)
  File ".../Server Plugin/asyn/scan.py", line 108, in scan
    callout(ctx, *m.groups())
  File ".../Server Plugin/asyn/core.py", line 140, in callout
    results = [cb(ctx, *args) for cb in list(self._callbacks)]   # latch callback list
  File "plugin.py", line 140, in _event
    self.lastinput_var = matches[0]
  File ".../Server Plugin/cyin/attr.py", line 358, in __set__
    indigo.variable.updateValue(self._variable(obj), unicode(value, errors="ignore"))

Posted on
Wed Jul 01, 2015 10:52 am
tornado offline
User avatar
Posts: 108
Joined: Jun 30, 2014

Re: Cynical Network: Parse Error

For what it's worth, this is the code that ended up removing this issue for me:
Code: Select all
   def remove_non_ascii_1(self, text):
      return ''.join([i if ord(i) < 128 else ' ' for i in text])
      
   def __set__(self, obj, value):
      value2=self.remove_non_ascii_1(value)
      indigo.variable.updateValue(self._variable(obj), str(value2))


Basically it removes any non ASCII characters from the string before being set.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests