Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can help join HITACHI RAR-2P2 remote (264 bit) #1729

Closed
step3528 opened this issue Jan 6, 2022 · 47 comments · Fixed by #1735
Closed

Can help join HITACHI RAR-2P2 remote (264 bit) #1729

step3528 opened this issue Jan 6, 2022 · 47 comments · Fixed by #1735
Assignees

Comments

@step3528
Copy link

step3528 commented Jan 6, 2022

Version/revision of the library used

Version of the library : 2.8.1

Describe the bug

My air conditioner is Hitachi RAK-25NH5 with RAR-2P2 remote, which is unrecognizable, can help to join?

the protocol appears to be just a shorter version of HITACHI.
view #1134

same value for Temperature

I created this file.

https://docs.google.com/spreadsheets/d/1qDnKM3ZslWrR-skgQjaConq3U2b7RuzZK1tA64WYRBM/edit?usp=sharing

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 6, 2022

Do you have at least one Raw dump using IRrecvDumpV3? (as asked for in the issue template)

@step3528
Copy link
Author

step3528 commented Jan 6, 2022

Hello,
Yes, i used IRrecvDumpV3.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 6, 2022

Please post the raw dump in the issue as text from at least one of the commands.

@step3528
Copy link
Author

step3528 commented Jan 6, 2022

attached the raw dump

hot/power off/ fan 1 /27°C**

PROTOCOL : Unknow
Code      : 0xC2B825B6 (266 Bits)
uint16_t rawData[531] = {3392, 1752,  372, 1356,  344, 504,  344, 504,  344, 480,  370, 480,  370, 478,  370, 478,  372, 480,  370, 478,  370, 480,  370, 478,  370, 480,  370, 1330,  370, 478,  370, 480,  370, 478,  370, 478,  370, 480,  370, 478,  370, 480,  370, 504,  346, 504,  344, 480,  370, 504,  346, 478,  370, 478,  370, 478,  372, 480,  370, 480,  370, 504,  346, 1330,  370, 480,  370, 1356,  346, 1330,  370, 1354,  346, 1328,  370, 1330,  370, 1328,  370, 478,  372, 1330,  370, 1328,  370, 1356,  346, 1354,  344, 1328,  372, 1354,  344, 1356,  344, 1330,  370, 1328,  372, 480,  370, 478,  370, 504,  346, 478,  372, 476,  372, 504,  346, 480,  370, 504,  344, 478,  372, 504,  344, 1328,  372, 1328,  372, 478,  370, 504,  346, 1330,  370, 1328,  372, 1328,  370, 1356,  344, 478,  370, 478,  370, 1356,  344, 1328,  372, 480,  370, 478,  372, 504,  346, 1330,  370, 478,  370, 480,  370, 1330,  370, 478,  370, 480,  370, 1328,  370, 1330,  370, 480,  372, 1352,  346, 1328,  372, 504,  346, 1328,  370, 1328,  370, 480,  370, 1328,  372, 1328,  370, 504,  344, 478,  372, 1330,  370, 478,  370, 480,  370, 480,  370, 478,  370, 480,  370, 1356,  346, 1328,  370, 480,  370, 1330,  370, 1330,  370, 1330,  370, 478,  370, 506,  344, 1328,  372, 1328,  372, 478,  372, 1330,  370, 1328,  372, 478,  370, 1330,  370, 1328,  372, 504,  344, 480,  370, 1330,  370, 504,  344, 504,  346, 1354,  346, 504,  346, 478,  372, 478,  370, 480,  370, 478,  370, 492,  358, 478,  370, 478,  370, 1328,  372, 1330,  370, 1328,  372, 1354,  346, 1328,  372, 1328,  370, 1330,  370, 1328,  372, 476,  372, 504,  346, 478,  372, 480,  370, 480,  370, 504,  344, 478,  370, 480,  370, 1328,  370, 1330,  372, 1328,  370, 1330,  370, 1330,  370, 1330,  368, 1330,  370, 1330,  370, 480,  370, 480,  370, 478,  370, 504,  344, 480,  370, 478,  370, 504,  344, 478,  372, 1328,  370, 1330,  370, 1330,  370, 1330,  370, 1328,  372, 1356,  344, 1330,  370, 1330,  370, 480,  370, 478,  370, 482,  368, 480,  370, 480,  370, 480,  370, 480,  370, 480,  370, 1330,  370, 1354,  346, 1330,  370, 1354,  346, 1330,  370, 1330,  370, 1330,  370, 1330,  370, 504,  346, 480,  370, 478,  372, 478,  372, 504,  344, 480,  370, 480,  370, 504,  344, 1330,  370, 1328,  370, 1330,  372, 1328,  370, 1354,  346, 1328,  370, 1330,  370, 1330,  370, 478,  370, 1330,  370, 1328,  372, 480,  370, 1330,  370, 480,  370, 480,  370, 480,  370, 1356,  344, 478,  370, 506,  344, 1330,  370, 478,  370, 1330,  372, 1354,  346, 1354,  346, 1328,  370, 478,  372, 478,  370, 480,  370, 504,  346, 480,  370, 1328,  370, 1330,  370, 478,  370, 1330,  370, 1328,  370, 1330,  372, 1354,  344, 1328,  372, 504,  346, 478,  370, 504,  346, 504,  346, 478,  370, 478,  370, 482,  368, 480,  370, 478,  370, 480,  370, 1328,  372, 1328,  370, 1330,  370, 1328,  370, 1328,  370, 1330,  370, 1354,  346, 1328,  372, 478,  370, 478,  370, 478,  372, 478,  372, 478,  372, 478,  372, 478,  370, 478,  372, 1330,  370, 1328,  370, 1328,  372, 1328,  372, 1330,  444, 1256,  370, 1330,  370, 1330,  442}

