ESPHome  2022.12.8
Go to the documentation of this file.
1 #pragma once
4 #include "esphome/core/defines.h"
5 #include "esphome/core/hal.h"
11 #ifdef USE_ESP32
13 namespace esphome {
14 namespace bedjet {
17  public:
18  void setup() override;
19  void loop() override;
20  void update() override;
21  void dump_config() override;
22  float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
24  /* BedJetClient status update */
25  void on_status(const BedjetStatusPacket *data) override;
26  void on_bedjet_state(bool is_ready) override;
27  std::string describe() override;
39  // climate::CLIMATE_MODE_TURBO // Not supported by Climate: see presets instead
42  });
44  // It would be better if we had a slider for the fan modes.
45  traits.set_supported_custom_fan_modes(BEDJET_FAN_STEP_NAMES_SET);
47  // If we support NONE, then have to decide what happens if the user switches to it (turn off?)
48  // climate::CLIMATE_PRESET_NONE,
49  // Climate doesn't have a "TURBO" mode, but we can use the BOOST preset instead.
51  });
53  // We could fetch biodata from bedjet and set these names that way.
54  // But then we have to invert the lookup in order to send the right preset.
55  // For now, we can leave them as M1-3 to match the remote buttons.
56  // EXT HT added to match remote button.
57  "EXT HT",
58  "M1",
59  "M2",
60  "M3",
61  });
62  if (this->heating_mode_ == HEAT_MODE_EXTENDED) {
64  } else {
66  }
70  return traits;
71  }
73  protected:
74  void control(const climate::ClimateCall &call) override;
78  void reset_state_();
79  bool update_status_();
81  bool is_valid_() {
82  // FIXME: find a better way to check this?
83  return !std::isnan(this->current_temperature) && !std::isnan(this->target_temperature) &&
84  this->current_temperature > 1 && this->target_temperature > 1;
85  }
86 };
88 } // namespace bedjet
89 } // namespace esphome
91 #endif
void on_bedjet_state(bool is_ready) override
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
void set_supported_custom_presets(std::set< std::string > supported_custom_presets)
void set_visual_temperature_step(float temperature_step)
float target_temperature
The target temperature of the climate device.
Definition: climate.h:183
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition: component.cpp:25
void reset_state_()
Resets states to defaults.
This class contains all static data for climate devices.
void add_supported_custom_preset(const std::string &preset)
void set_visual_min_temperature(float visual_min_temperature)
The climate device is set to heat to reach the target temperature.
Definition: climate_mode.h:18
ClimateMode mode
The active mode of the climate device.
Definition: climate.h:175
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition: climate.h:179
This class simplifies creating components that periodically check a state.
Definition: component.h:267
The climate device is set to dry/humidity mode.
Definition: climate_mode.h:22
void set_supported_presets(std::set< ClimatePreset > presets)
The format of a BedJet V3 status packet.
Definition: bedjet_codec.h:39
bool update_status_()
Attempts to update the climate device from the last received BedjetStatusPacket.
std::string describe() override
HVACMode.HEAT is handled using BTN_EXTHT.
Definition: bedjet_const.h:40
void control(const climate::ClimateCall &call) override
climate::ClimateTraits traits() override
float get_setup_priority() const override
void set_supported_modes(std::set< ClimateMode > modes)
void set_visual_max_temperature(float visual_max_temperature)
void set_heating_mode(BedjetHeatMode mode)
Sets the default strategy to use for climate::CLIMATE_MODE_HEAT.
The climate device is off.
Definition: climate_mode.h:12
void set_supports_action(bool supports_action)
Device is in boost preset.
Definition: climate_mode.h:88
Optional heating strategies to use for climate::CLIMATE_MODE_HEAT.
Definition: bedjet_const.h:36
Definition: a4988.cpp:4
void set_supports_current_temperature(bool supports_current_temperature)
void set_supported_custom_fan_modes(std::set< std::string > supported_custom_fan_modes)
The climate device only has the fan enabled, no heating or cooling is taking place.
Definition: climate_mode.h:20
void on_status(const BedjetStatusPacket *data) override
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:167
HVACMode.HEAT is handled using BTN_HEAT (default)
Definition: bedjet_const.h:38