[nrf52,zigbee] add support for binary_input (#11535)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick+github@koston.org> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
17 files changed
+866
-3
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include "zigbee_binary_sensor_zephyr.h"
|
||||
#if defined(USE_ZIGBEE) && defined(USE_NRF52) && defined(USE_BINARY_SENSOR)
|
||||
#include "esphome/core/log.h"
|
||||
extern "C" {
|
||||
#include <zboss_api.h>
|
||||
#include <zboss_api_addons.h>
|
||||
#include <zb_nrf_platform.h>
|
||||
#include <zigbee/zigbee_app_utils.h>
|
||||
#include <zb_error_to_string.h>
|
||||
}
|
||||
namespace esphome::zigbee {
|
||||
|
||||
static const char *const TAG = "zigbee.binary_sensor";
|
||||
|
||||
ZigbeeBinarySensor::ZigbeeBinarySensor(binary_sensor::BinarySensor *binary_sensor) : binary_sensor_(binary_sensor) {}
|
||||
|
||||
void ZigbeeBinarySensor::setup() {
|
||||
this->binary_sensor_->add_on_state_callback([this](bool state) {
|
||||
this->cluster_attributes_->present_value = state ? ZB_TRUE : ZB_FALSE;
|
||||
ESP_LOGD(TAG, "Set attribute end point: %d, present_value %d", this->end_point_,
|
||||
this->cluster_attributes_->present_value);
|
||||
ZB_ZCL_SET_ATTRIBUTE(this->end_point_, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, ZB_ZCL_CLUSTER_SERVER_ROLE,
|
||||
ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID, &this->cluster_attributes_->present_value,
|
||||
ZB_FALSE);
|
||||
this->parent_->flush();
|
||||
});
|
||||
}
|
||||
|
||||
void ZigbeeBinarySensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
"Zigbee Binary Sensor\n"
|
||||
" End point: %d, present_value %u",
|
||||
this->end_point_, this->cluster_attributes_->present_value);
|
||||
}
|
||||
|
||||
} // namespace esphome::zigbee
|
||||
#endif
|
||||
Reference in new issue
Block a user