this is what I identified
state 11 et 12 : press button
on/off : 13 EC
change FAN : 42 BD
decrease T° : 43 BC
increase T° : 44 BD
shutter swing : 81 7E

State 25 et 26 :mode et FAN
cool : 3C
HOT : 69
FAN : 1E
DRY : 5A
AUTO : 78

FAN Auto : 5A
FAN 1 : 1E
FAN 2 : 3C
FAN 3 : 4B

state 27 et 28 : ON ou OFF
ON : D1 2E
OFF : C1 3E

crankyoldgit added a commit that referenced this issue Jan 7, 2022
* Add send (`sendHitachiAc264()`) & decode support.
* Add unit tests coverage including real world data.
* Fix up some typos.
* Minor refactor of some code.

For #1729
@crankyoldgit crankyoldgit self-assigned this Jan 7, 2022
@crankyoldgit
Copy link
Owner

I've added "basic" support for the protocol in PR #1730 / Branch: https://github.com/crankyoldgit/IRremoteESP8266/tree/rar-2p2

Please download that, test it works (both sending & decoding please), and base your analysis on those results in your spreadsheet/documentation.

It should be 33 bytes in LSB order now.

@crankyoldgit crankyoldgit added more info Pending Confirmation Waiting for confirmation from user labels Jan 7, 2022
@step3528
Copy link
Author

step3528 commented Jan 8, 2022

here are the results with IRrecvDumpV3

Timestamp : 002824.971
13:07:58.607 -> Library : v2.8.1
13:07:58.607 ->
13:07:58.607 -> Protocol : HITACHI_AC264
13:07:58.607 -> Code : 0x01100040BFFF00CC33926D13EC50AF00FF00FF00FF00FF00FF16E9C13E00FF00FF (264 Bits)

https://docs.google.com/spreadsheets/d/1qDnKM3ZslWrR-skgQjaConq3U2b7RuzZK1tA64WYRBM/edit?usp=sharing

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 8, 2022

Looks good so far.
Did you have a chance to also test sending?

@step3528
Copy link
Author

step3528 commented Jan 8, 2022

Yes i am tested with the program CommonAcControl, the console bip when sending hitachi344 message but she does not start.

@crankyoldgit
Copy link
Owner

You can't use the "common" IRac stuff yet for this protocol. You'll need to use the more basic IR send example code.

@step3528
Copy link
Author

step3528 commented Jan 9, 2022

I am tested with IRsenddemo to modify and the console start.
the message sent is detected by the console.
I tested on and OFF message

@crankyoldgit
Copy link
Owner

Excellent. Thanks for confirming. I'll merge that PR

@step3528
Copy link
Author

step3528 commented Jan 9, 2022

thank you.

crankyoldgit added a commit that referenced this issue Jan 9, 2022
* Add send (`sendHitachiAc264()`) & decode support.
* Add unit tests coverage including real world data.
* Fix up some typos.
* Minor refactor of some code.

For #1729
@crankyoldgit
Copy link
Owner

Ok, you're now at this stage: https://github.com/crankyoldgit/IRremoteESP8266/wiki/Adding-support-for-a-new-AC-protocol#working-out-the-details

We have already established the bit ordering and the checksum (i.e. every second byte after state[3], is the inverse of the previous byte.)

So, you need to analyse which bit(s) is critical to power etc. eg. state[27] has 0xD1/0b11010001 for on and 0xC1/0b11000001 for off, which means 0b00010000 is the bit that controls power, 1 for on, 0 for off.

You need to do that sort of documentation for all the controls you want supported. When you have that all done, let me know and I'll write the code for it.

Bonus points if you can document it like:

/// Native representation of a Hitachi 104-bit A/C message.
union Hitachi1Protocol{
uint8_t raw[kHitachiAc1StateLength]; ///< The state in native code.
struct {
// Byte 0~2
uint8_t pad[3];
// Byte 3
uint8_t :6;
uint8_t Model :2;
// Byte 4
uint8_t :8;
// Byte 5
uint8_t Fan :4;
uint8_t Mode :4;
// Byte 6
uint8_t :2;
uint8_t Temp :5; // stored in LSB order.
uint8_t :1;
// Byte 7
uint8_t OffTimerLow :8; // nr. of minutes
// Byte 8
uint8_t OffTimerHigh :8; // & in LSB order.
// Byte 9
uint8_t OnTimerLow :8; // nr. of minutes
// Byte 10
uint8_t OnTimerHigh :8; // & in LSB order.
// Byte 11
uint8_t SwingToggle :1;
uint8_t Sleep :3;
uint8_t PowerToggle :1;
uint8_t Power :1;
uint8_t SwingV :1;
uint8_t SwingH :1;
// Byte 12
uint8_t Sum :8;
};
};

@crankyoldgit crankyoldgit removed the Pending Confirmation Waiting for confirmation from user label Jan 9, 2022
@step3528
Copy link
Author

step3528 commented Jan 10, 2022

hello,

this is what I defined is it suitable
I can't insert as code

// / Représentation native d'un message A/C Hitachi 264 bits.
union HitachiAC264Protocole{
  uint8_t raw[ kHitachiAc264StateLength ] ;  // /< L'état dans le code natif.
  structure {
   struct {
    // Byte 0~10
    uint8_t pad0[11];
    // Byte 11
    uint8_t Button  :8;
    // Byte 12
    uint8_t       :8;
    // Byte 13
    uint8_t       :2;
    uint8_t Temp  :6;
    // Byte 14
    uint8_t       :8;
    // Byte 14~24
    uint8_t pad1[10];
    // Byte 25
    uint8_t Mode  :4;
    uint8_t Fan   :4;
    // Byte 26
    uint8_t       :8;
    // Byte 27
    uint8_t Power :8;
    // Byte 28
    uint8_t        :8;
    // Byte 29~32
    uint8_t pad2[4];

   } ;
} ;
// HitachiAc264
const uint8_t kHitachiAc264ButtonPowerMode = 0x13;
const uint8_t kHitachiAc264ButtonFan = 0x42;
const uint8_t kHitachiAc264ButtonTempDown = 0x43;
const uint8_t kHitachiAc264ButtonTempUp = 0x44;
const uint8_t kHitachiAc264ButtonSwing = 0x81;

//Temp min max for Cool Hot Dry (Fan no T°)
const uint8_t kHitachiAc264MinTemp = 16;   // 16C
const uint8_t kHitachiAc264MaxTemp = 32;   // 32C

const uint8_t kHitachiAc264Fan = 1;
const uint8_t kHitachiAc264Cool = 3;
const uint8_t kHitachiAc264Dry = 5;
const uint8_t kHitachiAc264Heat = 6;

const uint8_t kHitachiAc264FanLow = 1;
const uint8_t kHitachiAc264FanMedium = 3;
const uint8_t kHitachiAc264FanHigh = 4;
const uint8_t kHitachiAc264FanAuto = 5;
const uint8_t kHitachiAc264FanDry = 1; //mode dry only speed low
const uint8_t kHitachiAc264FanLowfan = 1;// mode Fan no speed fan auto
const uint8_t kHitachiAc264FanMediumfan = 3;
const uint8_t kHitachiAc264FanHighfan = 4;

const uint8_t kHitachiAc264PowerOn = 0xD1;
const uint8_t kHitachiAc264PowerOff = 0xC1;

@crankyoldgit
Copy link
Owner

const uint8_t kHitachiAc264ButtonPowerMode = 0x13;
const uint8_t kHitachiAc264ButtonFan = 0x42;
const uint8_t kHitachiAc264ButtonTempDown = 0x43;
const uint8_t kHitachiAc264ButtonTempUp = 0x44;
const uint8_t kHitachiAc264ButtonSwing = 0x81;

Which location do these values go into?

@crankyoldgit
Copy link
Owner

const uint8_t kHitachiAc264FanDry = 1; //mode dry only speed low
const uint8_t kHitachiAc264FanLowfan = 1;// mode Fan no speed fan auto

Why are these fan speeds the same?

@step3528
Copy link
Author

const uint8_t kHitachiAc264ButtonPowerMode = 0x13;
const uint8_t kHitachiAc264ButtonFan = 0x42;
const uint8_t kHitachiAc264ButtonTempDown = 0x43;
const uint8_t kHitachiAc264ButtonTempUp = 0x44;
const uint8_t kHitachiAc264ButtonSwing = 0x81;

Which location do these values go into?

these values ​​relate to byte 11 (button)

@step3528
Copy link
Author

const uint8_t kHitachiAc264FanDry = 1; //mode dry only speed low
const uint8_t kHitachiAc264FanLowfan = 1;// mode Fan no speed fan auto

Why are these fan speeds the same?

const uint8_t kHitachiAc264FanLowfan = 1;// mode Fan no speed fan auto
const uint8_t kHitachiAc264FanMediumfan = 3;
const uint8_t kHitachiAc264FanHighfan = 4;

these 3 lines can be deleted and add that in FAN mode auto speed is not possible.

@crankyoldgit
Copy link
Owner

I can't insert as code

When using multiple lines of code you need to use "```", not "`".

crankyoldgit added a commit that referenced this issue Jan 13, 2022
* Supports Power, Temp, Mode, & Fanspeed. That's it.
  - Effectively a parent class of `IRHitachiAc424`.
* Add `IRac` integration.
* Update & add unit tests.

Fixes #1729
@crankyoldgit crankyoldgit added the Pending Confirmation Waiting for confirmation from user label Jan 13, 2022
crankyoldgit added a commit that referenced this issue Jan 17, 2022
Per #1729 (comment)
This pretty much confirms `handleToggles()` isn't the problem.
@crankyoldgit
Copy link
Owner

@NiKiZe Just extended the test to verify handleToggles() isn't the problem/is behaving as expected. :-/

@crankyoldgit
Copy link
Owner

@step3528 Can you please include a copy of the "info" page on IRMQTTServer too please, after you've tried to turn it off via the Web Interface? It might give some useful info. :-/

@step3528
Copy link
Author

@step3528 Did you modify any of the IRMQTTServer header or source files at all? If so, what setting/defines/flags etc did you change?

I did not modify the file

@step3528 Can you please include a copy of the "info" page on IRMQTTServer too please, after you've tried to turn it off via the Web Interface? It might give some useful info. :-/

General
Hostname: ir_server
IP address: 192.168.0.70
MAC address: CC:50:E3:63:6D:93
Booted: 1 Minute 45 Seconds ago
Version: v1.6.0
Built: Jan 17 2022 11:41:11
Period Offset: -6us
IR Lib Version: 2.8.1
ESP8266 Core Version: 3.0.2
Free Sketch Space: 1444k
Cpu Freq: 80MHz
Sanity Check: Ok
IR Send GPIO(s): 4 (default)
Inverting GPIO output: Off
Total send requests: 1
Last message sent: FAILED (Never)
IR Recv GPIO: 14
Total IR Received: 0
Last IR Received: None (Never)
Duplicate WiFi networks: Show
Min WiFi signal required: 8%
Serial debugging: Off

MQTT Information
Server: 10.0.0.4:1883 (Disconnected Never)
Disconnections: 0
Buffer Size: 768 bytes
Client id: ir_server636d93
Command topic(s): ir_server/send, ir_server/send_0
Acknowledgements topic: ir_server/sent
IR Received topic: ir_server/received
Log topic: ir_server/log
LWT topic: ir_server/status
QoS: 1
Last MQTT command seen: (topic) 'None' (payload) 'None' (Never)
Total published: 3
Total received: 0

Climate Information
IR Send GPIO: 4
Last update source: HTTP
Total sent: 1
Last send: Ok (1 Minute 6 Seconds ago)
State listen period: 5 Seconds
State broadcast period: 10 Minutes
Last state broadcast: Never
Last discovery sent: Locked
Discovery topic: homeassistant/climate/ir_server/config
Command topics: ir_server/ac/cmnd/(protocol|model|power|mode|temp|fanspeed|swingv|swingh|quiet|turbo|light|beep|econo|sleep|filter|clean|use_celsius|resend)
State topics: ir_server/ac/stat/(protocol|model|power|mode|temp|fanspeed|swingv|swingh|quiet|turbo|light|beep|econo|sleep|filter|clean|use_celsius|resend)

I must have a problem at home because I tried with LG and IRrecvDumpV3.ino detected ON

crankyoldgit added a commit that referenced this issue Jan 19, 2022
This (and some other debugging) pretty much confirms the core library is doing what we hope/expect.
The problem pretty much has to be a bug in IRMQTTServer or a user-side problem.

For #1729
@crankyoldgit
Copy link
Owner

@step3528 I'm really stumped.

I've tested everything I can think of in the library itself. It all appears to be working as expected, and producing the correct hex/state codes.
The fact you've tested it with LG and it appears to be working indicates you are probably using IRMQTTServer correctly.
IRMQTTServer uses exactly the same code for parsing the web interface and turning power on & off for all AC protocols.
So it's unlikely that's the problem too.

I'm going to try hair-brained hail-mary suggestions/solutions now. Can you delete the library code you have on your computer. Download the latest copy from that branch, and build IRMQTTServer again from scratch, and wipe & re-flash the device.

@NiKiZe Basically the only things left to verify are:

  • Is @step3528 using the IRMQTTServer program correctly? (Probably is)
  • Perhaps @step3528 's build is corrupted in some funky way. (Unlikely)
  • A problem in sendClimate() in IRMQTTServer as described above. (Extremely unlikely as it's also working for LG for him).

@step3528
Copy link
Author

Sorry @crankyoldgit I have trouble expressing myself. I have the same problem with LG.

I will reinstall IRMQTTServer.

@crankyoldgit
Copy link
Owner

I have trouble expressing myself. I have the same problem with LG.

Ahhhh. That's helpful info. i.e. LG being broken too. That gives me something to work on.
But yes, please re-install.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 19, 2022

Add a test for the IRMQTTServer path that creates the packet. maybe there is on/off issues that is not propagating from generic to specific AC classes? (sorry short on time ATM)

@crankyoldgit
Copy link
Owner

@NiKiZe Yeah. I'm going to have to instrument IRMQTTServer more I think to debug what might be going on there.

I temporarily added debug stuff to print ac->toString() in IRac::hitachi264() just before the send() at:

IRremoteESP8266/src/IRac.cpp

Lines 1326 to 1345 in 56e48e2

void IRac::hitachi264(IRHitachiAc264 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan) {
ac->begin();
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setPower(on);
// No Swing(V) setting available.
// No Swing(H) setting available.
// No Quiet setting available.
// No Turbo setting available.
// No Light setting available.
// No Filter setting available.
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.
ac->send();
}

In the following (new) test:
// Check that IRac copies & modifies the states as we expect.
irac.next = on; // Copy in the "on" state we constructed earlier.
irac.sendAc(); // Send it.
irac.markAsSent(); // Confirm it was sent.
EXPECT_FALSE(irac.cmpStates(on, irac.getStatePrev())); // They are the same.
EXPECT_FALSE(irac.cmpStates(on, irac.getState())); // They are the same.
irac.next.power = false; // Turn off the power.
EXPECT_TRUE(irac.cmpStates(on, irac.getState())); // They are the different.
EXPECT_FALSE(off.power);
EXPECT_FALSE(irac.cmpStates(off, irac.getState())); // They are the same.
EXPECT_FALSE(irac.cmpStates(off, irac.next)); // They are the same.
irac.sendAc(); // Send it.
irac.markAsSent(); // Confirm it was sent.
EXPECT_FALSE(irac.cmpStates(off, irac.getStatePrev())); // They are the same.
EXPECT_FALSE(irac.cmpStates(off, irac.getState())); // They are the same.
EXPECT_FALSE(irac.cmpStates(off, irac.next)); // They are the same.
EXPECT_FALSE(irac.getStatePrev().power);
EXPECT_FALSE(irac.getState().power);
EXPECT_FALSE(irac.next.power);

it was working as expected.
e.g.

[ RUN      ] TestIRHitachiAc264Class.Issue1729_PowerOntoOff
/* Manually calling hitachi264() */
DEBUG: Power: On, Mode: 6 (Heat), Temp: 25C, Fan: 5 (Auto), Button: 19 (Power/Mode)
DEBUG: Power: Off, Mode: 6 (Heat), Temp: 25C, Fan: 5 (Auto), Button: 19 (Power/Mode)
/* Then calling it via IRac::sendAc()` */
DEBUG: Power: On, Mode: 6 (Heat), Temp: 25C, Fan: 5 (Auto), Button: 19 (Power/Mode)
DEBUG: Power: Off, Mode: 6 (Heat), Temp: 25C, Fan: 5 (Auto), Button: 19 (Power/Mode)
[       OK ] TestIRHitachiAc264Class.Issue1729_PowerOntoOff (1 ms)

So that leads me to think I'm doing something wrong in the IRMQTTServer code compared to the unit test code.

@step3528
Copy link
Author

sorry but I think it was me who did not use the interface correctly.

By carrying out a new test, I found that it was the "mode" parameter that allowed to turn off and not the "power" parameter.

image

I'm really sorry for the lost time.

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jan 19, 2022

So mode off is power off?
And power off makes no difference?

@step3528
Copy link
Author

So mode off is power off?

yes, it sends the message off with cool mode

Mesg Desc.: Power: Off, Mode: 3 (Cool), Temp: 25C, Fan: 5 (Auto), Button: 19 (Power/Mode)

And power off makes no difference?

yes power off has no action

@crankyoldgit
Copy link
Owner

crankyoldgit commented Jan 20, 2022

By carrying out a new test, I found that it was the "mode" parameter that allowed to turn off and not the "power" parameter.

Ahhhh. That makes all the difference in pinpointing the issue.

You need to change this parameter to false:

// Use Home Assistant-style operation modes.
// TL;DR: Power and Mode are linked together. One changes the other.
// i.e.
// - When power is set to "off", the mode is set to "off".
// - When the mode changes from "off" to something else, power is set to "on".
// See: https://www.home-assistant.io/components/climate.mqtt/#modes
// *** WARNING ***
// This setting will cause IRMQTTServer to forget what the previous operation
// mode was. e.g. a power "on" -> "off" -> "on" will cause it to use the
// default mode for your A/C, not the previous mode.
// Typically this is "Auto" or "Cool" mode.
// Change to false, if your home automation system doesn't like this, or if
// you want IRMQTTServer to be the authoritative source for controling your
// A/C.
#define MQTT_CLIMATE_HA_MODE true

i.e.

#define MQTT_CLIMATE_HA_MODE false

I'll look into fixing it (power doing what is expected via the web interface) in your scenario. That's sort of a bug. But now I know what is causing it at least. Phew!!

crankyoldgit added a commit that referenced this issue Jan 20, 2022
* Supports Power, Temp, Mode, & Fan speed. That's it.
  - Effectively a parent class of `IRHitachiAc424`.
* Add `IRac` integration.
* Update & add unit tests.

Fixes #1729
crankyoldgit added a commit that referenced this issue Jan 20, 2022
- Fix the case when `MQTT_CLIMATE_HA_MODE` is enabled & Home Assistant is NOT being used, and `power` is turned off via the http interface, that it also sets the `mode` to Off, and viceversa. Mode "Off" also sets Power "Off".
- Move some literal strings to constants for consistency.
  - Helps with potential internationalisation.
- Bump version patch number.

Ref #1729
Fixes #1739
crankyoldgit added a commit that referenced this issue Jan 20, 2022
- Fix the case when `MQTT_CLIMATE_HA_MODE` is enabled & Home Assistant is NOT being used, and `power` is turned off via the http interface, that it also sets the `mode` to Off, and viceversa. Mode "Off" also sets Power "Off".
- Move some literal strings to constants for consistency.
  - Helps with potential internationalisation.
- Bump version patch number.

Ref #1729
Fixes #1739
crankyoldgit added a commit that referenced this issue Mar 14, 2022
_v2.8.2 (20220314)_

**[Bug Fixes]**
- ESP32-C3: Fix reboot/crashes on ESP32-C3s when receiving. (#1768 #1751)

**[Features]**
- HITACHI_AC296: Add `IRac` class support & tests. (#1776 #1758 #1757)
- Support for Hitachi RAS-70YHA3 (remote RAR-3U3) (#1758 #1757)
- LG: Add Swing Toggle support for Model `LG6711A20083V` (#1771 #1770)
- IRMQTTServer: add `MQTT_SERVER_AUTODETECT_ENABLE` via mqtt mDNS (#1769)
- Experimental basic support for Kelon 168 bit / 21 byte protocol. (#1747 #1745 #1744)
- MitsubishiAC: Tweak repeat gap timing. (#1760 #1759)
- Gree YAP0F8 (Detected as Kelvinator) vertical position set support (#1756)
- Make KELON (48 bit) protocol decoding stricter. (#1746 #1744)
- IRMQTTServer V1.6.1 (#1740 #1739 #1729)
- HITACHI_AC264: Add minimal detailed support. (#1735 #1729)
- LG2: Improve Light toggle msg handling. (#1738 #1737)
- MIDEA: Add support for Quiet, Clean & Freeze Protect controls. (#1734 #1733)
- Add basic support for HITACHI_AC264 264bit protocol. (#1730 #1729)
- ESP32-C3: Work around for some C3 specific compiler issues again. (#1732 #1695)

**[Misc]**
- MIDEA: Update supported devices (#1774 #1773 #1716)
- Update devices supported by ELECTRA_AC (#1766 #1765)
- Improve documentation for `encodePioneer()` (#1761 #1749)
- Update (un)supported DAIKIN128 devices. (#1752)
- Refactor `decodeCOOLIX()` code & add another test case. (#1750 #1748)
- Simplify code based on state_t being initialised by default. (#1736 #1699)
- Add comments to help Teknopoint users. (#1731 #1728)
- Fix library version string calculation. (#1727 #1725)
- Confirm we can reproduce `TurnOnFujitsuAC.ino` via IRac/IRMQTTServer. (#1726 #1701)
crankyoldgit added a commit that referenced this issue Mar 15, 2022
##_v2.8.2 (20220314)_

**[Bug Fixes]**
- ESP32-C3: Fix reboot/crashes on ESP32-C3s when receiving. (#1768 #1751)

**[Features]**
- HITACHI_AC296: Add `IRac` class support & tests. (#1776 #1758 #1757)
- Support for Hitachi RAS-70YHA3 (remote RAR-3U3) (#1758 #1757)
- LG: Add Swing Toggle support for Model `LG6711A20083V` (#1771 #1770)
- IRMQTTServer: add `MQTT_SERVER_AUTODETECT_ENABLE` via mqtt mDNS (#1769)
- Experimental basic support for Kelon 168 bit / 21 byte protocol. (#1747 #1745 #1744)
- MitsubishiAC: Tweak repeat gap timing. (#1760 #1759)
- Gree YAP0F8 (Detected as Kelvinator) vertical position set support (#1756)
- Make KELON (48 bit) protocol decoding stricter. (#1746 #1744)
- IRMQTTServer V1.6.1 (#1740 #1739 #1729)
- HITACHI_AC264: Add minimal detailed support. (#1735 #1729)
- LG2: Improve Light toggle msg handling. (#1738 #1737)
- MIDEA: Add support for Quiet, Clean & Freeze Protect controls. (#1734 #1733)
- Add basic support for HITACHI_AC264 264bit protocol. (#1730 #1729)
- ESP32-C3: Work around for some C3 specific compiler issues again. (#1732 #1695)

**[Misc]**
- MIDEA: Update supported devices (#1774 #1773 #1716)
- Update devices supported by ELECTRA_AC (#1766 #1765)
- Improve documentation for `encodePioneer()` (#1761 #1749)
- Update (un)supported DAIKIN128 devices. (#1752)
- Refactor `decodeCOOLIX()` code & add another test case. (#1750 #1748)
- Simplify code based on state_t being initialised by default. (#1736 #1699)
- Add comments to help Teknopoint users. (#1731 #1728)
- Fix library version string calculation. (#1727 #1725)
- Confirm we can reproduce `TurnOnFujitsuAC.ino` via IRac/IRMQTTServer. (#1726 #1701)
@crankyoldgit
Copy link
Owner

FYI, the changes mentioned above have now been included in the new v2.8.2 release of the library.

@anklav24
Copy link

anklav24 commented Sep 5, 2022

Hi guys.
I have a HITACHI RAC-09CH7 with a RAR-2P2 remote and tuya-ir.
I've tried to integrate it in a Home Assistant, but works only raw commands as a couple buttons.
How to make it work as a climate device?

tuya-ir.yaml

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"

hitachi_ir.h

#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
  }
};

@ppkstat
Copy link

ppkstat commented Aug 19, 2023

@anklav24 Have you managed to find a solution to this?

@anklav24
Copy link

@ppkstat No, I keep using raw commands.

@ppkstat
Copy link

ppkstat commented Aug 19, 2023 via email

@anklav24
Copy link

@ppkstat I tried. There's no answer there like in irremote library repo too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants