codersaur / SmartThings

Samsung SmartThings SmartApps and Device Handlers
Apache License 2.0
301 stars 540 forks source link

Problem posting influxdb #56

Open brianegge opened 4 years ago

brianegge commented 4 years ago

Probably an issue with escaping single quotes

deviceName=Andrew’s\ Bedroom\ (SPG6)

postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: [content-length:323, x-influxdb-error:unable to parse 'temperature,deviceId=387accbc-197e-401a-860b-30216863e23b,deviceName=Andrew’s\ Bedroom\ (SPG6),groupId=76973841-1133-4c88-898a-9e06934a1ad7,groupName=Dining\ Room,hubId=null,hubName=null,locationId=89a3cb26-6280-43ba-85a7-8495f9d9cc5a,locationName=Home,unit=F value=': missing field value, request-id:a2e4c97a-49ca-11ea-bdce-b827eb78a875, http/1.1 400 bad request:null, x-request-id:a2e4c97a-49ca-11ea-bdce-b827eb78a875, x-influxdb-build:OSS, content-type:application/json, date:Fri, 07 Feb 2020 16:55:25 GMT, x-influxdb-version:1.7.9], Body: {"error":"unable to parse 'temperature,deviceId=387accbc-197e-401a-860b-30216863e23b,deviceName=Andrew’s\\ Bedroom\\ (SPG6),groupId=76973841-1133-4c88-898a-9e06934a1ad7,groupName=Dining\\ Room,hubId=null,hubName=null,locationId=89a3cb26-6280-43ba-85a7-8495f9d9cc5a,locationName=Home,unit=F value=': missing field value"}

invalid number, possible powerLevel=high

postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: [content-length:349, x-influxdb-error:unable to parse '_stHub,locationId="89a3cb26-6280-43ba-85a7-8495f9d9cc5a",locationName="Home",hubId="79bdc377-ff47-4a88-ac5f-0f7dafb77fc6",hubName="Home\ Hub",hubIP="192.168.254.X" status="ACTIVE",batteryInUse=0i,uptime=nulli,zigbeePowerLevel=-6i,zwavePowerLevel="full",firmwareVersion="000.028.00012"': invalid number, request-id:9d1e32b8-49c1-11ea-b9bc-b827eb78a875, http/1.1 400 bad request:null, x-request-id:9d1e32b8-49c1-11ea-b9bc-b827eb78a875, x-influxdb-build:OSS, content-type:application/json, date:Fri, 07 Feb 2020 15:50:50 GMT, x-influxdb-version:1.7.9], Body: {"error":"unable to parse '_stHub,locationId=\"89a3cb26-6280-43ba-85a7-8495f9d9cc5a\",locationName=\"Home\",hubId=\"79bdc377-ff47-4a88-ac5f-0f7dafb77fc6\",hubName=\"Home\\ Hub\",hubIP=\"192.168.254.X\" status=\"ACTIVE\",batteryInUse=0i,uptime=nulli,zigbeePowerLevel=-6i,zwavePowerLevel=\"full\",firmwareVersion=\"000.028.00012\"': invalid number"}
brianegge commented 4 years ago

OK, something is funky with how ST posts unicode. I think it's sending the wrong content-length.

This fixed the parsing issue: str = str.replaceAll('\u2019', '\'') // Replace ’ with '.

The other was uptime=nulli. I change this to not include the uptime value if it's null.

BreeCook commented 4 years ago

52 all the crazy things in our homes now days is scary

bjQrnen commented 4 years ago

The other was uptime=nulli. I change this to not include the uptime value if it's null.

Could you please share the bit where you do the null-handling? Thanks.

bjQrnen commented 4 years ago

Nevermind, I used the fix in #33. Is there an easy way to find a fork that is more "up-to-date" on regards of the pending pull request?