9static const char *
const TAG =
"kuntze";
11static const uint8_t CMD_READ_REG = 0x03;
12static const uint16_t REGISTER[] = {4136, 4160, 4680, 6000, 4688, 4728, 5832};
15static constexpr size_t KUNTZE_MAX_LOG_BYTES = 8;
18 auto get_16bit = [&](
int i) -> uint16_t {
return (uint16_t(data[i * 2]) << 8) | uint16_t(data[i * 2 + 1]); };
21#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
26 float value = (float) get_16bit(0);
27 for (
int i = 0; i < data[3]; i++)
31 ESP_LOGD(TAG,
"pH=%.1f", value);
36 ESP_LOGD(TAG,
"temperature=%.1f", value);
41 ESP_LOGD(TAG,
"DIS1=%.1f", value);
46 ESP_LOGD(TAG,
"DIS2=%.1f", value);
51 ESP_LOGD(TAG,
"REDOX=%.1f", value);
56 ESP_LOGD(TAG,
"EC=%.1f", value);
61 ESP_LOGD(TAG,
"OCI=%.1f", value);
74 ESP_LOGW(TAG,
"timed out waiting for response");
80 send(CMD_READ_REG, REGISTER[this->
state_ - 1], 2);
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
sensor::Sensor * temperature_sensor_
sensor::Sensor * dis2_sensor_
sensor::Sensor * ec_sensor_
sensor::Sensor * oci_sensor_
sensor::Sensor * ph_sensor_
sensor::Sensor * dis1_sensor_
sensor::Sensor * redox_sensor_
void dump_config() override
void on_modbus_data(const std::vector< uint8_t > &data) override
void send(uint8_t function, uint16_t start_address, uint16_t number_of_entities, uint8_t payload_len=0, const uint8_t *payload=nullptr)
void publish_state(float state)
Publish a new state to the front-end.
Providing packet encoding functions for exchanging data with a remote host.
char * format_hex_pretty_to(char *buffer, size_t buffer_size, const uint8_t *data, size_t length, char separator)
Format byte array as uppercase hex to buffer (base implementation).
constexpr size_t format_hex_pretty_size(size_t byte_count)
Calculate buffer size needed for format_hex_pretty_to with separator: "XX:XX:...:XX\0".
Application App
Global storage of Application pointer - only one Application can exist.