How do I get access from a client app by using PhoneGap to OpenHAB? - html

I'm developing a hybrid app (using PhoneGap) for openHAB. At the moment I'm struggling to build a connection from my hybrid to the OpenHAB runtime. Any suggestions?

The intended way to connect to the openHAB runtime is the REST API which is described in detail in the wiki (see https://github.com/openhab/openhab/wiki/REST-API).
You could also have a look at the implementations of the native Android client (see https://github.com/openhab/openhab.android) or the greenT HTML5 application based on Sencha Touch (see https://github.com/openhab/openhab/tree/master/distribution/openhabhome/webapps/greent).
Hope this helps,
Thomas E.-E.

The openhab has a REST API implemented as a bundle. this can be accessed via the URL "http://openhabip:8080/rest/".
If you want to access the items and implemet your own UI you can use "http://openhabip:8080/rest/items" with HTTP GET, POST ,PUT.
Otherwise you can use the "http://:8080/rest/sitemaps" and use the openhab provided sitemaps.
The details are in https://github.com/openhab/openhab/wiki/REST-API

Related

React Native API usage

I want to display some data from our Solarpanels within an RN App. I have no experience with fetching the data from an json api like this, and the tutorials I found online is not working in this case for some reason.
Is there anyone who can take a look at this link, and point me in the right direction?
https://www.solaredge.com/sites/default/files/se_monitoring_api.pdf
When I open the API link with our API Key, I get something like this in the browser:
{"overview":{
"lastUpdateTime":"2022-02-14 13:57:00",
"lifeTimeData":{"energy":1.7024576E8},
"lastYearData":{"energy":8955.0},
"lastMonthData":{"energy":489.0},
"lastDayData":{"energy":0.0},
"currentPower":{"power":0.0},
"measuredBy":"INVERTER"}
}
I am using Ignite by Inifite Red as a boilerplate in this app, and there some builtin APISauce function I'm not familiar with if that makes it easier.
Check import you are using of dependency which is not installed and package.json so that you have installed correctly the dependencies.

In a in WinRT app, how do I connect using TLS1.2?

I've got a Windows Store app that's a WinRT Phone/Desktop app (i.e. not a UWP app), targeting Windows 8.1 and up.
It's been on the store for several years now, but recently it stopped being able to connect with various web APIs and websites (YouTube, as well as my own site) using HTTPS.
I have a WPF version of this app as well, and this happened on that app recently as well, and to fix it I used System.Net.ServicePointManager. Unfortunately, in my WinRT environment, System.Net doesn't include ServicePointManager. In my WPF app, I did this, and it worked just fine:
ServicePointManager.ServerCertificateValidationCallback = delegate
{
Debug.WriteLine("returning true (the ssl is valid)");
return true;
};
// our server is using TLS 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
In doing some research around the internet, it seems that .NET 4.6 should include ServicePointManager, but I don't see any way to change (or even see) my version of .NET in the WinRT development environment.
I looked some more and found that a StreamSocket could be used to connect with TLS1.2... but that seems primarily designed to enable bluetooth communications, or communications to a web endpoint, but only by hostname... which is insufficient for me. I need to connect to an actual website, not just the base-level domain.
Trying this, I did the following:
StreamSocket socket = new StreamSocket();
string serverServiceName = "https";
socket.Control.KeepAlive = false;
url = "inadaydevelopment.com";
HostName serverHost = new HostName(url);
await socket.ConnectAsync(serverHost, serverServiceName, SocketProtectionLevel.Tls12);
text = await ReadDataFromSocket(socket);
I can include the code for ReadDataFromSocket() if necessary, but it seems to work, reading the data from the socket as expected when I point it at https://google.com. However, I can't seem to figure out how to point the socket at anything useful. The homepage of inadaydevelopment.com isn't what I want; I'm looking to consume a web API hosted on that server, but can't seem to find a way to do that.
Since the first parameter to the ConnectAsync() method is just HostName, the second parameter (remoteServiceName) must be the way to connect to the actual API or webpage I'm trying to connect to. According to the docs, that is The service name or TCP port number of the remote network destination... I haven't seen any example values for this parameter other than https and various numeric values, neither of which is going to get me to the API endpoint or webpage I'm trying to connect to.
So, with that super-long preamble out of the way, my question boils down to this:
Is there a way for me to use System.Net.ServicePointManager in my WinRT app like I do in my WPF app? If so, how?
If not, how can I use StreamSocket to connect to the exact web service or webpage I want to connect to, rather than just the top-level host?
If that's not possible, by what other means can I consume web content using TLS1.2?
Thanks in advance for any help or advice.
Use Windows.Web.Http API instead of System.Net.Http API.
System.Net.Http does not support TLS1.2 but Windows.Web.Http does in WinRT apps.

Polymer RESTful CRUD app

I have a Users resource that consumes and produces JSON.
I want to make RESTful calls (GET,POST,PUT,DELETE) in Polymer.
Any example app or link to resources.
I made this Polymer app for an Open Source domotic project:
https://github.com/NikZar/nautes-freedomotic-dashboard
You can take a look at my: fd-rest-element-service.html and see how it gets used in the application.
I hope this helps :)

How to do Chart on Windows Phone Universal App

I'm new Windows Phone Universal App, I need to implement bar/pie chart.
Tried many dll, Metro UI, WinRtXamlToolKit and WinRtXamlToolKit.Controls.DataVisualization
These dll are not working.
Give me good idea to do this on Windows Phone Universal App. How to do chart programmatically.
Thanks
I believe the Telerik has some Chart libraries that cost money ( can't link though as stackoverflow only permits me to post 2 links ( less than 10 rep) ). I have not used it and it is in Beta version at the moment. Google "Rad Chart windows universal apps" and you can read about it.
When I have needed charts for universal apps i have used the Google Chart Tools. You can use https://developers.google.com/chart/image/ even though Google is not developing on it anymore. It is is freakingly easy to use if you do not want to spend time drawing your own Charts. With the API you can request a chart just through a http request. You can setup almost everything and it's really easy to use thanks to the well documented API.
Here is an example of a bar chart i made using the API.
http://chart.googleapis.com/chart?chtt=Karakterfordeling&cht=bvg&chof=png&chs=300x300&chxt=x,y&chco=0076A3&chf=bg,s,65432100&hxr=0,0,50&chxl=0:|2|4|7|10|12&chxr=1,0,20&chbh=40,0,10&chd=t:2,60,70,10,90
All the arguments are passed through the http request and you can set your Chart up using the Live Chart Playground:
These are the arguments for the http request posted above. You can use the Live Chart Playground to set up parameters like below.
chtt=Karakterfordeling
cht=bvg
chof=png
chs=300x300
chxt=x,y
chco=0076A3
chf=bg,s,65432100
hxr=0,0,50
chxl=0:
2
4
7
10
12
chxr=1,0,20
chbh=40,0,10
chd=t:2,60,70,10,90
In code you set the http string as your ImageSource. You can manipulate the http string in your code and adapt the chart parameters/data if needed. I would recommend using a Converter that you bind to from you XAML. Pass your data to the converter and let it return a ImageSource with the http request. If you are new to Converters you can probably find a few posts about it here on stackoverflow.
Don't use DLLs grab the files into your project.
Add WinRTXamlToolkit.Controls.DataVisualization.csproj to your solution and reference it in the main project and add this to your page.
xmlns:charting="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
xmlns:datavis="using:WinRTXamlToolkit.Controls.DataVisualization"
Look at the samples project http://winrtxamltoolkit.codeplex.com
Unfortunately, winrtxamltoolkit is only for WinRT; VS 2013 doesn't allow adding of project references of that kind to WinPhone projects.

What is the url for Couchbase UI?

I used couchdb before and really liked the UI, because I can create views and test them directly in UI and view documents.
Because, I need to scale, I started using couchbase. But, after installing couchbase, I don't know the url of couch base client side UI.
Thank you
Just use public IP of any of the nodes in the cluster and connect to port 8091, like this http://example.com:8091
Yes it's served via 8091. But I would read through this section of the docs: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-bestpractice-cloud-ip.html; when it comes to IP's.
//Daniel
CouchDB's GUI is available at http://127.0.0.1:5984/_utils