While the Xively API documentation and Libraries provide a good resource to read and write to Xively feeds and datastreams I cant seem to find a reference how to compose a https request to update a single datapoint. For Example: To code a "button" on a web page that can change the value of a data point from 1 to 0, which triggers an action on the device that is connected to/with this Feed. i.e to compose a request directly in a browser to obtain the desired effect.. I am very new to this and any guidance to this would be appreciated.
Asked
Active
Viewed 288 times
1 Answers
0
You should use XivelyJS.
There is a full example of a webpage which uses WebSockets.
It's very easy to use.
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/xively-js/1.0.4/xivelyjs.min.js"></script>
<script>
// Set your API key first
xively.setKey( "YOUR_KEY_HERE" );
xively.datastream.update( "YOUR_FEED_ID", "test_datastream", 123, function( event, data ) {
console.log( data.current_value ); // Logs value changes in realtime
});
</script>

errordeveloper
- 6,716
- 6
- 41
- 54
-
Thanks for the link that looks like it may just work. Not all functionality appears to be working after porting to my own xively feed however.. – user2490395 Jun 26 '13 at 15:14
-
Were you trying the sample app or something else? – errordeveloper Jun 26 '13 at 16:41
-
Used the sample app with my own credentials/feeds and the like. – user2490395 Jun 26 '13 at 21:04
-
I suppose that some channels need to be created with initial values set before you hook up the JS app to it... Have you checked the console logs in your browser? – errordeveloper Jun 26 '13 at 22:00
-
The feed are realtime sensors being updated every 30 seconds. The console log shows that some .png's are not loading as I did not import them into the file.The use.typekit.net files are not loaded as their location address is pointing to my local file (from where I am testing from) yet with a http address appended. Have checked the hrefs's they seem correct.. However when I change the temp on the app's interface the console shows the creation of a Temperature.json file. When I toggle the switches it does not. I am sure that I am overlooking something, appreciate any feedback.. – user2490395 Jun 27 '13 at 10:22
-
Had a chance to look into this a bit more: I reverted the naming of the "light" switch back to the original version called "light" Upon doing so the console showed the creation of a light.json file, however nothing happened. In the mean time having changed the settings for the "music/ volume to my own feed was successful. It apears that the "switches" have some code in a file that does not allow their variables to be changed...I am sorry for not being able to perhaps use the right terminology I hope that my finding are helpfull to this great interface!!! – user2490395 Jun 27 '13 at 16:45