Page 1 of 1

Create new device type

Posted: Sun Jan 01, 2023 11:20 pm
by JustinWilker
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!

Re: Create new device type

Posted: Mon Jan 02, 2023 4:14 am
by sanketwadekar
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.

Re: Create new device type

Posted: Tue Jan 03, 2023 7:02 am
by JustinWilker
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.

Re: Create new device type

Posted: Thu Jan 05, 2023 6:15 am
by sanketwadekar
If you don't mind, can you post your sketch here?

Re: Create new device type

Posted: Fri Jan 06, 2023 5:48 am
by JustinWilker
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 4581 times
Screenshot_20230106-004517.png
Screenshot_20230106-004517.png (142.14 KiB) Viewed 4581 times

Re: Create new device type

Posted: Mon Jan 09, 2023 6:22 am
by sanketwadekar
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.