How to get set temperature? - javascript

I would like to get the current temperature set on heat mode of the Nest thermostat (not the ambient measure temperature).
Is there a way to do that from Google Scripts?
I looked at the Google Apps scripts documentation but found nothing about this.

I did it! I used this code (by chance):
var settemp = device['traits']['sdm.devices.traits.ThermostatTemperatureSetpoint']['heatCelsius'];
Logger.log('settemp' + settemp);

Related

I want to use google maps with pins on locations and when I click a certain button i want to go to that location. .NET

I've been searching for this quite a bit and cannot seem to find it anywhere online.
The background story: I am making a .NET windows forms C# application and I have a couple of listbox items that I want to have the following functionality:
When I click on the listbox item I want the map to go to that location with a pin attached to these longitude and latitude coordinates.Also I would like a certain zoom. I would be very thankful is someone could give some information if this is possible.
It would be great if there would exist functions that do this.
Also I want to add a new function to add a new location, that when I add a pin to the map I get the longitude and latitude coordinates back somehow.
I understand events and all that btw, I just don't know how to use any possible functions, that google maps provides for .NET framework.
Google maps API is browser API (javascript) as #Mr. J pointed out.
There are third party API's that can be used
https://github.com/ericnewton76/gmaps-api-net
GoogleSigned.AssignAllServices(new GoogleSigned(gmapsApiKey));
var map = new StaticMapRequest();
map.Center = new Location("1600 Amphitheatre Parkway Mountain View, CA 94043");
map.Size = new System.Drawing.Size(imgGoogleResult.Width, imgGoogleResult.Height);
map.Zoom = 14;
map.Sensor = false;
Uri imgURI = map.ToUri();
imgGoogleResult.ImageLocation = imgURI.AbsoluteUri;

Weird behaviour leaflet and Shiny

