Author
Topic: Posting to a 3rd party server (Read 36645 times)

Starting with gateway version 400 and later, itís also possible to post data to a 3rd party server. This will allow developers to create remote services that can receive TED5000 data, without requiring end users to place their TED5000 on the internet.

To configure the TED5000 to post to a 3rd party service, the following steps will need to be executed:

1. User selects "Activate Energy Posting" from the main menu.2. User is prompted with a screen to enter 3rd party activation information:- URL of the authentication service.- Unique Identifier (provided by the 3rd party) to uniquely identify this ted on their system. This can be as simple at the GW ID, or a password - 20 character max

A disclaimer about data security will also be presented via this popup, activation means they acknowledge the privacy risks.

3. User hits submit. TED5000 makes a POST request to the 3rd party authentication service sending the unique identifier supplied in section 2.XML Sent will be:

Gateway is the hardware identifier (Serial Number) of the unit making the requestUnique is the unique identifier that was supplied in step 2. This is optional and is meant as an extra security token to be provided to the 3rd party service if they wish to use it.

PostServer- The ip address or dns resolvable name of the server (80 character max)PostPort - the port that the server is running onPostURL - the path of the service receiving the post (80 character max)UseSSL - whether or not to post data via SSLAuthToken- Unique token provided by the 3rd party used to as an authentication mechanism when data is submitted by the TED5000 (optional) (20 character max)PostRate - The number of minutes between data posts. (1 - 15)

Activation can be performed by the user more than once.

Data======================

Once activated, the TED5000 will begin to post the following data to the service defined above. The data will be in the following format:

The "MTU" element will be repeated for each MTU in the system. If the gateway is only configured for 1 MTU, this block will only be repeated once. - ID: the unique hardware id of the MTU -type: the configuration type of the mtu (0=load, 1=solar, 2=net, 3=stand-alone, 5=stand-alone-net)

The "cumulative" element will be repeated for each queued "minute" reading since the last post. The device can store up to 15 "minute" readings . If more than 15 minutes elapse between successful posts, only last 15 minutes will be resent. -timestamp is the "Unix Epoch" based timestamp of the reading. -watts is the cumulative reading in watts by the MTU (since its creation) at the specified time. Using the above example, each MTU is reporting 5watts of use since the previous minuteís data was sent (5W/min or 300W/hr (multiplied by 60))

-cost is the "rate in effect" when the reading was made.

So, in the above example, for the first MTU, the readings show that the usage is 5 watts per minute for the last 3 minutes at a rate of $0.12345).

The service should respond w/ a HTTP 200 code if successful. Any code >= 300 will be considered to be an error code.

I am new to the forum. Thanks for this post, it's very helpful, I got my TED gateway to post data to a server. There are two things where I would appreciate points:

I can not find the posting statistics, I tried /stats.htm , /stats.html and no page to be seen; where is it?

Also, I used the value 10 as post rate, but I get updates every 31 seconds. Maybe the gateway isn't happy with the way the post transactions occur / finish? HTTP/1.1 200 OKDate: Mon, 14 Mar 2011 01:16:25 GMT

I've attached an image showing where the stats box is on the stats.htm page. http://ted5000/stats.htm isn't resolving for you, you may want to try the IP address of your TED5000 instead (if you see footprints, you should be able to see stats though).

1. Would you have you considered pushing some of the other data that is available in the ted5k/livedata.xml file? Best option could be to let the user pick the fields they want as part of the activation. This data is a sample of what I was asking about:

2. Why did you choose the amount of watts since the gateway was powered vs watts since last post? Or some other factor? I am just getting into development. I suppose this value caught me off guard, but of course it is very usable.

I've attached an image showing where the stats box is on the stats.htm page. http://ted5000/stats.htm isn't resolving for you, you may want to try the IP address of your TED5000 instead (if you see footprints, you should be able to see stats though).

1. Would you have you considered pushing some of the other data that is available in the ted5k/livedata.xml file? Best option could be to let the user pick the fields they want as part of the activation. This data is a sample of what I was asking about:

Most of what is in livedata.xml (regarding power and cost) can be derived from the data we are posting.

2. Why did you choose the amount of watts since the gateway was powered vs watts since last post? Or some other factor? I am just getting into development. I suppose this value caught me off guard, but of course it is very usable.

The amount of watts we are sending is the number of watts read since the MTU left the factory. So even if you replaced gateway, the cumulative value would still be based on the MTU not the gateway.

I've been using this feature for several months and been very happy with it. I even have an open source project that I've built around it. But on June 3rd around 9pm I loaded firmware r499 (and Footprints r28) I didn't have time to check everything right after I loaded the new firmware and only now tracked down the problem to that date. Also I had forgotten to re-enable posting after the update and just did that today. But it is still not posting.

My stats.html tells me that I am getting Result "303" (which is not listed in the PDF).

Activated

Act. Status

Attempts

Success

Result

Last Timestamp

1

0

36

0

303

1372196340

I've done a restart on the unit with no improvement. Do I need to revert to the previous firmware or is there something else I can try?

EDIT: I have restored the previous version of the firmware (something that I would have called 'known good') and it's still not working. The error 303 is supposedly some sort of redirection issue, but I cannot for the life of me track that down. I can write a PHP page that tells the user what referrer he was redirected from and it says I'm making a "hard landing" (that is I was NOT redirected). My .htaccess files have not changed for over a year. I'm using a hosting service, but I can't help but wonder why it chose THAT day to change how only one of my hosted pages worked.Any ideas on how to detect a redirection - or prove that there is NOT a redirection?

EDIT2: I also have tried the hard reset using the button on the side of the unit. No joy there either.

<ted500ActivationResponse> <PostServer>http://MY_SERVER</PostServer> <PostURL>/elec/scripts/postData.php</PostURL> <UseSSL>F</UseSSL> <PostPort>80</PostPort> <AuthToken>myToken</AuthToken> <PostRate>1</PostRate> <SSLKey>NOT IMPLEMENTED</SSLKey></ted500ActivationResponse>This is my exact XML file and it worked great until the last firmware update, but on re-reading the thread for the umpteenth time I finally got it into my head to check my 500/5000 and to my horror I see that I had "500" and NOT "5000" in my XML.

If the latest firmware got around to actually checking the XML framing then mine woudl have been rejected. Although no explanation why it would have told me that is successfully set up the contact.