New Plugin: GhostXML

Posted on
Mon Mar 26, 2018 7:49 pm
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Scratch that. There was a bug with new devices when using basic auth (and maybe digest, too). I've uploaded v0.3.17 to the Indigo Plugin Store which should fix the problem. Please download and try that version instead.

I still believe that basic auth is what you're after.

Posted on
Tue Mar 27, 2018 9:04 pm
hamw offline
Posts: 1070
Joined: Mar 31, 2008

Re: New Plugin: GhostXML

Gave it a try but still no joy. Here is the log:

Code: Select all
   GhostXML                        There was a parse error. Check XML source.
   GhostXML Debug                  Device needs updating set to: True
   GhostXML Debug                  getDeviceStateList() method called.
   GhostXML Debug                  Pulling down existing state list.
   GhostXML Debug                    Writing dynamic states to device.
   GhostXML Debug                  No new states found.
   GhostXML Debug                  Device needs updating set to: False
   GhostXML Debug                  parseStateValues() method called.
   GhostXML Debug                  Writing device states:
   GhostXML Debug                     Response = Parse error. Check XML source.
   GhostXML Debug                  Digital Loggers Switch updated.

Mar 27, 2018, 10:59:02 PM
   GhostXML Debug                  Time since update (17) is greater than configured frequency (15)
   GhostXML Debug                  Queue task 409167487 sent to thread 409167487 - Digital Loggers Switch
   GhostXML Debug                  refreshDataForDev() method called.
   GhostXML Debug                  Found configured device: Digital Loggers Switch
   GhostXML Debug                  Refreshing device: Digital Loggers Switch
   GhostXML Debug                  getTheData() method called.
   GhostXML Debug                  *   Trying 10.0.1.XX...
