I wrote a code to control Nature Remo in C# because I saw the article about Sony DSC-QX10 that I wrote in the past.
I bought Nature Remo mini on impulse.
Simple.
Nature Remo is in simple box.
Nature Remo mini is a bit bigger than Airpods.
The cause of impulse buying is the following article. I wanted to control Nature Remo mini like Sony DSC-QX10.
I would like to operate Nature Remo mini with C # referring to the blog above and the Nature Remo API. Based on the following sources used in the operation of Sony DSC-QX10, I will change it to Nature Remo mini version.
static async void DoPost() { string jsonparams = "{\"method\": \"actTakePicture\"," + "\"params\": []," + "\"id\": 1," + "\"version\": \"1.0\"}";
string url = "http://10.0.0.1:10000/sony/camera"; var httpclient = new HttpClient(); var jsoncontent = new StringContent(jsonparams, Encoding.UTF8, "application/json"); httpclient.MaxResponseContentBufferSize = int.MaxValue; var response = await httpclient.PostAsync(url, jsoncontent); String text = await response.Content.ReadAsStringAsync(); }
It is a DVD deck to control. The remote controller is as shown below.
In order to control the device, you need to get the device id. It can be obtained by sending a request to Nature Remo mini using the code below. Please get the access token here.
static async void DoGet() { string token = "Bearer " + "{access token}"; string url = "https://api.nature.global/1/appliances"; var httpclient = new HttpClient(); httpclient.DefaultRequestHeaders.Add("Authorization", token); var response = await httpclient.GetAsync(url); }
Since you can get the device id, use that the device id to control the power of a DVD deck.
The acquired id ( e1ac8815-1480-4914-bd77-a42c5037659b) is specified as follows, and the source is rewritten for POST request. A status code is returned in 200, it will succeed. I think It is able to write the code of the GET code and the POST code beautifully by using HttpRequestMessage and SendAsync.
static async void DoPost() { string token = "Bearer " + "{access token}"; string url = "https://api.nature.global/1/signals/e1ac8815-1480-4914-bd77-a42c5037659b/send"; var httpclient = new HttpClient(); var httpreqmsg = new HttpRequestMessage(HttpMethod.Post, url); httpreqmsg.Headers.Add("Authorization", token); var response = await httpclient.SendAsync(httpreqmsg); }
Because I want to make the sample source code as simple as possible, I do not specify HEADER information and other necessary information neatly. For full-fledged use, please refer carefully to the Nature Remo API specification.
A programming of device is fun. I noticed after Nature Remo mini arrived at my house, but the second generation of Nature Remo has humidity, human feeling, and light sensor. I should have bought the second generation of Nature Remo!
It looks fun to control Philips Hue.
- 出版社/メーカー: フィリップスライティング(Philips Lighting)
- 発売日: 2017/10/13
- メディア: ホーム&キッチン
- この商品を含むブログを見る
Philips 800284 Hue Lightstrip Plus 2nd ジェネレーション [並行輸入品]
- 出版社/メーカー: Philips Lighting
- メディア: ホーム&キッチン
- この商品を含むブログを見る