11static const char *bedjet_fan_step_to_fan_mode(
const uint8_t
fan_step) {
12 if (
fan_step < BEDJET_FAN_SPEED_COUNT)
13 return BEDJET_FAN_STEP_NAMES[
fan_step];
17static uint8_t bedjet_fan_speed_to_step(
const char *fan_step_percent) {
18 for (
int i = 0; i < BEDJET_FAN_SPEED_COUNT; i++) {
19 if (strcmp(BEDJET_FAN_STEP_NAMES[i], fan_step_percent) == 0) {
33 LOG_CLIMATE(
"",
"BedJet Climate",
this);
36 ESP_LOGCONFIG(TAG,
" Supported modes:");
41 ESP_LOGCONFIG(TAG,
" - BedJet heating mode: EXT HT");
43 ESP_LOGCONFIG(TAG,
" - BedJet heating mode: HEAT");
46 ESP_LOGCONFIG(TAG,
" Supported fan modes:");
51 ESP_LOGCONFIG(TAG,
" - %s (c)",
mode);
54 ESP_LOGCONFIG(TAG,
" Supported presets:");
59 ESP_LOGCONFIG(TAG,
" - %s (c)",
preset);
66 if (restore.has_value()) {
67 ESP_LOGI(TAG,
"Restored previous saved state.");
93 ESP_LOGD(TAG,
"Received BedJetClimate::control");
94 if (!this->
parent_->is_connected()) {
95 ESP_LOGW(TAG,
"Not connected, cannot handle control call yet.");
99 auto mode_opt =
call.get_mode();
100 if (mode_opt.has_value()) {
105 button_result = this->
parent_->button_off();
111 button_result = this->
parent_->button_cool();
114 button_result = this->
parent_->button_dry();
117 ESP_LOGW(TAG,
"Unsupported mode: %d",
mode);
129 auto target_temp_opt =
call.get_target_temperature();
130 if (target_temp_opt.has_value()) {
131 auto target_temp = *target_temp_opt;
132 auto result = this->
parent_->set_target_temp(target_temp);
139 auto preset_opt =
call.get_preset();
140 if (preset_opt.has_value()) {
146 result = this->
parent_->button_turbo();
157 this->preset.reset();
161 ESP_LOGD(TAG,
"Ignoring preset '%s' call; with current mode '%s' and preset '%s'",
166 ESP_LOGW(TAG,
"Unsupported preset: %d",
preset);
169 }
else if (
call.has_custom_preset()) {
174 result = this->
parent_->button_memory1();
175 }
else if (
preset ==
"M2") {
176 result = this->
parent_->button_memory2();
177 }
else if (
preset ==
"M3") {
178 result = this->
parent_->button_memory3();
179 }
else if (
preset ==
"LTD HT") {
180 result = this->
parent_->button_heat();
181 }
else if (
preset ==
"EXT HT") {
182 result = this->
parent_->button_ext_heat();
184 ESP_LOGW(TAG,
"Unsupported preset: %.*s", (
int)
preset.size(),
preset.c_str());
193 auto fan_mode_opt =
call.get_fan_mode();
194 if (fan_mode_opt.has_value()) {
200 result = this->
parent_->set_fan_speed(20);
202 result = this->
parent_->set_fan_speed(50);
204 result = this->
parent_->set_fan_speed(75);
206 ESP_LOGW(TAG,
"[%s] Unsupported fan mode: %s", this->
get_name().c_str(),
216 auto fan_index = bedjet_fan_speed_to_step(
fan_mode.c_str());
217 if (fan_index <= 19) {
218 ESP_LOGV(TAG,
"[%s] Converted fan mode %.*s to bedjet fan step %d", this->
get_name().c_str(),
220 bool result = this->
parent_->set_fan_index(fan_index);
231 ESP_LOGV(TAG,
"[%s] Handling on_status with data=%p", this->
get_name().c_str(), (
void *) data);
234 if (converted_temp > 0)
242 if (converted_temp > 0) {
246 const auto *fan_mode_name = bedjet_fan_step_to_fan_mode(data->
fan_step);
247 if (fan_mode_name !=
nullptr) {
252 switch (data->
mode) {
305 ESP_LOGW(TAG,
"[%s] Unexpected mode: 0x%02X", this->
get_name().c_str(), data->
mode);
309 ESP_LOGV(TAG,
"[%s] After on_status, new mode=%s", this->
get_name().c_str(),
323 if (!this->
parent_->is_connected())
325 if (!this->
parent_->has_status())
346 ESP_LOGD(TAG,
"[%s] update()", this->
get_name().c_str());
350 ESP_LOGD(TAG,
"[%s] update_status result=%s", this->
get_name().c_str(), result ?
"true" :
"false");
uint8_t fan_step
BedJet fan speed; value is in the 0-19 range, representing 5% increments (5%-100%): 5 + 5 /< * fan_st...
BedjetMode mode
BedJet operating mode.
void disable_loop()
Disable this component's loop.
void status_clear_warning()
const StringRef & get_name() const
bool update_status_()
Attempts to update the climate device from the last received BedjetStatusPacket.
BedjetTemperatureSource temperature_source_
climate::ClimateTraits traits() override
BedjetHeatMode heating_mode_
void on_bedjet_state(bool is_ready) override
void reset_state_()
Resets states to defaults.
void control(const climate::ClimateCall &call) override
void dump_config() override
std::string describe() override
void on_status(const BedjetStatusPacket *data) override
This class is used to encode all control actions on a climate device.
bool has_custom_fan_mode() const
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
float target_temperature
The target temperature of the climate device.
bool set_preset_(ClimatePreset preset)
Set preset. Reset custom preset. Return true if preset has been changed.
bool set_custom_preset_(const char *preset)
Set custom preset. Reset primary preset. Return true if preset has been changed.
void clear_custom_preset_()
Clear custom preset.
bool set_fan_mode_(ClimateFanMode mode)
Set fan mode. Reset custom fan mode. Return true if fan mode has been changed.
float current_temperature
The current temperature of the climate device, as reported from the integration.
ClimateAction action
The active state of the climate device.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimatePreset > preset
The active preset of the climate device.
optional< ClimateDeviceRestoreState > restore_state_()
Restore the state of the climate device, call this from your setup() method.
bool set_custom_fan_mode_(const char *mode)
Set custom fan mode. Reset primary fan mode. Return true if fan mode has been changed.
const ClimatePresetMask & get_supported_presets() const
const std::vector< const char * > & get_supported_custom_fan_modes() const
const ClimateFanModeMask & get_supported_fan_modes() const
const std::vector< const char * > & get_supported_custom_presets() const
const ClimateModeMask & get_supported_modes() const
BedjetHeatMode
Optional heating strategies to use for climate::CLIMATE_MODE_HEAT.
@ HEAT_MODE_EXTENDED
HVACMode.HEAT is handled using BTN_EXTHT.
@ MODE_DRY
BedJet is in Dry mode (high speed, no heat)
@ MODE_EXTHT
BedJet is in Extended Heat mode (limited to 10 hours)
@ MODE_COOL
BedJet is in Cool mode (actually "Fan only" mode)
@ MODE_TURBO
BedJet is in Turbo mode (high heat, limited time)
@ MODE_HEAT
BedJet is in Heat mode (limited to 4 hours)
@ MODE_WAIT
BedJet is in "wait" mode, a step during a biorhythm program.
@ MODE_STANDBY
BedJet is Off.
float bedjet_temp_to_c(uint8_t temp)
Converts a BedJet temp step into degrees Celsius.
@ BTN_EXTHT
Enter Extended Heat mode (limited to 10 hours)
@ BTN_HEAT
Enter Heat mode (limited to 4 hours)
@ TEMPERATURE_SOURCE_OUTLET
const LogString * climate_preset_to_string(ClimatePreset preset)
Convert the given PresetMode to a human-readable string.
ClimatePreset
Enum for all preset modes NOTE: If adding values, update ClimatePresetMask in climate_traits....
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
const LogString * climate_fan_mode_to_string(ClimateFanMode fan_mode)
Convert the given ClimateFanMode to a human-readable string.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
const LogString * climate_mode_to_string(ClimateMode mode)
Convert the given ClimateMode to a human-readable string.
@ CLIMATE_ACTION_IDLE
The climate device is idle (monitoring climate but no action needed)
@ CLIMATE_ACTION_DRYING
The climate device is drying.
@ CLIMATE_ACTION_HEATING
The climate device is actively heating.
@ CLIMATE_ACTION_COOLING
The climate device is actively cooling.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_OFF
The fan mode is set to Off.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
Providing packet encoding functions for exchanging data with a remote host.
The format of a BedJet V3 status packet.
uint8_t target_temp_step
Target temp that the BedJet will try to heat to. See actual_temp_step.
uint8_t actual_temp_step
Actual temp of the air blown by the BedJet fan; value represents 2 * /< degrees_celsius.
uint8_t fan_step
BedJet fan speed; value is in the 0-19 range, representing 5% increments (5%-100%): 5 + 5 /< * fan_st...
BedjetMode mode
BedJet operating mode.
uint8_t ambient_temp_step
Current ambient air temp.