espressif / esp-rainmaker

ESP RainMaker Agent for firmware development
Apache License 2.0
432 stars 145 forks source link

Not able to add Internal Blinds along with standard devices (MEGH-3830) #168

Closed maxakash closed 1 year ago

maxakash commented 1 year ago

I am trying to add Internal Blinds as a device along with other standard devices such as Fan and LightBulb. But I am not able to do so. First InternalBlind type is not found, and if I try to add it via

    esp_rmaker_device_add_param(curtain, esp_rmaker_param_create("name", NULL, esp_rmaker_str("Curtain"),
            PROP_FLAG_READ | PROP_FLAG_WRITE | PROP_FLAG_PERSIST));
    esp_rmaker_param_t *openClose_param = esp_rmaker_param_create("direction", NULL, esp_rmaker_int(0), PROP_FLAG_READ | PROP_FLAG_WRITE);
    esp_rmaker_param_add_ui_type(openClose_param, ESP_RMAKER_UI_DROPDOWN);
    esp_rmaker_device_add_param(curtain, openClose_param);
    esp_rmaker_device_assign_primary_param(curtain, openClose_param);
    esp_rmaker_device_add_cb(curtain, write_cb, NULL);
    esp_rmaker_node_add_device(node, curtain);

I get "Could not initialise node" error. Please help me how to add Internal Blinds. Thanks

sanketwadekar commented 1 year ago

Hi @maxakash, Can you provide more logs? If possible, please share the source file so that I can help you better.

sanketwadekar commented 1 year ago

There is no need to use Rainmaker C APIs (Rainmaker using IDF) in Arduino. To add a new device (other than the standard devices), you can use the APIs provided by Arduino Rainmaker.

Example snippet


static Device internalBlinds;
void setup() {
   // Code
    internalBlinds = Device("Internal Blind");
    Param deviceParam("XYZ Param", NULL, value(20), PROP_FLAG_READ | PROP_FLAG_WRITE | PROP_FLAG_PERSIST);
    deviceParam.addUIType(ESP_RMAKER_UI_TEXT);
    internalBlinds.addParam(deviceParam); 

    my_node.addDevice(internalBlinds); // my_node is the 
   // Code
}

You can read more about the APIs here

If this solves your problem, you can close this issue.

maxakash commented 1 year ago

There is no need to use Rainmaker C APIs (Rainmaker using IDF) in Arduino. To add a new device (other than the standard devices), you can use the APIs provided by Arduino Rainmaker.

Example snippet


static Device internalBlinds;
void setup() {
   // Code
    internalBlinds = Device("Internal Blind");
    Param deviceParam("XYZ Param", NULL, value(20), PROP_FLAG_READ | PROP_FLAG_WRITE | PROP_FLAG_PERSIST);
    deviceParam.addUIType(ESP_RMAKER_UI_TEXT);
    internalBlinds.addParam(deviceParam); 

    my_node.addDevice(internalBlinds); // my_node is the 
   // Code
}

You can read more about the APIs here

If this solves your problem, you can close this issue.

Thanks @sanketwadekar . This is what I was looking for.

maxakash commented 1 year ago

Hey @sanketwadekar, I have set up my blinds using static Device curtain("Blinds", ESP_RMAKER_DEVICE_BLINDS_INTERNAL, NULL); But still the blinds are not shown in Google Home. I just checked that openPercent is a required trait for blinds. I think it is not implemented in GVA due to which it is not shown in Google Home. Can you please check?

shahpiyushv commented 1 year ago

@maxakash Have you tried adding ESP_RMAKER_PARAM_BLINDS_POSITION (esp.param.blinds-position) parameter?

maxakash commented 1 year ago

@maxakash Have you tried adding ESP_RMAKER_PARAM_BLINDS_POSITION (esp.param.blinds-position) parameter?

@shahpiyushv it worked after adding ESP_RMAKER_PARAM_BLINDS_POSITION. I was using it the wrong way. Thanks for your help.

maxakash commented 1 year ago

Hey @shahpiyushv , is there any way to implement Google actions blinds attribute discreteOnlyOpenClose, so that the blinds just have open and close function?

shahpiyushv commented 1 year ago

@maxakash , currently it is hard-coded with a value of false, so that we support the superset of the valid commands. Bit if there is some hardware limitation, we will allow setting this too. Can you file a separate issue for that with appropriate title?

shahpiyushv commented 1 year ago

I will close this issue since a new one #170 has been filed