8static const char *
const TAG =
"anova";
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..?", this->
get_name().c_str());
71 ESP_LOGW(TAG,
"[%s] Note, this component does not currently support Anova Nano.", this->
get_name().c_str());
79 ESP_LOGW(TAG,
"[%s] esp_ble_gattc_register_for_notify failed, status=%d", this->
get_name().c_str(),
status);
83 case ESP_GATTC_REG_FOR_NOTIFY_EVT: {
84 this->
node_state = espbt::ClientState::ESTABLISHED;
89 case ESP_GATTC_NOTIFY_EVT: {
90 if (param->notify.handle != this->char_handle_)
92 this->
codec_->decode(param->notify.value, param->notify.value_len);
93 if (this->
codec_->has_target_temp()) {
96 if (this->
codec_->has_current_temp()) {
99 if (this->
codec_->has_running()) {
102 if (this->
codec_->has_unit()) {
103 ESP_LOGD(TAG,
"Anova units is %s", (this->
codec_->unit_ ==
'f') ?
"fahrenheit" :
"celsius");
138 if (this->
node_state != espbt::ClientState::ESTABLISHED)
146 ESP_LOGW(TAG,
"[%s] Poll cycle incomplete (step %u); restarting cycle", this->
parent_->
address_str(),
147 static_cast<uint8_t
>(this->poll_step_));
void disable_loop()
Disable this component's loop.
const StringRef & get_name() const
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)
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.