* TCP_NODELAY set
* Connected to 10.0.1.XX (10.0.1.XX) port XXXX (#0)
* Server auth using Basic with user 'admin'
> GET /restapi/relay/outlets/all/state/=name,physical_state/ HTTP/1.1
> Host: 10.0.1.XX:XXXX
> Authorization: Basic YWRtaW46NDU2Q2FtM3JhWg==
> User-Agent: curl/7.51.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Connection: close
< Content-Type: text/html
< Cache-Control: No-cache, no-store, must-revalidate, max-age=0
< Expires: Mon, 01 Jan 1990 00:00:01 GMT
< Pragma: no-cache
< Set-Cookie: DLILPC=""; Version=1; Max-Age=0; Path=/
<
{ [99 bytes data]
* Recv failure: Connection reset by peer
* Curl_http_done: called premature == 1
* Closing connection 0

   GhostXML Debug                  Source file type: XML
   GhostXML Debug                  stripNamespace() method called.
   GhostXML Debug                  <HTML><HEAD>

<META HTTP-EQUIV="refresh" content="0; URL=/index.htm">

</HEAD><BODY></BODY>
</HTML>
   GhostXML                        There was a parse error. Check XML source.
   GhostXML Debug                  Device needs updating set to: True


Other ideas? Does the request need to be reconfigured?

Posted on
Wed Mar 28, 2018 3:52 am
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Looks like you're on the right track and this line is promising:
Code: Select all
< HTTP/1.0 200 OK


What happens if you put the URL structure from your AppleScript directly into a web browser?
Code: Select all
http://usesr:pwd@10.0.1.XX:XXXX/outlet?

Posted on
Thu Mar 29, 2018 6:13 pm
hamw offline
Posts: 1070
Joined: Mar 31, 2008

Re: New Plugin: GhostXML

Well, when simply put in a web browser it returns the login screen, with the username and PW boxes. Maybe that's where it is getting hung up. But, it seems like the instructions would let you use the RestAPI to pull the info? I also put the Rest string in there and had the same result.

Posted on
Thu Mar 29, 2018 7:24 pm
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Based on this... Try setting up a device with digest auth and the url

Code: Select all
http://192.168.0.123/restapi/


Of course replacing the IP address with that of your device.
Attachments
Screen Shot 2018-03-29 at 8.06.56 PM.png
Screen Shot 2018-03-29 at 8.06.56 PM.png (92.81 KiB) Viewed 343 times

Posted on
Sat Apr 28, 2018 6:07 am
hamw offline
Posts: 1070
Joined: Mar 31, 2008

Re: New Plugin: GhostXML

I did as suggested and it made a slight difference:

Code: Select all
* TCP_NODELAY set
* Connected to 10.0.1.45 (10.0.1.45) port 8200 (#0)
* Server auth using Basic with user 'admin'
> GET /restapi HTTP/1.1
> Host: 10.0.1.45:8200
> Authorization: Basic YWRtaW46NDU2Q2FtM3JhWg==
> User-Agent: curl/7.51.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Connection: close
< Content-Type: text/html
< Cache-Control: No-cache, no-store, must-revalidate, max-age=0
< Expires: Mon, 01 Jan 1990 00:00:01 GMT
< Pragma: no-cache
< Set-Cookie: DLILPC=""; Version=1; Max-Age=0; Path=/
<
{ [99 bytes data]
* Curl_http_done: called premature == 0                       <<<<<<<
* Closing connection 0

   GhostXML Debug                  Source file type: XML
   GhostXML Debug                  stripNamespace() method called.
   GhostXML Debug                  <HTML><HEAD>


At this line "called premature" formerly == 1

Progress?

Posted on
Sat Apr 28, 2018 7:22 am
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Definitely progress, but from the return, it looks like you're using basic auth instead of digest auth. Do you have the device set to use digest where the server is returning a message that basic is being used?

Posted on
Thu May 03, 2018 6:12 am
qcvictor offline
Posts: 70
Joined: Apr 23, 2015
Location: Quebec, Canada

Re: New Plugin: GhostXML

Hi DaveL17
Have some trouble with json import, device stay stuck on "Processing" and no refresh anymore,
This the json output:
{"System":{
"Build":20102,
"Git Build":"mega-20180429",
"Local time":"2018-05-03 08:05:53",
"Unit":7,
"Name":"Wemos Pool Controller",
"Uptime":4671,
"Load":26,
"Load LC":11282,
"Free RAM":17912
},
"WiFi":{
"Hostname":"Wemos-Pool-Controller-7",
"IP config":"DHCP",
"IP":"10.0.0.XX",
"Subnet Mask":"255.255.255.0",
"Gateway IP":"10.0.X.X",
"MAC address":"5C:CF:7F:F0:28:8A",
"DNS 1":"10.0.X.X",
"DNS 2":"X.X.X.X",
"SSID":"XXXXXXXX",
"BSSID":"F0:9F:C2:A4:AE:EF",
"Channel":1,
"Connected msec":136965665,
"Last Disconnect Reason":201,
"Last Disconnect Reason str":"(201) No AP found",
"Number reconnects":26,
"RSSI":-53
},
"Sensors":[
{
"TaskNumber":1,
"Type":"Analog input - ADS1115",
"TaskName":"pH",
"TaskValues": [
{"ValueNumber":1,
"Name":"pH",
"Value":11.50}]
},
{
"TaskNumber":2,
"Type":"Analog input - internal",
"TaskName":"Pressure Filter",
"TaskValues": [
{"ValueNumber":1,
"Name":"Bar",
"Value":0.91}]
},
{
"TaskNumber":3,
"Type":"Display - LCD2004",
"TaskName":"Screen"},
{
"TaskNumber":4,
"Type":"Analog input - ADS1115",
"TaskName":"Orp",
"TaskValues": [
{"ValueNumber":1,
"Name":"Orp",
"Value":171.51}]
},
{
"TaskNumber":5,
"Type":"Switch input - Switch",
"TaskName":"PIR",
"TaskValues": [
{"ValueNumber":1,
"Name":"Switch",
"Value":0}]
},
{
"TaskNumber":6,
"Type":"Environment - DS18b20",
"TaskName":"Temperature",
"TaskValues": [
{"ValueNumber":1,
"Name":"Temperature",
"Value":9.06}]
},
{
"TaskNumber":7,
"Type":"Generic - Pulse counter",
"TaskName":"Water Flow",
"TaskValues": [
{"ValueNumber":1,
"Name":"Count",
"Value":0.00},
{"ValueNumber":2,
"Name":"Total",
"Value":0.00},
{"ValueNumber":3,
"Name":"Time",
"Value":0.00}]
},
{
"TaskNumber":9,
"Type":"Generic - Dummy Device",
"TaskName":"Test",
"TaskValues": [
{"ValueNumber":1,
"Name":"[Pressure Filter#Bar]+10",
"Value":0.00},
{"ValueNumber":2,
"Name":"Pressure Filter#Bar +10",
"Value":0.00},
{"ValueNumber":3,
"Name":"",
"Value":0.00},
{"ValueNumber":4,
"Name":"",
"Value":0.00}]
}
]
}

Output from debug:
Code: Select all
3 mai 2018 07:58:44
   GhostXML                        Debugging on.
   GhostXML Debug                  Debug level: 1

3 mai 2018 07:58:59
   GhostXML Debug                  Device has been updated. Blow state list up to Trigger and Control Page labels.
   GhostXML Debug                  validateDeviceConfigUi() method called.
   GhostXML Debug                  Device has been updated. Blow state list up to Trigger and Control Page labels.
   GhostXML Debug                  Stopping GhostXML device: ESP8266 Pool Level (json)
   GhostXML Debug                  Starting GhostXML device: ESP8266 Pool Level (json)
   GhostXML Debug                  Device has been updated. Blow state list up to Trigger and Control Page labels.
   GhostXML Debug                  Time since update (695) is greater than configured frequency (15)
   GhostXML Debug                  Found configured device: ESP8266 Pool Level (json)
   GhostXML Debug                  Refreshing device: ESP8266 Pool Level (json)
   GhostXML Debug                  *   Trying 10.0.0.56...
* TCP_NODELAY set
* Connected to 10.0.0.56 (10.0.0.56) port 80 (#0)
> GET /json HTTP/1.1
> Host: 10.0.0.56
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 242
< Connection: close
< Access-Control-Allow-Origin: *
<
{ [242 bytes data]
* Closing connection 0

   GhostXML Debug                  Source file type: JSON
   GhostXML Debug                  Device needs updating set to: True
   GhostXML Debug                  Pulling down existing state list.
   GhostXML Debug                    Writing dynamic states to device.
   GhostXML Debug                  Device needs updating set to: False

Posted on
Thu May 03, 2018 11:57 am
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Took me a while, but I figured out what the issue is.

Some of the source json keys contain spaces (which I don't believe is good form) but when I updated the plugin to contend with the spaces, it then parses successfully. It's a wonder that this particular problem has taken this long to surface.

I'll post an update to the plugin later tonight (North America time). You should then be in business.

Posted on
Thu May 03, 2018 6:16 pm
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

I just released a new version of the plugin to the Indigo Plugin Store that should be able to handle your JSON feed.

Posted on
Fri May 04, 2018 3:35 am
qcvictor offline
Posts: 70
Joined: Apr 23, 2015
Location: Quebec, Canada

Re: New Plugin: GhostXML

Hi Dave
Thanks you so much for your great job and support, it's working now.
Vic

Posted on
Fri May 04, 2018 3:54 am
DaveL17 offline
User avatar
Posts: 3842
Joined: Aug 20, 2013

Re: New Plugin: GhostXML

Excellent. Thanks for letting me know.

Who is online

Users browsing this forum: No registered users and 1 guest