Hitachi AC IR Climate problem #1877
-
The problemHi guys.
esphome:
name: tuya-ir
platform: ESP8266
board: esp01_1m
includes:
- include/hitachi_ir.h
libraries:
- crankyoldgit/IRremoteESP8266@^2.8.2
platformio_options:
build_flags:
- -DSEND_HITACHI_AC264
- -DDEBUG_AC
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
password: !secret esphome_api_password
ota:
password: !secret esphome_api_password
# Use the blue LED as a status light.
# Blink slowly = Temporary issue (WiFi/MQTT disconnected, sensor unavailable, ...)
# Blink quickly = Error encountered
status_led:
pin: GPIO4
# Configure the IR receiver. Handy to pickup confirmation messages
# from your AC (or capture commands from the actual remote)
remote_receiver:
pin:
number: GPIO5
inverted: true
mode:
input: true
pullup: true
# high 55% tolerance is recommended for some remote control units
tolerance: 55%
dump: raw # all or raw for my case
# Configure the IR LED: this one sends commands to other devices
remote_transmitter:
pin: GPIO14
carrier_duty_percent: 50%
# Configure the AC unit you have. Mine is a Hitachi.
switch:
- platform: template
name: Turn On A/C
turn_on_action:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
# Hitachi AC 24C FanLow SwingOff
code: [3442, -1657, 440, -1260, 440, -410, 439, -410, 464, -386, 440, -409, 440, -412, 438, -410, 440, -409, 467, -383, 444, -406, 466, -383, 441, -409, 465, -1235, 439, -410, 464, -386, 440, -410, 463, -387, 463, -385, 465, -385, 465, -385, 443, -407, 440, -410, 439, -410, 465, -384, 465, -385, 440, -410, 440, -410, 439, -411, 439, -410, 440, -410, 440, -1259, 441, -409, 440, -1259, 441, -1258, 443, -1257, 439, -1261, 443, -1255, 441, -1259, 466, -383, 440, -1260, 440, -1259, 440, -1259, 445, -1255, 440, -1260, 438, -1260, 440, -1259, 440, -1260, 465, -1235, 444, -405, 465, -385, 440, -409, 465, -385, 439, -411, 439, -410, 440, -410, 465, -384, 465, -385, 441, -412, 437, -1262, 438, -1259, 440, -410, 439, -410, 464, -1235, 440, -1259, 440, -1260, 441, -1258, 441, -409, 463, -386, 466, -1234, 463, -1237, 440, -409, 441, -408, 440, -414, 460, -1236, 439, -410, 441, -410, 439, -1259, 442, -408, 466, -384, 466, -1233, 441, -1259, 440, -411, 463, -1235, 441, -1257, 442, -408, 465, -1235, 441, -1258, 464, -385, 441, -1259, 440, -1260, 442, -407, 441, -409, 440, -1259, 440, -410, 464, -385, 466, -384, 468, -382, 466, -383, 465, -1235, 466, -1232, 466, -385, 442, -1257, 466, -1233, 466, -1234, 439, -411, 439, -410, 464, -386, 467, -385, 463, -384, 465, -1235, 440, -1259, 439, -411, 464, -1235, 439, -1260, 440, -1260, 466, -1236, 440, -1257, 440, -409, 464, -385, 441, -1259, 441, -409, 440, -410, 439, -412, 439, -409, 440, -409, 465, -385, 466, -388, 436, -410, 439, -1259, 441, -1259, 465, -1235, 439, -1260, 441, -1258, 465, -1235, 439, -1260, 440, -1259, 442, -408, 468, -381, 441, -409, 465, -385, 439, -411, 440, -409, 440, -410, 444, -406, 441, -1262, 436, -1261, 440, -1258, 439, -1260, 441, -1258, 442, -1258, 440, -1260, 439, -1259, 440, -410, 440, -410, 440, -410, 439, -410, 466, -383, 440, -411, 441, -408, 440, -411, 439, -1259, 466, -1233, 465, -1235, 440, -1262, 438, -1258, 487, -1212, 467, -1233, 440, -1260, 440, -409, 440, -410, 440, -409, 441, -409, 465, -385, 464, -385, 442, -410, 464, -383, 442, -1258, 465, -1234, 442, -1257, 465, -1235, 440, -1259, 441, -1258, 466, -1234, 444, -1255, 465, -386, 438, -411, 464, -387, 463, -385, 464, -386, 465, -385, 440, -410, 465, -385, 439, -1259, 441, -1259, 440, -1259, 464, -1235, 440, -1260, 438, -1261, 466, -1233, 440, -1260, 439, -1260, 441, -1258, 440, -410, 464, -386, 464, -1235, 465, -384, 465, -385, 442, -408, 441, -409, 439, -411, 439, -1260, 464, -1235, 465, -384, 441, -1259, 440, -1260, 440, -1258, 466, -1238, 437, -408, 467, -383, 465, -385, 443, -1256, 465, -384, 465, -1235, 443, -1256, 465, -385, 464, -1236, 442, -1258, 438, -1261, 438, -411, 465, -1234, 466, -388, 462, -383, 466, -1234, 443, -407, 445, -1254, 465, -384, 442, -409, 438, -410, 466, -385, 441, -409, 440, -409, 464, -1235, 440, -410, 440, -1259, 440, -1260, 441, -1258, 440, -1260, 439, -1260, 469, -1230, 440, -410, 465, -385, 440, -1258, 442, -409, 440, -411, 438, -410, 440, -409, 441, -410, 440, -1258, 465, -1235, 465, -385, 440, -1258, 441, -1259, 466, -1237, 437, -1259, 465]
- platform: template
name: Turn On A/C Swing Toggle
turn_on_action:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
# Hitachi AC 24C FanLow Toggle
code: [3440, -1656, 441, -1258, 445, -406, 440, -409, 465, -384, 466, -384, 466, -384, 440, -410, 465, -384, 442, -408, 441, -408, 467, -383, 456, -394, 464, -1235, 465, -385, 466, -384, 465, -385, 440, -409, 446, -404, 441, -409, 465, -384, 465, -388, 436, -412, 439, -409, 464, -386, 465, -384, 466, -385, 465, -384, 466, -383, 442, -408, 441, -409, 465, -1234, 464, -386, 465, -1234, 466, -1233, 441, -1259, 440, -1260, 440, -1259, 465, -1234, 440, -410, 464, -1235, 443, -1257, 440, -1259, 465, -1234, 442, -1258, 441, -1259, 439, -1260, 465, -1234, 441, -1258, 439, -411, 441, -408, 442, -408, 466, -384, 439, -411, 465, -384, 440, -410, 465, -385, 465, -385, 440, -409, 440, -1261, 463, -1235, 440, -410, 441, -408, 465, -1234, 466, -1234, 440, -1260, 440, -1259, 441, -409, 441, -408, 441, -1258, 440, -1263, 437, -410, 465, -384, 466, -383, 465, -1235, 441, -409, 469, -381, 465, -1234, 440, -410, 464, -388, 462, -1234, 466, -1234, 441, -408, 465, -1234, 442, -1259, 467, -382, 441, -1261, 441, -1256, 440, -410, 440, -1259, 444, -406, 464, -385, 466, -384, 441, -409, 440, -410, 465, -384, 440, -1260, 464, -385, 465, -1234, 441, -1259, 468, -1231, 466, -1233, 441, -1259, 464, -1235, 441, -409, 465, -384, 466, -387, 464, -384, 463, -386, 466, -383, 440, -1259, 465, -1235, 440, -409, 465, -1235, 465, -1234, 440, -1260, 441, -1258, 439, -1261, 464, -384, 441, -410, 460, -1239, 466, -384, 469, -381, 461, -388, 464, -388, 437, -410, 464, -386, 442, -408, 464, -386, 445, -1255, 465, -1233, 465, -1235, 441, -1260, 441, -1256, 441, -1259, 440, -1259, 465, -1234, 441, -409, 464, -386, 466, -384, 440, -409, 440, -411, 439, -410, 464, -385, 466, -384, 469, -1231, 440, -1259, 440, -1259, 441, -1259, 444, -1255, 442, -1258, 438, -1261, 440, -1259, 440, -410, 440, -410, 440, -410, 439, -410, 466, -384, 465, -384, 465, -385, 464, -385, 466, -1234, 465, -1234, 466, -1234, 440, -1262, 436, -1261, 439, -1260, 464, -1235, 441, -1258, 463, -387, 464, -386, 466, -383, 467, -383, 441, -409, 441, -408, 465, -386, 464, -386, 441, -1257, 441, -1258, 466, -1234, 440, -1259, 440, -1260, 465, -1234, 440, -1260, 439, -1260, 440, -409, 441, -409, 466, -384, 441, -409, 465, -384, 465, -385, 465, -385, 439, -411, 468, -1231, 440, -1259, 441, -1258, 440, -1260, 440, -1259, 466, -1233, 466, -1233, 465, -1235, 441, -1258, 466, -1235, 440, -412, 441, -405, 441, -1259, 465, -384, 465, -385, 466, -384, 465, -385, 440, -410, 465, -1236, 463, -1234, 465, -384, 441, -1259, 441, -1258, 440, -1261, 439, -1258, 443, -408, 464, -386, 464, -386, 463, -1237, 443, -405, 441, -1259, 440, -1258, 441, -410, 464, -1235, 441, -1259, 465, -1233, 442, -408, 465, -1235, 440, -409, 443, -407, 441, -1259, 442, -407, 466, -1234, 440, -409, 441, -409, 440, -410, 464, -385, 441, -408, 467, -384, 466, -1233, 440, -410, 464, -1236, 439, -1259, 440, -1260, 440, -1259, 441, -1259, 440, -1259, 440, -410, 440, -409, 440, -1260, 441, -408, 464, -388, 463, -384, 465, -385, 465, -387, 463, -1234, 440, -1260, 440, -409, 466, -1234, 439, -1260, 441, -1258, 466, -1234, 440]
- platform: template
name: Turn Off A/C
turn_on_action:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
# Hitachi AC TurnOff:
code: [3438, -1658, 442, -1259, 439, -410, 465, -385, 440, -409, 466, -384, 440, -410, 440, -409, 465, -384, 467, -383, 466, -384, 441, -409, 441, -409, 439, -1260, 465, -384, 466, -384, 465, -384, 441, -410, 440, -409, 440, -410, 466, -384, 441, -408, 441, -409, 465, -384, 447, -403, 441, -409, 440, -409, 454, -400, 462, -385, 465, -383, 466, -384, 439, -1261, 463, -386, 465, -1234, 441, -1259, 448, -1251, 440, -1261, 439, -1259, 440, -1260, 440, -410, 463, -1236, 439, -1260, 465, -1234, 465, -1234, 441, -1260, 439, -1259, 440, -1260, 464, -1235, 441, -1258, 465, -386, 440, -408, 466, -385, 439, -410, 466, -384, 440, -410, 439, -409, 466, -385, 464, -385, 440, -409, 441, -1259, 440, -1259, 439, -412, 465, -384, 466, -1233, 465, -1234, 465, -1235, 466, -1233, 440, -410, 466, -383, 442, -1258, 441, -1259, 464, -385, 466, -384, 464, -386, 440, -1259, 440, -410, 440, -410, 464, -1234, 467, -383, 440, -410, 465, -1234, 466, -1234, 439, -411, 464, -1235, 439, -1260, 465, -385, 443, -1256, 465, -1234, 464, -386, 439, -1261, 470, -1230, 439, -410, 440, -409, 466, -1233, 466, -384, 440, -410, 465, -385, 440, -409, 466, -389, 436, -1258, 466, -1233, 440, -410, 440, -1261, 439, -1260, 439, -1260, 440, -409, 441, -409, 464, -385, 441, -409, 440, -410, 439, -1260, 464, -1235, 465, -385, 464, -1236, 458, -1241, 441, -1259, 440, -1259, 440, -1259, 441, -409, 442, -407, 466, -1234, 439, -411, 466, -383, 466, -384, 465, -384, 442, -408, 440, -410, 464, -386, 465, -384, 442, -1258, 465, -1234, 440, -1259, 465, -1234, 440, -1260, 441, -1259, 440, -1259, 441, -1258, 440, -410, 465, -384, 441, -409, 440, -410, 467, -384, 463, -385, 441, -410, 439, -410, 440, -1259, 441, -1259, 465, -1234, 441, -1262, 440, -1255, 466, -1233, 466, -1234, 440, -1260, 440, -412, 462, -385, 440, -409, 464, -386, 442, -408, 465, -385, 464, -385, 440, -411, 439, -1259, 465, -1235, 440, -1259, 468, -1231, 440, -1261, 439, -1260, 442, -1256, 440, -1259, 441, -410, 445, -406, 464, -384, 464, -385, 466, -384, 441, -409, 440, -409, 440, -411, 463, -1235, 441, -1263, 461, -1234, 465, -1235, 440, -1260, 439, -1260, 440, -1259, 464, -1235, 466, -384, 465, -385, 441, -408, 466, -384, 440, -410, 464, -385, 441, -413, 435, -411, 440, -1259, 440, -1260, 440, -1259, 440, -1262, 436, -1261, 440, -1258, 441, -1259, 440, -1259, 464, -1235, 456, -1249, 439, -406, 465, -385, 464, -1235, 440, -410, 440, -410, 439, -411, 441, -408, 465, -384, 440, -1260, 465, -1234, 464, -386, 466, -1233, 440, -1260, 464, -1234, 442, -1258, 465, -385, 440, -410, 439, -410, 439, -411, 439, -410, 441, -1260, 467, -1231, 468, -382, 440, -1259, 440, -1260, 464, -1235, 466, -1233, 468, -1231, 442, -409, 464, -385, 465, -1234, 441, -410, 464, -1235, 440, -410, 441, -408, 466, -383, 441, -410, 465, -385, 440, -409, 464, -1235, 465, -385, 440, -1259, 440, -1259, 465, -1235, 441, -1258, 440, -1260, 440, -1259, 440, -409, 463, -388, 438, -1260, 466, -384, 469, -381, 466, -383, 467, -383, 465, -385, 453, -1246, 465, -1235, 441, -408, 440, -1259, 466, -1234, 465, -1234, 441, -1259, 440]
climate:
- platform: custom
lambda: |-
auto my_hitachiac = new HitachiAC();
App.register_component(my_hitachiac);
return {my_hitachiac};
climates:
- name: "Master Bedroom AC"
#include "esphome.h"
#include "IRremoteESP8266.h"
#include "IRsend.h"
#include "ir_Hitachi.h"
///This code is relevant for cases where the IR control for an AC is available in IRremoteESP8266, but isn't supported yet in Esphome
const uint16_t kIrLed = 14; // ESP8266 GPIO pin to use. Recommended: 0 (D3).
const bool inverted = false;
const bool use_modulation = true;
IRHitachiAc264 ac(kIrLed, inverted, use_modulation);
// Setup files. This is the equivalent of the code written in the setup loop of Arduino
class HitachiAC : public Component, public Climate { public: void setup() override {
// Setup pins etc
ac.begin();
// AC model. This is only relevant in cases where the ir_company.h requires a model (i.e. the signals change by model)
// ac.setModel(R_LT0541_HTA_A);
delay(200);
// Setting up base conditions, so that the system doesn't send garbage to begin with
ac.setTemp(24);
ac.setFan(kHitachiAc264FanAuto);
// ac.setSwingV(true);
ac.off();
// Setting up base conditions transferred to Home Assistant, so that there's no garbage at initialization
this->mode = mode;
this->fan_mode = CLIMATE_FAN_AUTO;
this->swing_mode = CLIMATE_SWING_VERTICAL;
this->target_temperature = 24;
this->publish_state();
}
// Traits: This tells home assistant what "traits" are supported by AC in terms of heating/cooling/fan speeds/swing modes. These are used by Home Assistant to customize the AC card on your dashboard
climate::ClimateTraits traits() {
auto traits = climate::ClimateTraits();
traits.set_supports_current_temperature(false);
traits.set_supports_two_point_target_temperature(false);
traits.set_supported_modes({
climate::CLIMATE_MODE_OFF,
climate::CLIMATE_MODE_HEAT,
climate::CLIMATE_MODE_DRY,
climate::CLIMATE_MODE_COOL,
climate::CLIMATE_MODE_FAN_ONLY,
//Adding this leads to esphome data not showing on Home Assistant somehow, hence skipping. Others please try and let me know
});
traits.set_supported_fan_modes({
climate::CLIMATE_FAN_AUTO,
climate::CLIMATE_FAN_LOW,
climate::CLIMATE_FAN_MEDIUM,
climate::CLIMATE_FAN_HIGH,
});
traits.set_supported_swing_modes({
climate::CLIMATE_SWING_OFF,
climate::CLIMATE_SWING_VERTICAL,
});
traits.set_visual_min_temperature(16);
traits.set_visual_max_temperature(30);
traits.set_visual_temperature_step(1);
return traits;
}
//Code for what to do when the mode of the AC is changed on the dashboard
void control(const ClimateCall &call) override {
if (call.get_mode().has_value()) {
// User requested mode change
ClimateMode mode = *call.get_mode();
// Send mode to hardware
//You need an condition of each of the supported modes mentioned in the traits section above
//For each mode, you need to find the relevant mode from the list of constants. This list can be found in the relevant .h library from IRremoteESP8266 library. In this case the file is "ir_Hitachi.h". Typically the function should be the same - .setMode. However, best check the relevant .h library.
if (mode == CLIMATE_MODE_OFF) {
ac.off();
} else if (mode == CLIMATE_MODE_HEAT) {
ac.on();
ac.setMode(kHitachiAc264Heat);
} else if (mode == CLIMATE_MODE_DRY) {
ac.on();
ac.setMode(kHitachiAc264Dry);
} else if (mode == CLIMATE_MODE_COOL) {
ac.on();
ac.setMode(kHitachiAc264Cool);
} else if (mode == CLIMATE_MODE_FAN_ONLY) {
ac.on();
ac.setMode(kHitachiAc264Fan);
}
// Publish updated state
this->mode = mode;
this->publish_state();
}
//Code for what to do when the fan speed / mode is changed on the dashboard
if (call.get_fan_mode().has_value()) {
// User requested fan mode change
ClimateFanMode fan_mode = *call.get_fan_mode();
// Send fan mode to hardware
if (fan_mode == CLIMATE_FAN_AUTO) {
ac.setFan(kHitachiAc264FanAuto);
} else if (fan_mode == CLIMATE_FAN_LOW) {
ac.setFan(kHitachiAc264FanMin);
} else if (fan_mode == CLIMATE_FAN_MEDIUM) {
ac.setFan(kHitachiAc264FanMedium);
} else if (fan_mode == CLIMATE_FAN_HIGH) {
ac.setFan(kHitachiAc264FanHigh);
}
this->fan_mode = fan_mode;
this->publish_state();
}
//Code for what to do when the swing mode is changed on the dashboard
//Check what function is available in the relevant .h file. For example, .setSwingV is the relevant function in ir_Hitachi.h, but it is .setSwingVertical in some others
if (call.get_swing_mode().has_value()) {
// User requested fan mode change
ClimateSwingMode swing_mode = *call.get_swing_mode();
// Send fan mode to hardware
if (swing_mode == CLIMATE_SWING_OFF) {
ac.setSwingVToggle(false);
} else if (swing_mode == CLIMATE_SWING_VERTICAL) {
ac.setSwingVToggle(true);
}
this->swing_mode = swing_mode;
this->publish_state();
}
//Code for what to do when the temperature is changed on the dashboard
if (call.get_target_temperature().has_value()) {
// User requested target temperature change
float temp = *call.get_target_temperature();
// Send target temp to climate
ac.setTemp(temp);
this->target_temperature = temp;
this->publish_state();
}
//Send the IR code you've built basis all the above data
ac.send();
#if DEBUG_AC
ESP_LOGD("DEBUG", "Home A/C remote is in the following state:");
ESP_LOGD("DEBUG", "%s\n", ac.toString().c_str());
#endif // DEBUG_AC
}
};
Which version of ESPHome has the issue?2.8.2 What type of installation are you using?Home Assistant Add-on Which version of Home Assistant has the issue?2022.9.2 What platform are you using?ESP8266 BoardNo response Component causing the issueNo response Example YAML snippetNo response Anything in the logs that might be useful for us?No response Additional informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Why are you asking us for how to get it to work with home assistant rather than with FYI, currently the Lines 1413 to 1418 in 1f00aeb |
Beta Was this translation helpful? Give feedback.
-
And I've now created a special FAQ item on this topic as well as this sort of thing seems to come up a lot. |
Beta Was this translation helpful? Give feedback.
And I've now created a special FAQ item on this topic as well as this sort of thing seems to come up a lot.