mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 02:02:51 +00:00
[daikin_brc] Add sub_unit parameter for multi-unit addressing (#15234)
Co-authored-by: J. Nick Koston <nick@home-assistant.io> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
co-authored by
J. Nick Koston
J. Nick Koston
parent
1e05106a78
commit
602bf00435
@@ -6,6 +6,8 @@ from esphome.types import ConfigType
|
||||
|
||||
AUTO_LOAD = ["climate_ir"]
|
||||
|
||||
CONF_SUB_UNIT = "sub_unit"
|
||||
|
||||
daikin_brc_ns = cg.esphome_ns.namespace("daikin_brc")
|
||||
DaikinBrcClimate = daikin_brc_ns.class_("DaikinBrcClimate", climate_ir.ClimateIR)
|
||||
|
||||
@@ -13,6 +15,7 @@ DaikinBrcClimate = daikin_brc_ns.class_("DaikinBrcClimate", climate_ir.ClimateIR
|
||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(DaikinBrcClimate).extend(
|
||||
{
|
||||
cv.Optional(CONF_USE_FAHRENHEIT, default=False): cv.boolean,
|
||||
cv.Optional(CONF_SUB_UNIT, default=0): cv.int_range(min=0, max=5),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -20,3 +23,4 @@ CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(DaikinBrcClimate).ext
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
var = await climate_ir.new_climate_ir(config)
|
||||
cg.add(var.set_fahrenheit(config[CONF_USE_FAHRENHEIT]))
|
||||
cg.add(var.set_sub_unit(config[CONF_SUB_UNIT]))
|
||||
|
||||
@@ -20,13 +20,18 @@ void DaikinBrcClimate::transmit_state() {
|
||||
0xDA, 0x17, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x20, 0x00};
|
||||
|
||||
// The low 3 bits of the frame header byte address the indoor unit, in the preamble and the state frame
|
||||
remote_state[3] |= this->sub_unit_;
|
||||
remote_state[10] |= this->sub_unit_;
|
||||
remote_state[6] += this->sub_unit_; // preamble checksum covers byte 3
|
||||
|
||||
remote_state[12] = this->alt_mode_();
|
||||
remote_state[13] = this->mode_button_;
|
||||
remote_state[14] = this->operation_mode_();
|
||||
remote_state[17] = this->temperature_();
|
||||
remote_state[18] = this->fan_speed_swing_();
|
||||
|
||||
// Calculate checksum
|
||||
// Calculate state frame checksum
|
||||
for (int i = DAIKIN_BRC_PREAMBLE_SIZE; i < DAIKIN_BRC_TRANSMIT_FRAME_SIZE - 1; i++) {
|
||||
remote_state[DAIKIN_BRC_TRANSMIT_FRAME_SIZE - 1] += remote_state[i];
|
||||
}
|
||||
@@ -254,8 +259,8 @@ bool DaikinBrcClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
if (byte != 0x17)
|
||||
return false;
|
||||
} else if (pos == 3) {
|
||||
// frame header
|
||||
if (byte != 0x18)
|
||||
// frame header, with this unit's address in the low 3 bits
|
||||
if (byte != (0x18 | this->sub_unit_))
|
||||
return false;
|
||||
} else if (pos == 4) {
|
||||
// frame type
|
||||
|
||||
@@ -60,6 +60,8 @@ class DaikinBrcClimate final : public climate_ir::ClimateIR {
|
||||
this->fahrenheit_ = value;
|
||||
this->temperature_step_ = value ? 0.5f : 1.0f;
|
||||
}
|
||||
/// Which indoor unit (0 to 5) this climate addresses on a multi-unit system
|
||||
void set_sub_unit(uint8_t value) { this->sub_unit_ = value; }
|
||||
|
||||
protected:
|
||||
uint8_t mode_button_ = 0x00;
|
||||
@@ -75,6 +77,7 @@ class DaikinBrcClimate final : public climate_ir::ClimateIR {
|
||||
bool on_receive(remote_base::RemoteReceiveData data) override;
|
||||
bool parse_state_frame_(const uint8_t frame[]);
|
||||
bool fahrenheit_{false};
|
||||
uint8_t sub_unit_{0};
|
||||
};
|
||||
|
||||
} // namespace esphome::daikin_brc
|
||||
|
||||
@@ -2,3 +2,7 @@ climate:
|
||||
- platform: daikin_brc
|
||||
name: Daikin_brc Climate
|
||||
transmitter_id: xmitr
|
||||
- platform: daikin_brc
|
||||
name: Daikin_brc Climate Unit 2
|
||||
transmitter_id: xmitr
|
||||
sub_unit: 1
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
|
||||
<<: !include common.yaml
|
||||
daikin_brc: !include common.yaml
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp8266-ard.yaml
|
||||
|
||||
<<: !include common.yaml
|
||||
daikin_brc: !include common.yaml
|
||||
|
||||
Reference in New Issue
Block a user