-
Notifications
You must be signed in to change notification settings - Fork 190
Window Covering command stop indistinguishable (CON-799) #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you looked at the internals of the window covering cluster API? |
I have checked it and there is happening what i described. The target position/tilt is set to the current position/tilt which is executing the callback for attribute changed. For me this looks like the implementation of the chip layer is not thought on a practical basis or i am missing something obvious :D. |
Back on the day I suggested in a PR the ability to override command callback (#35) because I needed to stop (and move) the Window Covering device when Position Aware features weren't enabled so that there is no way to use position to tell esp-matter to move the device. First, you need to copy this piece of code wherever you want to modify the command : esp-matter/components/esp_matter/esp_matter_core.cpp Lines 157 to 162 in 1cacb8b
(This is needed because as it is defined at a cpp file, AFAIK there is no way to access it) Then you define your command (I leave this template here that can help you with getting the handles and setting a response for Matter with esp_err_t stop_movement(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr) {
chip::app::CommandHandler *commandObj = (chip::app::CommandHandler *)opaque_ptr;
chip::EndpointId endpoint = command_path.mEndpointId;
ESP_LOGI(TAG, "StopMotion command received for endpoint %d", endpoint);
if (endpoint == endpoint_id ) {
chip::Protocols::InteractionModel::Status status = GetMotionLockStatus(endpoint);
if (Status::Success != status)
{
ESP_LOGE(TAG, "Err device locked");
commandObj->AddStatus(commandPath, status);
return ESP_FAIL;
}
/* TODO get the handle of your device */
device_handle* deivce_handle= (device_handle*)get_priv_data(endpoint);
if (device_handle== NULL) {
commandObj->AddStatus(command_path, Status::Failure);
return ESP_FAIL;
}
commandObj->AddStatus(command_path, chip::Protocols::InteractionModel::Status::Success);
/* TODO perform stop logic */
deivce_handle->stop();
return ESP_OK;
} else {
ESP_LOGE(TAG, "Stop command sent to an unknown endpoint");
commandObj->AddStatus(command_path, chip::Protocols::InteractionModel::Status::NotFound);
return ESP_FAIL;
}
}
Lastly, override the command: ((_command_t *)esp_matter::command::get(cluster_t_handle, WindowCovering::Commands::StopMotion::Id, COMMAND_FLAG_ACCEPTED))->callback = stop_movement; Maybe there is another way to do this such as modifying the delegate that is at app/clusters/window-covering-server/window-covering-server.cpp#L741 but I didn't explore more as the way I explained worked for me. |
@Diegorro98 Thank you very much! I guess i will go on with this approach. |
You can intercept the call by writing your own plugin sever which then chains on into the Matter one.
|
@svenehlers glad to help! 😊 |
Hello here, you could provide a PR to the main window covering server if needed. The most important thing to keep in mind for a product I am not an ESP user , so i don't know how your examples or SDK are working TBH |
does set_plugin_server_init_callback is from Matter's SDK or this a thing from ESP's SDK ? |
I think now i implemented it in a way how it was intended by CHIP and how you suggested in a previous comment @Diegorro98 . I am defining a window covering delegate and inject it into the window covering endpoint. This was not possible for CHIP v1.0 but since v1.1 it is.
By returning CHIP_ERROR_IN_PROGRESS the stop command willl not update the target lift/tilt by its own. I do it on my own after the covering really stopped.
where covering_delegate is declared in a global scope. I had to add this line before calling SetEndpoint:
|
Uh oh!
There was an error while loading. Please reload this page.
I am thinking about how to distinguish the window covering stop command from other drive commands. The chip layer is changing the target position and tilt upon receiving a stop command to the current position and tilt but in the attribute update callback i can not detect if the chip layer received a drive command with the current position or tilt as parameter or if it was caused by a stop command.
This could be handled by updating the current position in 'real time' but this takes too much computation time and produces too much traffic. Currently the current position and tilt is updated after the window covering stopped only. While driving the current position and tilt is always given from the previous stopping event.
At this moment i dont see any solution but setting an extra flag when the stop command callback is called in the esp-matter layer or chip layer. Does anybody knows another solution or has any concerns about manipulating the esp-matter source file.
The text was updated successfully, but these errors were encountered: