9static constexpr std::array MODE_MAP{
17static constexpr std::array FAN_MODE_MAP{
26template<
typename A,
typename B, std::
size_t N>
27static bool map_lookup(
const std::array<std::pair<A, B>, N> &map, A
key, B &
out) {
28 for (
const auto &[from, to] : map) {
37template<
typename Left,
typename Right, std::
size_t N>
38static constexpr std::optional<Left> reverse_map_lookup(
const std::array<std::pair<Left, Right>, N> &map, Right
key) {
39 for (
const auto &entry : map) {
40 if (entry.second ==
key) {
47template<
typename Left,
typename Right, std::
size_t N>
48static constexpr std::optional<Left> reverse_map_lookup(
const std::array<std::pair<Left, Right>, N> &map,
49 const std::optional<Right> &
key) {
50 return key.has_value() ? reverse_map_lookup(map, *
key) :
std::nullopt;
54 const MitsubishiCN105::Status &status,
79 LOG_CLIMATE(
"",
"Mitsubishi CN105 Climate",
this);
80 ESP_LOGCONFIG(TAG,
" Temperature unit: °%c",
81 this->
parent_->get_temperature_mapping().get_use_fahrenheit() ?
'F' :
'C');
86 if (this->
parent_->is_status_initialized()) {
94 for (
const auto &p : MODE_MAP) {
98 for (
const auto &p : FAN_MODE_MAP) {
104 const bool use_fahrenheit = this->
parent_->get_temperature_mapping().get_use_fahrenheit();
110 if (this->
parent_->is_telemetry_polling_enabled()) {
123 if (
const auto mode =
call.get_mode()) {
125 this->
parent_->set_power(
false);
126 }
else if (
const auto mapped = reverse_map_lookup(MODE_MAP, *
mode)) {
127 this->
parent_->set_power(
true);
128 this->
parent_->set_mode(*mapped);
132 if (
const auto fan_mode = reverse_map_lookup(FAN_MODE_MAP,
call.get_fan_mode())) {
138 this->
parent_->set_vane_mode(*vane);
141 this->
parent_->set_wide_vane_mode(*wide);
145 this->
parent_->publish_status();
149 const auto &status = this->
parent_->status();
154 if (!map_lookup(MODE_MAP,
status.mode, this->mode)) {
155 ESP_LOGD(TAG,
"Unable to map mode");
161 if (this->
parent_->is_telemetry_polling_enabled()) {
170 ESP_LOGD(TAG,
"Unable to map fan mode");
BedjetMode mode
BedJet operating mode.
constexpr void insert(ValueType value)
Add a single value to the set (std::set compatibility)
MitsubishiCN105Component * parent_
This class is used to encode all control actions on a climate device.
const optional< ClimateSwingMode > & get_swing_mode() const
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
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.
void set_visual_max_temperature(float visual_max_temperature)
void add_feature_flags(uint32_t feature_flags)
void add_supported_fan_mode(ClimateFanMode mode)
void set_visual_temperature_step(float temperature_step)
void set_supported_swing_modes(ClimateSwingModeMask modes)
void set_visual_min_temperature(float visual_min_temperature)
void set_temperature_unit(TemperatureUnit unit)
void set_visual_current_temperature_step(float temperature_step)
void add_supported_mode(ClimateMode mode)
void control(const climate::ClimateCall &call) override
void dump_config() override
climate::ClimateTraits traits() override
SwingModeManager swing_mode_manager_
void set_supported_swing_mode(climate::ClimateSwingMode mode)
void set_supported_swing_modes(const climate::ClimateSwingModeMask &supported_swing_modes)
std::optional< climate::ClimateSwingMode > update_and_get_swing_mode(MitsubishiCN105::VaneMode vane_mode, MitsubishiCN105::WideVaneMode wide_vane_mode)
const climate::ClimateSwingModeMask & supported_swing_modes() const
std::optional< MitsubishiCN105::WideVaneMode > wide_vane_from(climate::ClimateSwingMode swing_mode) const
std::optional< MitsubishiCN105::VaneMode > vane_from(climate::ClimateSwingMode swing_mode) const
std::vector< uint8_t > & out
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_SUPPORTS_ACTION
ClimateSwingMode
Enum for all modes a climate swing can be in NOTE: If adding values, update ClimateSwingModeMask in c...
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
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_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
@ CLIMATE_ACTION_OFF
The climate device is off (inactive or no power)
@ 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_ACTION_FAN
The climate device is in fan only mode.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_MIDDLE
The fan mode is set to Middle.
@ CLIMATE_FAN_QUIET
The fan mode is set to Quiet.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
ESPHOME_LOG_TAG(TAG, "mitsubishi_cn105.driver")