ESPHome  2022.6.2
hitachi_ac344.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_ac344 {
8 
9 const uint16_t HITACHI_AC344_HDR_MARK = 3300; // ac
10 const uint16_t HITACHI_AC344_HDR_SPACE = 1700; // ac
11 const uint16_t HITACHI_AC344_BIT_MARK = 400;
12 const uint16_t HITACHI_AC344_ONE_SPACE = 1250;
13 const uint16_t HITACHI_AC344_ZERO_SPACE = 500;
14 const uint32_t HITACHI_AC344_MIN_GAP = 100000; // just a guess.
15 const uint16_t HITACHI_AC344_FREQ = 38000; // Hz.
16 
17 const uint8_t HITACHI_AC344_BUTTON_BYTE = 11;
18 const uint8_t HITACHI_AC344_BUTTON_POWER = 0x13;
19 const uint8_t HITACHI_AC344_BUTTON_SLEEP = 0x31;
20 const uint8_t HITACHI_AC344_BUTTON_MODE = 0x41;
21 const uint8_t HITACHI_AC344_BUTTON_FAN = 0x42;
22 const uint8_t HITACHI_AC344_BUTTON_TEMP_DOWN = 0x43;
23 const uint8_t HITACHI_AC344_BUTTON_TEMP_UP = 0x44;
24 const uint8_t HITACHI_AC344_BUTTON_SWINGV = 0x81;
25 const uint8_t HITACHI_AC344_BUTTON_SWINGH = 0x8C;
26 const uint8_t HITACHI_AC344_BUTTON_MILDEWPROOF = 0xE2;
27 
28 const uint8_t HITACHI_AC344_TEMP_BYTE = 13;
29 const uint8_t HITACHI_AC344_TEMP_OFFSET = 2;
30 const uint8_t HITACHI_AC344_TEMP_SIZE = 6;
31 const uint8_t HITACHI_AC344_TEMP_MIN = 16; // 16C
32 const uint8_t HITACHI_AC344_TEMP_MAX = 32; // 32C
33 const uint8_t HITACHI_AC344_TEMP_FAN = 27; // 27C
34 
35 const uint8_t HITACHI_AC344_TIMER_BYTE = 15;
36 
37 const uint8_t HITACHI_AC344_MODE_BYTE = 25;
38 const uint8_t HITACHI_AC344_MODE_FAN = 1;
39 const uint8_t HITACHI_AC344_MODE_COOL = 3;
40 const uint8_t HITACHI_AC344_MODE_DRY = 5;
41 const uint8_t HITACHI_AC344_MODE_HEAT = 6;
42 const uint8_t HITACHI_AC344_MODE_AUTO = 7;
43 
45 const uint8_t HITACHI_AC344_FAN_MIN = 1;
46 const uint8_t HITACHI_AC344_FAN_LOW = 2;
47 const uint8_t HITACHI_AC344_FAN_MEDIUM = 3;
48 const uint8_t HITACHI_AC344_FAN_HIGH = 4;
49 const uint8_t HITACHI_AC344_FAN_AUTO = 5;
50 const uint8_t HITACHI_AC344_FAN_MAX = 6;
51 const uint8_t HITACHI_AC344_FAN_MAX_DRY = 2;
52 
53 const uint8_t HITACHI_AC344_POWER_BYTE = 27;
54 const uint8_t HITACHI_AC344_POWER_ON = 0xF1;
55 const uint8_t HITACHI_AC344_POWER_OFF = 0xE1;
56 
57 const uint8_t HITACHI_AC344_SWINGH_BYTE = 35;
58 const uint8_t HITACHI_AC344_SWINGH_OFFSET = 0; // Mask 0b00000xxx
59 const uint8_t HITACHI_AC344_SWINGH_SIZE = 3; // Mask 0b00000xxx
60 const uint8_t HITACHI_AC344_SWINGH_AUTO = 0; // 0b000
61 const uint8_t HITACHI_AC344_SWINGH_RIGHT_MAX = 1; // 0b001
62 const uint8_t HITACHI_AC344_SWINGH_RIGHT = 2; // 0b010
63 const uint8_t HITACHI_AC344_SWINGH_MIDDLE = 3; // 0b011
64 const uint8_t HITACHI_AC344_SWINGH_LEFT = 4; // 0b100
65 const uint8_t HITACHI_AC344_SWINGH_LEFT_MAX = 5; // 0b101
66 
67 const uint8_t HITACHI_AC344_SWINGV_BYTE = 37;
68 const uint8_t HITACHI_AC344_SWINGV_OFFSET = 5; // Mask 0b00x00000
69 
71 const uint8_t HITACHI_AC344_MILDEWPROOF_OFFSET = 2; // Mask 0b00000x00
72 
73 const uint16_t HITACHI_AC344_STATE_LENGTH = 43;
74 const uint16_t HITACHI_AC344_BITS = HITACHI_AC344_STATE_LENGTH * 8;
75 
76 #define GETBIT8(a, b) ((a) & ((uint8_t) 1 << (b)))
77 #define GETBITS8(data, offset, size) (((data) & (((uint8_t) UINT8_MAX >> (8 - (size))) << (offset))) >> (offset))
78 
80  public:
82  : climate_ir::ClimateIR(HITACHI_AC344_TEMP_MIN, HITACHI_AC344_TEMP_MAX, 1.0F, true, true,
86 
87  protected:
88  uint8_t remote_state_[HITACHI_AC344_STATE_LENGTH]{0x01, 0x10, 0x00, 0x40, 0x00, 0xFF, 0x00, 0xCC, 0x00, 0x00, 0x00,
89  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
91  0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
92  uint8_t previous_temp_{27};
93  // Transmit via IR the state of this climate controller.
94  void transmit_state() override;
95  bool get_power_();
96  void set_power_(bool on);
97  uint8_t get_mode_();
98  void set_mode_(uint8_t mode);
99  void set_temp_(uint8_t celsius, bool set_previous = false);
100  uint8_t get_fan_();
101  void set_fan_(uint8_t speed);
102  void set_swing_v_toggle_(bool on);
103  bool get_swing_v_toggle_();
104  void set_swing_v_(bool on);
105  bool get_swing_v_();
106  void set_swing_h_(uint8_t position);
107  uint8_t get_swing_h_();
108  uint8_t get_button_();
109  void set_button_(uint8_t button);
110  // Handle received IR Buffer
111  bool on_receive(remote_base::RemoteReceiveData data) override;
112  bool parse_mode_(const uint8_t remote_state[]);
113  bool parse_temperature_(const uint8_t remote_state[]);
114  bool parse_fan_(const uint8_t remote_state[]);
115  bool parse_swing_(const uint8_t remote_state[]);
116  bool parse_state_frame_(const uint8_t frame[]);
117  void dump_state_(const char action[], uint8_t remote_state[]);
118 };
119 
120 } // namespace hitachi_ac344
121 } // namespace esphome
The fan mode is set to Low.
Definition: climate_mode.h:54
const uint16_t HITACHI_AC344_HDR_MARK
Definition: hitachi_ac344.h:9
const uint8_t HITACHI_AC344_SWINGH_RIGHT_MAX
Definition: hitachi_ac344.h:61
const uint8_t HITACHI_AC344_FAN_AUTO
Definition: hitachi_ac344.h:49
const uint8_t HITACHI_AC344_SWINGH_BYTE
Definition: hitachi_ac344.h:57
void set_temp_(uint8_t celsius, bool set_previous=false)
const uint8_t HITACHI_AC344_SWINGH_OFFSET
Definition: hitachi_ac344.h:58
const uint8_t HITACHI_AC344_TEMP_SIZE
Definition: hitachi_ac344.h:30
const uint8_t HITACHI_AC344_MODE_AUTO
Definition: hitachi_ac344.h:42
const uint8_t HITACHI_AC344_FAN_BYTE
Definition: hitachi_ac344.h:44
const uint8_t HITACHI_AC344_BUTTON_SWINGV
Definition: hitachi_ac344.h:24
const uint8_t HITACHI_AC344_MODE_FAN
Definition: hitachi_ac344.h:38
bool on_receive(remote_base::RemoteReceiveData data) override
ClimateMode mode
The active mode of the climate device.
Definition: climate.h:175
int speed
Definition: fan.h:35
const uint8_t HITACHI_AC344_BUTTON_POWER
Definition: hitachi_ac344.h:18
const uint8_t HITACHI_AC344_TEMP_MAX
Definition: hitachi_ac344.h:32
const uint8_t HITACHI_AC344_TEMP_FAN
Definition: hitachi_ac344.h:33
uint8_t remote_state_[HITACHI_AC344_STATE_LENGTH]
Definition: hitachi_ac344.h:88
bool parse_mode_(const uint8_t remote_state[])
const uint8_t HITACHI_AC344_TEMP_OFFSET
Definition: hitachi_ac344.h:29
const uint8_t HITACHI_AC344_FAN_MEDIUM
Definition: hitachi_ac344.h:47
const uint16_t HITACHI_AC344_BITS
Definition: hitachi_ac344.h:74
const uint8_t HITACHI_AC344_SWINGH_RIGHT
Definition: hitachi_ac344.h:62
const uint8_t HITACHI_AC344_SWINGV_BYTE
Definition: hitachi_ac344.h:67
const uint8_t HITACHI_AC344_SWINGH_LEFT
Definition: hitachi_ac344.h:64
The fan mode is set to Horizontal.
Definition: climate_mode.h:76
const uint8_t HITACHI_AC344_FAN_HIGH
Definition: hitachi_ac344.h:48
The fan mode is set to Auto.
Definition: climate_mode.h:52
const uint32_t HITACHI_AC344_MIN_GAP
Definition: hitachi_ac344.h:14
bool parse_swing_(const uint8_t remote_state[])
const uint8_t HITACHI_AC344_BUTTON_BYTE
Definition: hitachi_ac344.h:17
const uint8_t HITACHI_AC344_SWINGH_AUTO
Definition: hitachi_ac344.h:60
const uint8_t HITACHI_AC344_BUTTON_MODE
Definition: hitachi_ac344.h:20
const uint8_t HITACHI_AC344_BUTTON_TEMP_DOWN
Definition: hitachi_ac344.h:22
const uint8_t HITACHI_AC344_SWINGH_SIZE
Definition: hitachi_ac344.h:59
const uint8_t HITACHI_AC344_POWER_BYTE
Definition: hitachi_ac344.h:53
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:23
const uint8_t HITACHI_AC344_POWER_OFF
Definition: hitachi_ac344.h:55
const uint8_t HITACHI_AC344_BUTTON_SWINGH
Definition: hitachi_ac344.h:25
const uint8_t HITACHI_AC344_FAN_MAX_DRY
Definition: hitachi_ac344.h:51
const uint8_t HITACHI_AC344_MILDEWPROOF_OFFSET
Definition: hitachi_ac344.h:71
bool parse_temperature_(const uint8_t remote_state[])
const uint8_t HITACHI_AC344_BUTTON_TEMP_UP
Definition: hitachi_ac344.h:23
const uint16_t HITACHI_AC344_HDR_SPACE
Definition: hitachi_ac344.h:10
const uint8_t HITACHI_AC344_BUTTON_FAN
Definition: hitachi_ac344.h:21
The fan mode is set to High.
Definition: climate_mode.h:58
const uint8_t HITACHI_AC344_SWINGV_OFFSET
Definition: hitachi_ac344.h:68
The swing mode is set to Off.
Definition: climate_mode.h:70
bool parse_fan_(const uint8_t remote_state[])
const uint8_t HITACHI_AC344_TEMP_MIN
Definition: hitachi_ac344.h:31
const uint16_t HITACHI_AC344_FREQ
Definition: hitachi_ac344.h:15
const uint8_t HITACHI_AC344_FAN_LOW
Definition: hitachi_ac344.h:46
const uint8_t HITACHI_AC344_MODE_DRY
Definition: hitachi_ac344.h:40
const uint16_t HITACHI_AC344_ZERO_SPACE
Definition: hitachi_ac344.h:13
const uint16_t HITACHI_AC344_BIT_MARK
Definition: hitachi_ac344.h:11
const uint8_t HITACHI_AC344_MODE_BYTE
Definition: hitachi_ac344.h:37
void dump_state_(const char action[], uint8_t remote_state[])
const uint8_t HITACHI_AC344_SWINGH_LEFT_MAX
Definition: hitachi_ac344.h:65
const uint8_t HITACHI_AC344_SWINGH_MIDDLE
Definition: hitachi_ac344.h:63
const uint8_t HITACHI_AC344_MODE_COOL
Definition: hitachi_ac344.h:39
const uint8_t HITACHI_AC344_TIMER_BYTE
Definition: hitachi_ac344.h:35
const uint8_t HITACHI_AC344_MILDEWPROOF_BYTE
Definition: hitachi_ac344.h:70
const uint8_t HITACHI_AC344_TEMP_BYTE
Definition: hitachi_ac344.h:28
Definition: a4988.cpp:4
const uint8_t HITACHI_AC344_BUTTON_MILDEWPROOF
Definition: hitachi_ac344.h:26
const uint16_t HITACHI_AC344_ONE_SPACE
Definition: hitachi_ac344.h:12
const uint8_t HITACHI_AC344_BUTTON_SLEEP
Definition: hitachi_ac344.h:19
const uint8_t HITACHI_AC344_MODE_HEAT
Definition: hitachi_ac344.h:41
const uint8_t HITACHI_AC344_FAN_MIN
Definition: hitachi_ac344.h:45
The fan mode is set to Medium.
Definition: climate_mode.h:56
float position
Definition: cover.h:14
bool parse_state_frame_(const uint8_t frame[])
const uint16_t HITACHI_AC344_STATE_LENGTH
Definition: hitachi_ac344.h:73
ClimateAction action
The active state of the climate device.
Definition: climate.h:177
const uint8_t HITACHI_AC344_POWER_ON
Definition: hitachi_ac344.h:54
const uint8_t HITACHI_AC344_FAN_MAX
Definition: hitachi_ac344.h:50