webdeck / homebridge-indigo

Homebridge Plugin for Indigo
Apache License 2.0
13 stars 6 forks source link

Actions: Unexpected token #2

Closed flic closed 8 years ago

flic commented 8 years ago

As requested, here's how the plugin chokes on my actions:

[Indigo] Error parsing Indigo response for /actions.json/ Exception: SyntaxError: Unexpected token


, {
    "name": "Total watt

fas1=indigo.devices[920690105].states["curEnergyLevel"] fas2=indigo.devices[1651950809].states["curEnergyLevel"] fas3=indigo.devices[476244226].states["curEnergyLevel"]

subprocess.call(["/opt/local/bin/rrdtool","update","/Users/Shared/rrd/watt.rrd","N:"+str(fas1)+":"+str(fas2)+":"+str(fas3)]) ", "nameURLEncoded": "Total%20watt%0A%0Afas1%3Dindigo.devices%5B920690105%5D.states%5B%22curEnergyLevel%22%5D%0Afas2%3Dindigo.devices%5B1651950809%5D.states%5B%22curEnergyLevel%22%5D%0Afas3%3Dindigo.devices%5B476244226%5D.states%5B%22curEnergyLevel%22%5D%0A%0Asubprocess.call%28%5B%22%252Fopt%252Flocal%252Fbin%252Frrdtool%22%2C%22update%22%2C%22%252FUsers%252FShared%252Frrd%252Fwatt.rrd%22%2C%22N%3A%22%2Bstr%28fas1%29%2B%22%3A%22%2Bstr%28fas2%29%2B%22%3A%22%2Bstr%28fas3%29%5D%29%0A", "restParent": "actions", "restURL": "/actions/Total%20watt%0A%0Afas1%3Dindigo.devices%5B920690105%5D.states%5B%22curEnergyLevel%22%5D%0Afas2%3Dindigo.devices%5B1651950809%5D.states%5B%22curEnergyLevel%22%5D%0Afas3%3Dindigo.devices%5B476244226%5D.states%5B%22curEnergyLevel%22%5D%0A%0Asubprocess.call%28%5B%22%252Fopt%252Flocal%252Fbin%252Frrdtool%22%2C%22update%22%2C%22%252FUsers%252FShared%252Frrd%252Fwatt.rrd%22%2C%22N%3A%22%2Bstr%28fas1%29%2B%22%3A%22%2Bstr%28fas2%29%2B%22%3A%22%2Bstr%28fas3%29%5D%29%0A.json" }


It's an action group of type Execute script (embedded Python). The name of the action group is "total watt", the rest of the text above seems to be the script itself, URL encoded.

If I disable this action group for remote view it all works. It's not at all necessary for me to have it enabled so for my purposes the problem is solved, but it might be of interest to you.

webdeck commented 8 years ago

This is a bug with Indigo's RESTful API returning invalid JSON. Please submit a bug report to Indigo so that they can fix it in a future version. As a fix here, I've updated the plugin to ignore any devices that have invalid JSON, so it at least discovers the rest of your devices without erroring out.