8static const char *
const TAG =
"gdk101";
9static const uint8_t NUMBER_OF_READ_RETRIES = 5;
11void GDK101Component::update() {
58void GDK101Component::dump_config() {
59 ESP_LOGCONFIG(TAG,
"GDK101:");
62 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
65 LOG_SENSOR(
" ",
"Average Radaition Dose per 1 minute", this->rad_1m_sensor_);
66 LOG_SENSOR(
" ",
"Average Radaition Dose per 10 minutes", this->rad_10m_sensor_);
67 LOG_SENSOR(
" ",
"Status", this->status_sensor_);
68 LOG_SENSOR(
" ",
"Measurement Duration", this->measurement_duration_sensor_);
71#ifdef USE_BINARY_SENSOR
72 LOG_BINARY_SENSOR(
" ",
"Vibration Status", this->vibration_binary_sensor_);
76 LOG_TEXT_SENSOR(
" ",
"Firmware Version", this->fw_version_text_sensor_);
83 uint8_t retry = NUMBER_OF_READ_RETRIES;
98 ESP_LOGE(TAG,
"Updating GDK101 failed!");
107 if (this->rad_1m_sensor_ !=
nullptr) {
109 ESP_LOGE(TAG,
"Updating GDK101 failed!");
113 const float dose =
data[0] + (
data[1] / 100.0f);
115 this->rad_1m_sensor_->publish_state(dose);
123 if (this->rad_10m_sensor_ !=
nullptr) {
125 ESP_LOGE(TAG,
"Updating GDK101 failed!");
129 const float dose =
data[0] + (
data[1] / 100.0f);
131 this->rad_10m_sensor_->publish_state(dose);
139 ESP_LOGE(TAG,
"Updating GDK101 failed!");
144 if (this->status_sensor_ !=
nullptr) {
145 this->status_sensor_->publish_state(
data[0]);
149#ifdef USE_BINARY_SENSOR
150 if (this->vibration_binary_sensor_ !=
nullptr) {
151 this->vibration_binary_sensor_->publish_state(
data[1]);
159#ifdef USE_TEXT_SENSOR
160 if (this->fw_version_text_sensor_ !=
nullptr) {
162 ESP_LOGE(TAG,
"Updating GDK101 failed!");
168 this->fw_version_text_sensor_->publish_state(fw_version_str);
176 if (this->measurement_duration_sensor_ !=
nullptr) {
178 ESP_LOGE(TAG,
"Updating GDK101 failed!");
182 const float meas_time = (
data[0] * 60) +
data[1];
184 this->measurement_duration_sensor_->publish_state(meas_time);
virtual void mark_failed()
Mark this component as failed.
virtual void setup()
Where the component's initialization should happen.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
void status_set_error(const char *message=nullptr)
bool read_status_(uint8_t *data)
bool read_bytes_with_retry_(uint8_t a_register, uint8_t *data, uint8_t len)
bool read_dose_1m_(uint8_t *data)
bool read_dose_10m_(uint8_t *data)
bool read_fw_version_(uint8_t *data)
bool reset_sensor_(uint8_t *data)
bool read_measurement_duration_(uint8_t *data)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
std::string str_sprintf(const char *fmt,...)
void IRAM_ATTR HOT delay(uint32_t ms)