forked from esphome/esphome
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
117 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "mitp_select.h" | ||
|
||
namespace esphome { | ||
namespace mitsubishi_itp { | ||
|
||
void VanePositionSelect::process_packet(const SettingsGetResponsePacket &packet) { | ||
switch (packet.get_vane()) { | ||
case SettingsSetRequestPacket::VANE_AUTO: | ||
mitp_select_value_ = std::string("Auto"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_1: | ||
mitp_select_value_ = std::string("1"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_2: | ||
mitp_select_value_ = std::string("2"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_3: | ||
mitp_select_value_ = std::string("3"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_4: | ||
mitp_select_value_ = std::string("4"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_5: | ||
mitp_select_value_ = std::string("5"); | ||
break; | ||
case SettingsSetRequestPacket::VANE_SWING: | ||
mitp_select_value_ = std::string("Swing"); | ||
break; | ||
default: | ||
ESP_LOGW(TAG, "Vane in unknown position %x", packet.get_vane()); | ||
} | ||
} | ||
|
||
void HorizontalVanePositionSelect::process_packet(const SettingsGetResponsePacket &packet) { | ||
switch (packet.get_horizontal_vane()) { | ||
case SettingsSetRequestPacket::HV_AUTO: | ||
mitp_select_value_ = std::string("Auto"); | ||
break; | ||
case SettingsSetRequestPacket::HV_LEFT_FULL: | ||
mitp_select_value_ = std::string("<<"); | ||
break; | ||
case SettingsSetRequestPacket::HV_LEFT: | ||
mitp_select_value_ = std::string("<"); | ||
break; | ||
case SettingsSetRequestPacket::HV_CENTER: | ||
mitp_select_value_ = std::string(""); | ||
break; | ||
case SettingsSetRequestPacket::HV_RIGHT: | ||
mitp_select_value_ = std::string(">"); | ||
break; | ||
case SettingsSetRequestPacket::HV_RIGHT_FULL: | ||
mitp_select_value_ = std::string(">>"); | ||
break; | ||
case SettingsSetRequestPacket::HV_SPLIT: | ||
mitp_select_value_ = std::string("<>"); | ||
break; | ||
case SettingsSetRequestPacket::HV_SWING: | ||
mitp_select_value_ = std::string("Swing"); | ||
break; | ||
default: | ||
ESP_LOGW(TAG, "Vane in unknown horizontal position %x", packet.get_horizontal_vane()); | ||
} | ||
} | ||
} // namespace mitsubishi_itp | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "mitp_text-sensor.h" | ||
|
||
namespace esphome { | ||
namespace mitsubishi_itp { | ||
|
||
void ErrorCodeSensor::process_packet(const ErrorStateGetResponsePacket &packet) { | ||
// TODO: Include friendly text from JSON, somehow. | ||
if (!packet.error_present()) { | ||
mitp_text_sensor_state_ = std::string("No Error Reported"); | ||
} else if (auto raw_code = packet.get_raw_short_code() != 0x00) { | ||
// Not that it matters, but good for validation I guess. | ||
if ((raw_code & 0x1F) > 0x15) { | ||
ESP_LOGW(LISTENER_TAG, "Error short code %x had invalid low bits. This is an IT protocol violation!", raw_code); | ||
} | ||
|
||
mitp_text_sensor_state_ = "Error " + packet.get_short_code(); | ||
} else { | ||
mitp_text_sensor_state_ = "Error " + to_string(packet.get_error_code()); | ||
} | ||
} | ||
|
||
} // namespace mitsubishi_itp | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters