15 this->
codec_ = make_unique<AnovaCodec>();
27 esp_ble_gattc_write_char(this->
parent_->
get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_,
28 pkt->
length, pkt->
data, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);
35 auto mode_val =
call.get_mode();
36 if (mode_val.has_value()) {
41 pkt = this->
codec_->get_stop_request();
44 pkt = this->
codec_->get_start_request();
47 ESP_LOGW(TAG,
"Unsupported mode: %d",
mode);
52 auto target_temp =
call.get_target_temperature();
53 if (target_temp.has_value()) {
60 case ESP_GATTC_DISCONNECT_EVT: {
67 case ESP_GATTC_SEARCH_CMPL_EVT: {
70 ESP_LOGW(TAG,
"[%s] No control service found at device, not an Anova..?", LOG_STR_ARG(this->
get_log_name()));
71 ESP_LOGW(TAG,
"[%s] Note, this component does not currently support Anova Nano.",
80 ESP_LOGW(TAG,
"[%s] esp_ble_gattc_register_for_notify failed, status=%d", LOG_STR_ARG(this->
get_log_name()),
85 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
86 this->
node_state = espbt::ClientState::ESTABLISHED;
91 case ESP_GATTC_NOTIFY_EVT: {
92 if (param->notify.handle != this->char_handle_)
94 this->
codec_->decode(param->notify.value, param->notify.value_len);
95 if (this->
codec_->has_target_temp()) {
98 if (this->
codec_->has_current_temp()) {
101 if (this->
codec_->has_running()) {
104 if (this->
codec_->has_unit()) {
105 ESP_LOGD(TAG,
"Anova units is %s", (this->
codec_->unit_ ==
'f') ?
"fahrenheit" :
"celsius");
140 if (this->
node_state != espbt::ClientState::ESTABLISHED)
148 ESP_LOGW(TAG,
"[%s] Poll cycle incomplete (step %u); restarting cycle", this->
parent_->
address_str(),
149 static_cast<uint8_t
>(this->poll_step_));
void disable_loop()
Disable this component's loop.
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
void dump_config() override
std::unique_ptr< AnovaCodec > codec_
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
void control(const climate::ClimateCall &call) override
void write_request_(AnovaPacket *pkt)
void set_unit_of_measurement(const char *unit)
espbt::ClientState node_state
This class is used to encode all control actions on a climate device.
ClimateMode mode
The active mode of the climate device.
float target_temperature
The target temperature of the climate device.
float current_temperature
The current temperature of the climate device, as reported from the integration.
void publish_state()
Publish the state of the climate device, to be called from integrations.
const char * address_str() const
BLECharacteristic * get_characteristic(espbt::ESPBTUUID service, espbt::ESPBTUUID chr)
ESPHOME_LOG_TAG(TAG, "anova")
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.