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_);
81 uint8_t retry = NUMBER_OF_READ_RETRIES;
96 ESP_LOGE(TAG,
"Updating GDK101 failed!");
105 if (this->rad_1m_sensor_ !=
nullptr) {
107 ESP_LOGE(TAG,
"Updating GDK101 failed!");
111 const float dose =
data[0] + (
data[1] / 100.0f);
113 this->rad_1m_sensor_->publish_state(dose);
121 if (this->rad_10m_sensor_ !=
nullptr) {
123 ESP_LOGE(TAG,
"Updating GDK101 failed!");
127 const float dose =
data[0] + (
data[1] / 100.0f);
129 this->rad_10m_sensor_->publish_state(dose);
137 ESP_LOGE(TAG,
"Updating GDK101 failed!");
142 if (this->status_sensor_ !=
nullptr) {
143 this->status_sensor_->publish_state(
data[0]);
147#ifdef USE_BINARY_SENSOR
148 if (this->vibration_binary_sensor_ !=
nullptr) {
149 this->vibration_binary_sensor_->publish_state(
data[1]);
157#ifdef USE_TEXT_SENSOR
158 if (this->fw_version_text_sensor_ !=
nullptr) {
160 ESP_LOGE(TAG,
"Updating GDK101 failed!");
166 snprintf(buf,
sizeof(buf),
"%d.%d",
data[0],
data[1]);
167 this->fw_version_text_sensor_->publish_state(buf);
175 if (this->measurement_duration_sensor_ !=
nullptr) {
177 ESP_LOGE(TAG,
"Updating GDK101 failed!");
181 const float meas_time = (
data[0] * 60) +
data[1];
183 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()
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.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)