Create new device type

JustinWilker
Posts: 3
Joined: Sun Jan 01, 2023 11:05 pm

Create new device type

Postby JustinWilker » Sun Jan 01, 2023 11:20 pm

Trying to set up a garage door sensor using rainmaker, according to https://rainmaker.espressif.com/docs/st ... types.html garage door is available. However, when I compile I get the following error:

Code: Select all

Compilation error: 'GarageDoor' does not name a type
Any help is appreciated!

sanketwadekar
Posts: 32
Joined: Tue Jul 26, 2022 10:08 am

Re: Create new device type

Postby sanketwadekar » Mon Jan 02, 2023 4:14 am

Hello,
Garage Door Sensor is supported but there is no class "GarageDoor" inbuilt in the Rainmaker SDK that implements it. To create the Door sensor, you will have to use the APIs from the "Device" and "Param" classes. You can refer to this link https://docs.espressif.com/projects/ard ... maker.html for API docs.

JustinWilker
Posts: 3
Joined: Sun Jan 01, 2023 11:05 pm

Re: Create new device type

Postby JustinWilker » Tue Jan 03, 2023 7:02 am

I have it set up now that the Google Home app is recognizing it as a garage door, however, I can't seem to get it to update.

Code: Select all

static Device garageSensor1("Garage Door 1", ESP_RMAKER_DEVICE_GARAGE_DOOR);
Param garagePosition("Garage Position", ESP_RMAKER_PARAM_GARAGE_POSITION, value(0), PROP_FLAG_READ | PROP_FLAG_WRITE);
Param garageLock("Garage Lock", ESP_RMAKER_PARAM_GARAGE_LOCK, value(0), PROP_FLAG_READ | PROP_FLAG_WRITE);

Code: Select all

int state = digitalRead(hallSensor1);
  garageSensor1.updateAndReportParam("Garage Lock", state);
Updates just fine in RainMaker app, just not with Google.

sanketwadekar
Posts: 32
Joined: Tue Jul 26, 2022 10:08 am

Re: Create new device type

Postby sanketwadekar » Thu Jan 05, 2023 6:15 am

If you don't mind, can you post your sketch here?

JustinWilker
Posts: 3
Joined: Sun Jan 01, 2023 11:05 pm

Re: Create new device type

Postby JustinWilker » Fri Jan 06, 2023 5:48 am

I actually just ended up changing the device to blinds and the parameter to blinds position.

Didn't change anything else about the code, Google now displays the information (open or close) in the app. The device shows up as "blinds" instead of "garage" but that's just a minor inconvenience.

Must be the way RainMaker is reporting the information to Google.
Screenshot_20230106-000948.png
Screenshot_20230106-000948.png (173.25 KiB) Viewed 4881 times
Screenshot_20230106-004517.png
Screenshot_20230106-004517.png (142.14 KiB) Viewed 4881 times

sanketwadekar
Posts: 32
Joined: Tue Jul 26, 2022 10:08 am

Re: Create new device type

Postby sanketwadekar » Mon Jan 09, 2023 6:22 am

JustinWilker wrote:
Tue Jan 03, 2023 7:02 am
I have it set up now that the Google Home app is recognizing it as a garage door, however, I can't seem to get it to update.

Code: Select all

static Device garageSensor1("Garage Door 1", ESP_RMAKER_DEVICE_GARAGE_DOOR);
Param garagePosition("Garage Position", ESP_RMAKER_PARAM_GARAGE_POSITION, value(0), PROP_FLAG_READ | PROP_FLAG_WRITE);
Param garageLock("Garage Lock", ESP_RMAKER_PARAM_GARAGE_LOCK, value(0), PROP_FLAG_READ | PROP_FLAG_WRITE);

Code: Select all

int state = digitalRead(hallSensor1);
  garageSensor1.updateAndReportParam("Garage Lock", state);
Updates just fine in RainMaker app, just not with Google.
If you are seeing it in the Google Home app, then you should be able to open/close it through the Google voice assistant. You can try saying "Okay google, open/close my garage door".

Code: Select all

    Param garage_position(GARAGE_POSITION_PARAM_NAME, ESP_RMAKER_PARAM_GARAGE_POSITION, value(start_state), PROP_FLAG_READ | PROP_FLAG_WRITE);
    garage_position.addUIType(ESP_RMAKER_UI_SLIDER);
    garage_position.addBounds(value(0), value(100), value(1));
    my_door.addParam(garage_position);
    my_door.assignPrimaryParam((param_handle_t *)garage_position.getParamHandle());
    
This is the code snippet that I've added for testing and it worked.

Who is online

Users browsing this forum: No registered users and 31 guests