Device Create API(Device Icon Change)

maialbe2823
Posts: 27
Joined: Thu Feb 17, 2022 4:41 am

Device Create API(Device Icon Change)

Postby maialbe2823 » Sat Feb 26, 2022 8:37 am

I noticed that there is only 4 API for devices like fan, switch, lightbulb and temperature sensor. I went into the cpp and header file and I created a class for a new thing which was a lock. I checked every possible library that could need it and added it. However; Arduino doesn't compiles as it doesn't recognize the ESP32 Dev Module anymore. Don't know why. Is there anyway to do it? Is there any other way for example if I create a custom device that instead of getting a random icon, I could add my own image icon?

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: Device Create API(Device Icon Change)

Postby ESP_Piyush » Mon Feb 28, 2022 5:29 am

Hello,

Sample code for custom devices can be found here. However, you cannot have custom icons in the phone app, since the phone app sources only support a small set of icons that you can see here. We would have liked to give an option to add own icons without having to re-compile the phone apps, but we have not started any work on that front yet. If you are looking for any specific device type or icon, do let us know.

maialbe2823
Posts: 27
Joined: Thu Feb 17, 2022 4:41 am

Re: Device Create API(Device Icon Change)

Postby maialbe2823 » Mon Feb 28, 2022 3:17 pm

Yes, I have used that table however for example if I create a lock device it says it doesnt exist. How can I get this done through arduino ide. As I see there is only 4 classes , not all of those in that table. So, If i call the Static Lock my_lock("Lock", NULL) it gives me an error since its not one of those. I even wnet an created a class for the lock but it stills give me the same error. How can I use the lock sample then.

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: Device Create API(Device Icon Change)

Postby ESP_Piyush » Tue Mar 01, 2022 5:23 pm

Hello, you can see that a custom dimmer device has been defined in this example. Have you similarly tried defining a lock, something like this?

Code: Select all

static Device my_device("Lock", "esp.device.lock", NULL);

maialbe2823
Posts: 27
Joined: Thu Feb 17, 2022 4:41 am

Re: Device Create API(Device Icon Change)

Postby maialbe2823 » Wed Mar 02, 2022 2:23 am

Thank you very much now I do get the image icon. One more question, how is it that the paramupdatereport function work in arduino , cuz in esp-idf sample I get it how is done but cannt seem to find the one arduino uses to updates sensors values, not the callback.

rmetzner49
Posts: 27
Joined: Mon Mar 27, 2017 1:09 am

Re: Device Create API(Device Icon Change)

Postby rmetzner49 » Fri Mar 04, 2022 2:35 pm

How about this:

my_device.updateAndReportParam("Hours Exercising:", h1);

Note, if you are updating several parameters, you will need to DELAY between calling them, else things choke.
Be sure not to use delay(); , you want a non-blocking timer. I update 3 values and have 200ms between each call.

maialbe2823
Posts: 27
Joined: Thu Feb 17, 2022 4:41 am

Re: Device Create API(Device Icon Change)

Postby maialbe2823 » Sat Mar 05, 2022 10:27 pm

Thank you very much.

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: Device Create API(Device Icon Change)

Postby ESP_Piyush » Mon Mar 07, 2022 7:06 am

Another option, if you have the param pointer is to use

Code: Select all

param->updateAndReport(val);

maialbe2823
Posts: 27
Joined: Thu Feb 17, 2022 4:41 am

Re: Device Create API(Device Icon Change)

Postby maialbe2823 » Mon Mar 07, 2022 5:32 pm

Thanks.

Who is online

Users browsing this forum: No registered users and 54 guests