sinricpro / feature-requests

Feature request tracker for Sinric Pro
0 stars 0 forks source link

add /products #33

Closed Geromatic closed 1 year ago

Geromatic commented 1 year ago

I checked the api documentation and it is missing /products page. how do I know what device type that I can make.

Geromatic commented 1 year ago
var request = require("request");
var options = { 
  method: 'GET',
  url: 'https://api.sinric.pro/api/v1/products/',
  headers: 
  {   'Authorization': 'Bearer <TOKEN HERE>',
      'Content-Type': 'application/x-www-form-urlencoded' 
  }
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);
});

I tried this code and sends me back result code 200 but does not provide me any data back. so I am assuming its coded in as a dummy function till a future update

kakopappa commented 1 year ago

your code works fine for me. image

Geromatic commented 1 year ago

hmm im using arduino so it might be too large of a payload

kakopappa commented 1 year ago

They are static, so you could hardcode the IDs

Geromatic commented 1 year ago

is there a way just to get the a simplified version that shows the productids similar to Get default list of room names nodejs command.. its also when you add a custom template it also adds the productid to list

kakopappa commented 1 year ago

no, there's not. I think I best option is to hard-code the ids. API is not written to be processed by microcontroller.

sivar2311 commented 1 year ago

@Geromatic If you use the ArduinoJson library, you can set filters to reduce the size. See example.

But as Kakopappa said: It is not meant to call the API from an Arduino. If I may ask: What do you intend to do?

sivar2311 commented 1 year ago

technically I am not using nodejs

Yes, we are talking about Arduino. It's about how you parse the JSON response.

If you use the ArduinoJson library you can easily set filters (see my post before) to reduce the JSON response and filter out only what you need.

I'm still interested in understanding what you're trying to do.

kakopappa commented 1 year ago

Me too

On Wed, 8 Mar 2023 at 12:00 PM sivar2311 @.***> wrote:

technically I am not using nodejs Yes, we are talking about Arduino. It's about how you parse the JSON response.

If you use the ArduinoJson library you can easily set filters (see my post before) to reduce the JSON response and filter out only what you need.

I'm still interested in understanding what you're trying to do.

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/feature-requests/issues/33#issuecomment-1459487939, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXZUW2OTHN3DDB67LLW3AG5HANCNFSM6AAAAAAVRSOGHM . You are receiving this because you commented.Message ID: @.***>

sushantr5 commented 8 months ago

How can I create my own product? I want to createa product which can be used by any account. So kind of default product irrespective of account. If custom product is always account specific then I would like to create a product using APIs. I am looking for two product types.

Even if I can use existing product types then also it is perfect.

  1. 4 Gang Switch
  2. 4 Speed Fan controller

I am writing tasmota driver which will integrate tasmota with your platform.

kakopappa commented 8 months ago

Hi @sushantr5

There are custom device types and built-in device types. Built-in are defined by us for common use cases and custom are created by the end-user for their edge cases.

If you want to share a custom device template with someone else then you can export the custom device temple to json format and share it. so the other person can import it.

Different fan speeds can be defined at the time of creating fan device (others tab)

If you have any other questions, please create a new issue

sushantr5 commented 8 months ago

@kakopappa

Thank you for your reply. I want to create this custom device automatically through API may be. I want to make this process as easy as possible in tasmota.

  1. User adds authorization details in Tasmota
  2. Device shall be created automatically in sinric.pro

For this purpose, when user enters credentials in Tasmota, I will call create device API. For this purpose Product is needed, Product may not be as per the out of the box templates defined. If we take basic use case, I want to control multiple relays through Tasmota and Sinric.pro, then in this case product details might be dependent on number of relays.

So I want to embed Product definition in Tasmota which can be customized according to the need. Other option I thought of adding one device for one relay, but it will consume device licenses in Sinric.pro. That is why I would like to create One device with 4 Relays.

UPDATE: I will create new issue