I have a shiny app which uses the leaflet library.
I need now to use the get.Bounds() function to get some coordinates. Easy enough (js file):
var myBounds = map.getBounds();
console.log(myBounds);
Then I need to send the coordinates to shiny for further processing (also in my js file:
Shiny.onInputChange("bounds", myBounds);
To see if that worked, it did in the server.R this:
observe({
print(input$bounds)
})
However, when I run the app in the R console appears NULL. Through the console.log in my .js file the coordinates are printed in the Firefox console.
BUT, it works every now and then. When I run the Shiny App ten times, it works sometimes three times, sometimes four times and sometimes never. I get the coordinates and they get printed into the R console.
I tried with reactive too, but that dod not do the trick. Same behaviour here.
#get extensions of map
myBoundsR <- reactive({
input$bounds
})
#print extensions
observe(print(myBoundsR()))
Why is that?! Why is the behaviour that inconsequent?! Why doesnt the line Shiny.onInputChange("bounds", myBounds); send the coordinates to server.R?
You might want to change it like this:
map.on('moveend', function(e) {
var myBounds = map.getBounds();
Shiny.onInputChange("bounds", myBounds);
console.log(myBounds);
});
It might be the problem that the extends of the window are not send for the "starting window"?! Thats just a guess though. I cannt find anything on that. And since the js is only gone through once, from top to bottom, the code only gets executed once.
Writing it this way, it should work when you pan/zoom?!
Let me know if that helped you!

ReferenceError: "document" is not defined

Im new to JavaScript and even more new to Google Apps Script. Im trying a simple function that shows the current date (only day, month e and full year), but the Google Script show the error ReferenceError: "document" is not defined.
My goal is to use this function in a Google Site. Here is the code:
function Data()
{
var d=new Date();
var dia=d.getDate();
var mes=d.getMonth();
var ano=d.getFullYear();
var DataCompleta=dia + "/" + mes + "/" + ano
document.write(DataCompleta);
}
Code running as a Google Apps Script does not run in the browser, so you cannot use web browser APIs with it. If you want to output content to a Google Site, then you need to use the API for Sites.
Presumably you would want something like createWebPage and then use the methods on the resulting object to add the content to it.
As said in the former answer you can't execute a function directly in the Browser, you'll have to choose a so called 'container' to run your function from it. I would recommand you read the documentation and maybe try a few simple tutorials to see how GAS can be executed.
EDIT : following your comments, feel free to have a look at this script built with UiApp, the result is viewable here and shows what you wanted to : "Hello, today is 25/10/2012"

Issuing MySQL queries from standalone Javascript (no, I'm not crazy, my vendor is)

Our lab recently got an Agilent Bravo pipetting robot (it precisely dispenses tiny quantities of liquid for doing rapidly doing many biology or chemistry experiments). Apparently the glue language for extending the software that controls the robot is Javascript! I know, right?
Anyway, for the robot to be useful, we have to be able to retrieve information about the samples it's handling but every example I can find for sending queries in Javascript depends on PHP and usually the assumption that the script is running in a web-browser.
Is there some way to wrap a command-line mysql or is there already some library or utility that does this? The OS we're running is Windows 7.
Wow, thanks for the quick and useful answers.
In addition, I found a platform-specific answer: http://www.velocity11.com/techdocs/helpsystem/vworks_ug/usingjavascriptinvworks.html
Long story short, VWorks (control software for Agilent's equipment) has a run() global function that does exactly that. But, the above answers are probably more useful to this site than my own is, because they are relevant to a broader range of problems, so thanks again.
"sending queries in Javascript depends on PHP"
no it doesn't.
Just send retreive data(json) using ajax, I'd use http://api.jquery.com/jQuery.ajax/.
Yes, you can use ADO with Javascript on Windows to access various data sources. Search for "jscript ado" and you will get lots of information on this, e.g.:
// path to database
var DBpath="\\\\Server\\Path\\myDB.mdb"
// set up a few object constants
var adLockReadOnly=1
var adOpenForwardOnly=0
var adCmdText=1
// create and open a new connection (MSAccess)
var cnn=new ActiveXObject("ADODB.connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" + DBpath
try
{
cnn.open
}
catch(err)
{
// could not open connection
// view details in err.Description and err.Number
return 0
}
//open a read only recordset
var rs = new ActiveXObject("ADODB.Recordset")
try
{
rs.Open("Select * from myTable", cnn, adOpenForwardOnly, adLockReadOnly)
}
catch(err)
{
// could not open recordset
return 0
}
while(!rs.EOF)
{
// do something
rs.movenext
}
rs.close
Update:
According to info here, you can develop plugins using Visual Studio/C#. Maybe that is of some use? You could write a plugin to send the data somewhere...

Controlling Clustered Pushpin's VEShape in VE SDK 6.2

Preface
I'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, so this question is specifically related to using the clustering feature of the VE 6.2 SDK.
The Problem
After enabling the built-in clustering (via VEShapeLayer.SetClusteringConfiguration), the clusters are created as expected, however, they have the default information in them which says something like "X items located here - zoom in to see details". In the app I'm working on, I need to display more information than that - I either need to allow the user to click on the pushpin and VE will automatically zoom in so that the points are now distinct OR display the names of the points in the infobox attached to the cluster pushpin. The catch is that cluster shape that VE creates for me does not appear to be editable until after all of the clustering logic has run...at that point, I don't know what original pushpins belong to that particular cluster. Is there a way to make this happen without resorting to creating a custom clustering implementation?
In case others have this same issue, the answer was just posted over in the MSDN forum for VE:
http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/d55090e2-2f5c-459c-9ecd-c3f32f0505b3/
We're doing precicely what I think you are asking for... Try this
// Create your map
var MapCtl = new VEMap('MapContainer');
// Create a layer for your pins
MapPinLayer = new VEShapeLayer();
// Add a callback that gets called every time the cluster config changes
var clusteringOptions = new VEClusteringOptions();
clusteringOptions.Callback = clusterCallback;
MapPinLayer.SetClusteringConfiguration(VEClusteringType.Grid, clusteringOptions);
// your cluster callback method
function clusterCallback(clusters) {
for (var i = 0; i < clusters.length; ++i) {
var cluster = clusters[i];
var clusterShape = cluster.GetClusterShape();
var clusterSize = cluster.Shapes.length;
clusterShape.SetTitle('Some Title');
clusterShape.SetDescription('There's ' + clusterSize + ' shops in this area');
}
}

Categories

Resources