-
Notifications
You must be signed in to change notification settings - Fork 39
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
Can't setup a simple switch endpoint and be visible in Home Assistant (TZ-1398) #506
Comments
Hi,
I think you can use the below steps for a try:
|
Thanks a lot @xieqinan for the quick answer! I will definitely give an other try with your suggestions. Just to be clear, my goal is not to bind the light with the switch. I do understand while reading my description it's not totally clear at first glance, but let me explain what I really want, as I think I've been too vague in my initial description. I currently have in my bathroom two devices (not ESP32, but ZigBee devices bought in the market):
So the idea to have a small device of my own (with my ESP32-C6 devKit for now) to indicate me which mode my thermostat is currently on
The "logic" with green/red/switch binding could be done directly in Home Assistant, I "just" need to expose either a RGB light or two lights (green & red), this is the easy part I'd say. The difficult one now is exposing the switch/button click in Home Assistant. I also wonder if a binary sensor would be the thing I'm looking for perhaps, instead of a switch? So I can tell Home Assistant to switch the thermostat mode to Eco/Comfort according to the sensor state What do you think? |
Understood, but I believe this issue is not related to the esp-zigbee-sdk. If the switch joined the HA network as the
I think this is a good idea; you can give it a try. |
I tried to get inspiration from the Could you please let me know if there is something wrong in my endpoint setup for Binary Input? // Binary input
esp_zb_binary_input_cluster_cfg_t binary_input_cfg = {
.out_of_service = false,
.status_flags = 0
};
esp_zb_basic_cluster_cfg_t binary_input_basic_cfg = {
.power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE,
.zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE,
};
esp_zb_identify_cluster_cfg_t binary_input_identify_cfg = {
.identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE
};
esp_zb_cluster_list_t *binary_input_cluster_list = esp_zb_zcl_cluster_list_create();
esp_zb_attribute_list_t *binary_input_basic_cluster = esp_zb_basic_cluster_create(&binary_input_basic_cfg);
esp_zb_basic_cluster_add_attr(binary_input_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, ESP_MANUFACTURER_NAME);
esp_zb_basic_cluster_add_attr(binary_input_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, ESP_MODEL_IDENTIFIER);
esp_zb_cluster_list_add_basic_cluster(binary_input_cluster_list, binary_input_basic_cluster, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);
esp_zb_cluster_list_add_identify_cluster(binary_input_cluster_list, esp_zb_identify_cluster_create(&binary_input_identify_cfg), ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);
esp_zb_attribute_list_t *binary_input_attr_list = esp_zb_binary_input_cluster_create(&binary_input_cfg);
bool binary_input_value = false;
esp_zb_binary_input_cluster_add_attr(binary_input_attr_list, ESP_ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID, &binary_input_value);
esp_zb_cluster_list_add_binary_input_cluster(binary_input_cluster_list, binary_input_attr_list, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);
esp_zb_endpoint_config_t binary_input_endpoint_config = {
.endpoint = BATHROOM_BINARY_INPUT_ENDPOINT,
.app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
.app_device_id = ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID,
.app_device_version = 0,
};
esp_zb_ep_list_add_ep(ep_list, binary_input_cluster_list, binary_input_endpoint_config); (If you want to check all the code, the branch has been updated.) Thank you :). |
Based on #506 (comment), I believe I understand your requirements. You need a physical light to indicate the thermostat state (Comfort or Eco) and a physical toggle switch to control the thermostat's state transition, with the light reflecting the state changes. If that’s the case, I don’t think it’s necessary to expose the switch/button click in Home Assistant. The following solution might meet your needs:
What do you think of this approach? |
Thanks for the answer @xieqinan.
You successfully summed up my project in one sentence! The thing you may have misunderstood is that the logic happens in Home Assistant and not in the ESP32 project itself. I think I still need to expose a switch in Home Assistant (HA), mostly because with ZHA (basic ZigBee integration), binding ZigBee devices between them is not the essence of ZHA, you mostly have to use HA Automation to, let's say, "link" things together (let's use "link" terminology and not "bind", just to not confuse with ZigBee binding). I'll give you one of my personal Automation, a very simple remote switch that controls one of my smart plug, it's not related with my ESP32 project btw. You can easily understand what's going on here, basically, one of my ZigBee device (an Aquara switch remote, named "Switch bureau") has an exposed This Aqara switch device has a lot of trigger options Then I can easily link these trigger with whatever I want HA to do. In this example a simple click on this remote will toggle my smart plug state. My goal with my project is to do exactly that, expose a switch + a light, and do an Automation like the one above to control the thermostat state. That's what I mean when I say "the logic is in Home Assistant", I don't need to know the current thermostat state in my ESP32 project, I just need to expose a switch and two lights. My real only problem now is that Home Assistant doesn't see my switch as a potential trigger for automation if that makes more sense now. |
Question
Hi there, my very first question here!
First of all, thank you for your work around this! I see a lot of support for questions and requests! Hope my question will be easy to answer!
Let me also do a very quick intro: I'm a Swift developer, so not very familiar with C, my problem could totally be lack of C basic knowledge.
My project: It's quite simple: a light driven by Home Assistant, pretty ease, just used this example and everything is working perfectly to drive the light.
On top of that, I want to add a switch, with it, I'd like to drive something else in Home Assistant, basically, be a simple "remote".
From Home Assistant, I would like to be able to bind things together with my other devices. No need to bind anything from the device code itself if possible.
My problem: In Home Assistant, I well see the light, and I can toggle on/off seamlessly, it works.
But I can't see the "switch/remote", the one I'd like to bind in one of my other device via Home Assistant.
When I go to "Automation" for instance, I can't see anything related to button/switch/remote to trigger something. I only see things like "light on", "light off", etc.
Ideally, I'd like to see something like one of my button. Perhaps it's something to configure in Home Assistant itself, but I think primarily I need to somehow expose the switch ability to toggle.
Certainly that
Is not enough?
The whole project compile, and is publicly available, so don't hesitate to check it if it helps (I'm using the
add-switch-for-zigbee-network-reset
branch for the current development).I did a lot of things, tried to use something else than a switch, but I'm now running out of ideas.
Thanks for your help :).
Additional context.
No response
The text was updated successfully, but these errors were encountered: