ESPHome  2024.11.1
hitachi_ac424.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/log.h"
5 
6 namespace esphome {
7 namespace hitachi_ac424 {
8 
9 const uint16_t HITACHI_AC424_HDR_MARK = 3416; // ac
10 const uint16_t HITACHI_AC424_HDR_SPACE = 1604; // ac
11 const uint16_t HITACHI_AC424_BIT_MARK = 463;
12 const uint16_t HITACHI_AC424_ONE_SPACE = 1208;
13 const uint16_t HITACHI_AC424_ZERO_SPACE = 372;
14 const uint32_t HITACHI_AC424_MIN_GAP = 100000; // just a guess.
15 const uint16_t HITACHI_AC424_FREQ = 38000; // Hz.
16 
17 const uint8_t HITACHI_AC424_BUTTON_BYTE = 11;
18 const uint8_t HITACHI_AC424_BUTTON_POWER = 0x13;
19 const uint8_t HITACHI_AC424_BUTTON_SLEEP = 0x31;
20 const uint8_t HITACHI_AC424_BUTTON_MODE = 0x41;
21 const uint8_t HITACHI_AC424_BUTTON_FAN = 0x42;
22 const uint8_t HITACHI_AC424_BUTTON_TEMP_DOWN = 0x43;
23 const uint8_t HITACHI_AC424_BUTTON_TEMP_UP = 0x44;
24 const uint8_t HITACHI_AC424_BUTTON_SWINGV = 0x81;
25 const uint8_t HITACHI_AC424_BUTTON_SWINGH = 0x8C;
26 const uint8_t HITACHI_AC424_BUTTON_MILDEWPROOF = 0xE2;
27 
28 const uint8_t HITACHI_AC424_TEMP_BYTE = 13;
29 const uint8_t HITACHI_AC424_TEMP_OFFSET = 2;
30 const uint8_t HITACHI_AC424_TEMP_SIZE = 6;
31 const uint8_t HITACHI_AC424_TEMP_MIN = 16; // 16C
32 const uint8_t HITACHI_AC424_TEMP_MAX = 32; // 32C
33 const uint8_t HITACHI_AC424_TEMP_FAN = 27; // 27C
34 
35 const uint8_t HITACHI_AC424_TIMER_BYTE = 15;
36 
37 const uint8_t HITACHI_AC424_MODE_BYTE = 25;
38 const uint8_t HITACHI_AC424_MODE_FAN = 1;
39 const uint8_t HITACHI_AC424_MODE_COOL = 3;
40 const uint8_t HITACHI_AC424_MODE_DRY = 5;
41 const uint8_t HITACHI_AC424_MODE_HEAT = 6;
42 const uint8_t HITACHI_AC424_MODE_AUTO = 14;
43 const uint8_t HITACHI_AC424_MODE_POWERFUL = 19;
44 
46 const uint8_t HITACHI_AC424_FAN_MIN = 1;
47 const uint8_t HITACHI_AC424_FAN_LOW = 2;
48 const uint8_t HITACHI_AC424_FAN_MEDIUM = 3;
49 const uint8_t HITACHI_AC424_FAN_HIGH = 4;
50 const uint8_t HITACHI_AC424_FAN_AUTO = 5;
51 const uint8_t HITACHI_AC424_FAN_MAX = 6;
52 const uint8_t HITACHI_AC424_FAN_MAX_DRY = 2;
53 
54 const uint8_t HITACHI_AC424_POWER_BYTE = 27;
55 const uint8_t HITACHI_AC424_POWER_ON = 0xF1;
56 const uint8_t HITACHI_AC424_POWER_OFF = 0xE1;
57 
58 const uint8_t HITACHI_AC424_SWINGH_BYTE = 35;
59 const uint8_t HITACHI_AC424_SWINGH_OFFSET = 0; // Mask 0b00000xxx
60 const uint8_t HITACHI_AC424_SWINGH_SIZE = 3; // Mask 0b00000xxx
61 const uint8_t HITACHI_AC424_SWINGH_AUTO = 0; // 0b000
62 const uint8_t HITACHI_AC424_SWINGH_RIGHT_MAX = 1; // 0b001
63 const uint8_t HITACHI_AC424_SWINGH_RIGHT = 2; // 0b010
64 const uint8_t HITACHI_AC424_SWINGH_MIDDLE = 3; // 0b011
65 const uint8_t HITACHI_AC424_SWINGH_LEFT = 4; // 0b100
66 const uint8_t HITACHI_AC424_SWINGH_LEFT_MAX = 5; // 0b101
67 
68 const uint8_t HITACHI_AC424_SWINGV_BYTE = 37;
69 const uint8_t HITACHI_AC424_SWINGV_OFFSET = 5; // Mask 0b00x00000
70 
72 const uint8_t HITACHI_AC424_MILDEWPROOF_OFFSET = 2; // Mask 0b00000x00
73 
74 const uint16_t HITACHI_AC424_STATE_LENGTH = 53;
75 const uint16_t HITACHI_AC424_BITS = HITACHI_AC424_STATE_LENGTH * 8;
76 
77 #define HITACHI_AC424_GETBIT8(a, b) ((a) & ((uint8_t) 1 << (b)))
78 #define HITACHI_AC424_GETBITS8(data, offset, size) \
79  (((data) & (((uint8_t) UINT8_MAX >> (8 - (size))) << (offset))) >> (offset))
80 
82  public:
84  : climate_ir::ClimateIR(HITACHI_AC424_TEMP_MIN, HITACHI_AC424_TEMP_MAX, 1.0F, true, true,
88 
89  protected:
91  0x01, 0x10, 0x00, 0x40, 0xBF, 0xFF, 0x00, 0xCC, 0x33, 0x92, 0x6D, 0x13, 0xEC, 0x5C, 0xA3, 0x00, 0xFF, 0x00,
92  0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x53, 0xAC, 0xF1, 0x0E, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0x7F, 0x03,
93  0xFC, 0x01, 0xFE, 0x88, 0x77, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00};
94  uint8_t previous_temp_{27};
95  // Transmit via IR the state of this climate controller.
96  void transmit_state() override;
97  bool get_power_();
98  void set_power_(bool on);
99  uint8_t get_mode_();
100  void set_mode_(uint8_t mode);
101  void set_temp_(uint8_t celsius, bool set_previous = false);
102  uint8_t get_fan_();
103  void set_fan_(uint8_t speed);
104  void set_swing_v_toggle_(bool on);
105  bool get_swing_v_toggle_();
106  void set_swing_v_(bool on);
107  bool get_swing_v_();
108  void set_swing_h_(uint8_t position);
109  uint8_t get_swing_h_();
110  uint8_t get_button_();
111  void set_button_(uint8_t button);
112  // Handle received IR Buffer
113  bool on_receive(remote_base::RemoteReceiveData data) override;
114  bool parse_mode_(const uint8_t remote_state[]);
115  bool parse_temperature_(const uint8_t remote_state[]);
116  bool parse_fan_(const uint8_t remote_state[]);
117  bool parse_swing_(const uint8_t remote_state[]);
118  bool parse_state_frame_(const uint8_t frame[]);
119  void dump_state_(const char action[], uint8_t remote_state[]);
120 };
121 
122 } // namespace hitachi_ac424
123 } // namespace esphome
The fan mode is set to Low.
Definition: climate_mode.h:54
const uint8_t HITACHI_AC424_BUTTON_FAN
Definition: hitachi_ac424.h:21
const uint8_t HITACHI_AC424_BUTTON_BYTE
Definition: hitachi_ac424.h:17
const uint8_t HITACHI_AC424_POWER_BYTE
Definition: hitachi_ac424.h:54
const uint8_t HITACHI_AC424_BUTTON_TEMP_DOWN
Definition: hitachi_ac424.h:22
const uint8_t HITACHI_AC424_FAN_HIGH
Definition: hitachi_ac424.h:49
const uint16_t HITACHI_AC424_HDR_MARK
Definition: hitachi_ac424.h:9
const uint8_t HITACHI_AC424_FAN_MEDIUM
Definition: hitachi_ac424.h:48
const uint16_t HITACHI_AC424_ZERO_SPACE
Definition: hitachi_ac424.h:13
bool parse_state_frame_(const uint8_t frame[])
const uint8_t HITACHI_AC424_MODE_POWERFUL
Definition: hitachi_ac424.h:43
const uint16_t HITACHI_AC424_HDR_SPACE
Definition: hitachi_ac424.h:10
const uint8_t HITACHI_AC424_TEMP_FAN
Definition: hitachi_ac424.h:33
const uint8_t HITACHI_AC424_BUTTON_SLEEP
Definition: hitachi_ac424.h:19
const uint8_t HITACHI_AC424_SWINGH_BYTE
Definition: hitachi_ac424.h:58
ClimateMode mode
The active mode of the climate device.
Definition: climate.h:173
const uint8_t HITACHI_AC424_BUTTON_SWINGH
Definition: hitachi_ac424.h:25
int speed
Definition: fan.h:35
const uint8_t HITACHI_AC424_TIMER_BYTE
Definition: hitachi_ac424.h:35
const uint8_t HITACHI_AC424_TEMP_SIZE
Definition: hitachi_ac424.h:30
bool parse_swing_(const uint8_t remote_state[])
const uint8_t HITACHI_AC424_MODE_AUTO
Definition: hitachi_ac424.h:42
const uint8_t HITACHI_AC424_MODE_FAN
Definition: hitachi_ac424.h:38
const uint8_t HITACHI_AC424_POWER_OFF
Definition: hitachi_ac424.h:56
const uint8_t HITACHI_AC424_SWINGV_OFFSET
Definition: hitachi_ac424.h:69
const uint8_t HITACHI_AC424_POWER_ON
Definition: hitachi_ac424.h:55
const uint8_t HITACHI_AC424_MILDEWPROOF_BYTE
Definition: hitachi_ac424.h:71
bool parse_mode_(const uint8_t remote_state[])
const uint16_t HITACHI_AC424_ONE_SPACE
Definition: hitachi_ac424.h:12
const uint8_t HITACHI_AC424_FAN_MAX
Definition: hitachi_ac424.h:51
const uint16_t HITACHI_AC424_STATE_LENGTH
Definition: hitachi_ac424.h:74
const uint16_t HITACHI_AC424_BIT_MARK
Definition: hitachi_ac424.h:11
const uint8_t HITACHI_AC424_FAN_AUTO
Definition: hitachi_ac424.h:50
const uint8_t HITACHI_AC424_FAN_MIN
Definition: hitachi_ac424.h:46
The fan mode is set to Horizontal.
Definition: climate_mode.h:78
const uint8_t HITACHI_AC424_BUTTON_MILDEWPROOF
Definition: hitachi_ac424.h:26
The fan mode is set to Auto.
Definition: climate_mode.h:52
const uint8_t HITACHI_AC424_TEMP_OFFSET
Definition: hitachi_ac424.h:29
const uint8_t HITACHI_AC424_TEMP_MIN
Definition: hitachi_ac424.h:31
const uint8_t HITACHI_AC424_MODE_DRY
Definition: hitachi_ac424.h:40
const uint8_t HITACHI_AC424_MODE_BYTE
Definition: hitachi_ac424.h:37
const uint8_t HITACHI_AC424_SWINGH_LEFT
Definition: hitachi_ac424.h:65
ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step=1.0f, bool supports_dry=false, bool supports_fan_only=false, std::set< climate::ClimateFanMode > fan_modes={}, std::set< climate::ClimateSwingMode > swing_modes={}, std::set< climate::ClimatePreset > presets={})
Definition: climate_ir.h:26
const uint8_t HITACHI_AC424_BUTTON_SWINGV
Definition: hitachi_ac424.h:24
const uint8_t HITACHI_AC424_SWINGH_RIGHT
Definition: hitachi_ac424.h:63
const uint8_t HITACHI_AC424_SWINGH_AUTO
Definition: hitachi_ac424.h:61
const uint8_t HITACHI_AC424_FAN_LOW
Definition: hitachi_ac424.h:47
const uint8_t HITACHI_AC424_MODE_HEAT
Definition: hitachi_ac424.h:41
bool parse_fan_(const uint8_t remote_state[])
const uint8_t HITACHI_AC424_SWINGV_BYTE
Definition: hitachi_ac424.h:68
const uint8_t HITACHI_AC424_MODE_COOL
Definition: hitachi_ac424.h:39
const uint8_t HITACHI_AC424_SWINGH_SIZE
Definition: hitachi_ac424.h:60
void set_temp_(uint8_t celsius, bool set_previous=false)
The fan mode is set to High.
Definition: climate_mode.h:58
The swing mode is set to Off.
Definition: climate_mode.h:72
bool parse_temperature_(const uint8_t remote_state[])
const uint8_t HITACHI_AC424_TEMP_MAX
Definition: hitachi_ac424.h:32
const uint8_t HITACHI_AC424_SWINGH_MIDDLE
Definition: hitachi_ac424.h:64
bool on_receive(remote_base::RemoteReceiveData data) override
const uint8_t HITACHI_AC424_SWINGH_RIGHT_MAX
Definition: hitachi_ac424.h:62
const uint8_t HITACHI_AC424_BUTTON_TEMP_UP
Definition: hitachi_ac424.h:23
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
const uint8_t HITACHI_AC424_FAN_BYTE
Definition: hitachi_ac424.h:45
const uint8_t HITACHI_AC424_FAN_MAX_DRY
Definition: hitachi_ac424.h:52
const uint16_t HITACHI_AC424_BITS
Definition: hitachi_ac424.h:75
const uint32_t HITACHI_AC424_MIN_GAP
Definition: hitachi_ac424.h:14
const uint8_t HITACHI_AC424_SWINGH_OFFSET
Definition: hitachi_ac424.h:59
const uint8_t HITACHI_AC424_TEMP_BYTE
Definition: hitachi_ac424.h:28
The fan mode is set to Medium.
Definition: climate_mode.h:56
const uint8_t HITACHI_AC424_MILDEWPROOF_OFFSET
Definition: hitachi_ac424.h:72
float position
Definition: cover.h:14
uint8_t remote_state_[HITACHI_AC424_STATE_LENGTH]
Definition: hitachi_ac424.h:90
const uint8_t HITACHI_AC424_BUTTON_POWER
Definition: hitachi_ac424.h:18
const uint8_t HITACHI_AC424_SWINGH_LEFT_MAX
Definition: hitachi_ac424.h:66
const uint16_t HITACHI_AC424_FREQ
Definition: hitachi_ac424.h:15
const uint8_t HITACHI_AC424_BUTTON_MODE
Definition: hitachi_ac424.h:20
ClimateAction action
The active state of the climate device.
Definition: climate.h:176
void dump_state_(const char action[], uint8_t remote_state[])