ESPHome  2024.12.2
bedjet_climate.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/defines.h"
5 #include "esphome/core/hal.h"
10 
11 #ifdef USE_ESP32
12 
13 namespace esphome {
14 namespace bedjet {
15 
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; }
23 
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;
28 
33 
41  // climate::CLIMATE_MODE_TURBO // Not supported by Climate: see presets instead
44  });
45 
46  // It would be better if we had a slider for the fan modes.
47  traits.set_supported_custom_fan_modes(BEDJET_FAN_STEP_NAMES_SET);
49  // If we support NONE, then have to decide what happens if the user switches to it (turn off?)
50  // climate::CLIMATE_PRESET_NONE,
51  // Climate doesn't have a "TURBO" mode, but we can use the BOOST preset instead.
53  });
55  // We could fetch biodata from bedjet and set these names that way.
56  // But then we have to invert the lookup in order to send the right preset.
57  // For now, we can leave them as M1-3 to match the remote buttons.
58  // EXT HT added to match remote button.
59  "EXT HT",
60  "M1",
61  "M2",
62  "M3",
63  });
64  if (this->heating_mode_ == HEAT_MODE_EXTENDED) {
66  } else {
68  }
72  return traits;
73  }
74 
75  protected:
76  void control(const climate::ClimateCall &call) override;
77 
80 
81  void reset_state_();
82  bool update_status_();
83 
84  bool is_valid_() {
85  // FIXME: find a better way to check this?
86  return !std::isnan(this->current_temperature) && !std::isnan(this->target_temperature) &&
87  this->current_temperature > 1 && this->target_temperature > 1;
88  }
89 };
90 
91 } // namespace bedjet
92 } // namespace esphome
93 
94 #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:186
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition: component.cpp:26
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:173
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:283
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
void set_temperature_source(BedjetTemperatureSource source)
Sets the temperature source to use for the climate entity&#39;s current temperature.
bool is_ready() const
Definition: component.cpp:144
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:90
BedjetHeatMode
Optional heating strategies to use for climate::CLIMATE_MODE_HEAT.
Definition: bedjet_const.h:36
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_supports_current_temperature(bool supports_current_temperature)
void set_supported_custom_fan_modes(std::set< std::string > supported_custom_fan_modes)
BedjetTemperatureSource temperature_source_
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:168
HVACMode.HEAT is handled using BTN_HEAT (default)
Definition: bedjet_const.h:38