Skip to content
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

Generic Switch example only supports single press (CON-1488) #1220

Closed
hvolpers opened this issue Dec 24, 2024 · 10 comments
Closed

Generic Switch example only supports single press (CON-1488) #1220

hvolpers opened this issue Dec 24, 2024 · 10 comments

Comments

@hvolpers
Copy link

Describe the bug
I build/installed the generic_switch example to an ESP32-C6 board using a GPIO Button (same behaviour will the boot button which is default). On bootup I get the message:

I (659) app_main: Generic Switch created with endpoint_id 1
E (659) esp_matter_feature: Momentary switch multi press is not supported because momentary switch and/or momentary switch releaseis absent

After adding the device to HomeKit (all devices updated to latest releases) single press is the only option available.

The error message seams to be iot_button related. I'm new to ESP32/Matter and I wasn't able to figure out what exacly the problem is.

Environment

  • ESP-Matter Commit Id: 96cb173

  • ESP-IDF Commit Id: v5.3.2 (9d7f2d69f50d1288526d4f1027108e314e8c879f)

  • SoC (eg: ESP32 or ESP32-C3): ESP32-H2 (Waveshare ESP32-C6-DEV-KIT-N8)

  • Device Logs (Please attach the log file): s. above, let me know if I can provide more information

  • Host Machine OS: Ubuntu 24.10

  • Host Machine Python version: 3.12.7

@github-actions github-actions bot changed the title Generic Switch example only supports single press Generic Switch example only supports single press (CON-1488) Dec 24, 2024
@Jerry-ESP
Copy link
Contributor

Did you use the default generic switch example? Can you share your code of the app_main.cpp ?

@Jerry-ESP
Copy link
Contributor

The current generic switch example support MomentarySwitch, MomentarySwitchMultiPress and ActionSwitch features, but the ActionSwitch is updated in matter1.4, maybe Apple home has not supported this feature. In matter1.3, If you want to add the MomentarySwitchMultiPress feature, you must add MomentarySwitchRelease feature.

@Jerry-ESP
Copy link
Contributor

In matter1.3
image

In matter1.4
image

@hvolpers
Copy link
Author

hvolpers commented Jan 2, 2025

Hi,

thanks for trying to help me out. Looks like I messed something up, as I wasn't able to reproduce the problem with a fresh copy of the generic_button example.
However, how can I add the long-press capability? As you pointed out (and that is what I found in the code as well) the combination Momentary Switch & Action Switch should be enough to add the long press feature, right?
I added the long press feature in app_main.cpp:

#if CONFIG_GENERIC_SWITCH_TYPE_MOMENTARY                                                                                                                                                                                                                                                              
    cluster::switch_cluster::feature::momentary_switch::add(cluster);                                                                                                                                                                                                                                 
    cluster::switch_cluster::feature::action_switch::add(cluster);                                                                                                                                                                                                                                    
    cluster::switch_cluster::feature::momentary_switch_multi_press::config_t msm;                                                                                                                                                                                                                     
    msm.multi_press_max = 5;                                                                                                                                                                                                                                                                          
    cluster::switch_cluster::feature::momentary_switch_multi_press::add(cluster, &msm);                                                                                                                                                                                                               
    cluster::switch_cluster::feature::momentary_switch_long_press::add(cluster);                                                                                                                                                                                                                      
#endif                                                                                                                                                                                                                                                                                                

but after rebuilding and flashing on boot up I get this (error) message from the ESP (erase-flash, flash, not coupled, first start right after flashing)

[...]
I (660) app_main: Generic Switch created with endpoint_id 1
E (660) esp_matter_feature: Momentary switch long press is not supported.
I (670) pp: pp rom version: 5b8dcfa
[...]

Sorry for being a c/c++/esp32 n00b here (working on it ;)). What am I missing here?

Thanks for taking the time and sorry for me messing something up. I will create a clean test case next time before opening an issue.

@Jerry-ESP
Copy link
Contributor

Hi
This is a known issue, we will fix it soon, you can apply this patch and have a try.

Thanks!
esp-matter-fix-switch-cluster-feature.zip

@hvolpers
Copy link
Author

hvolpers commented Jan 2, 2025

Thx, I will give it a try. Something else I realised: After removing the device I am not able to couple it again. The only way I found was to eraseflash and flash again. Any links/pointers for me to learn how to setup the full device lifecycle?

@Jerry-ESP
Copy link
Contributor

You can factory reset the device by type in the cli: matter device factoryreset, then you can pairing it again.

@hvolpers
Copy link
Author

hvolpers commented Jan 2, 2025

Sure. But that is not exacly an end-user experience, is it? ;) So I guess what you are saying that I have to implement the reset button myself as it is not in scope for the examples?

@hvolpers hvolpers closed this as completed Jan 2, 2025
@Jerry-ESP
Copy link
Contributor

Sure. But that is not exacly an end-user experience, is it? ;) So I guess what you are saying that I have to implement the reset button myself as it is not in scope for the examples?

Yes, but you can refer to the light example to implement the long press factoryreset function:

app_reset_button_register(button_handle);

@hvolpers
Copy link
Author

hvolpers commented Jan 2, 2025

I'll look into the light example. Thank you for helping me out and providing the fix, very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants