Skip to content

Commit

Permalink
Add workaround for BPV detection for HPSU v4
Browse files Browse the repository at this point in the history
  • Loading branch information
wrfz committed Dec 5, 2024
1 parent cad6c81 commit 50f6b4e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/daikin_rotex_can/daikin_rotex_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,21 @@ bool DaikinRotexCanComponent::is_command_set(TMessage const& message) {
}

std::string DaikinRotexCanComponent::recalculate_state(EntityBase* pEntity, std::string const& new_state) const {
CanSensor const* tvbh = m_entity_manager.get_sensor("tvbh");
const uint32_t delay = 2*60*1000; // 2 minutes. HPSU v4 immediately changes the BPV position to 100%, which leads to false positives!

CanSensor const* tv = m_entity_manager.get_sensor("tv");
CanSensor const* tvbh = m_entity_manager.get_sensor("tvbh");
CanSensor const* tr = m_entity_manager.get_sensor("tr");
CanSensor const* dhw_mixer_position = m_entity_manager.get_sensor("dhw_mixer_position");
CanSensor const* bpv = m_entity_manager.get_sensor("bypass_valve");
CanSensor const* flow_rate = m_entity_manager.get_sensor("flow_rate");
CanTextSensor const* error_code = m_entity_manager.get_text_sensor("error_code");

ESP_LOGI(TAG, "tv: %f, tvbh: %f, tr: %f, TvBH-Tv: %f, Tr-TvBH: %f, dhw: %f, bpv: %f, flow: %f",
tv->state, tvbh->state, tr->state, m_max_spread.tvbh_tv, m_max_spread.tvbh_tr, dhw_mixer_position->state, bpv->state, flow_rate->state);
if (tv && tvbh && tr && dhw_mixer_position && bpv && flow_rate) {
ESP_LOGI(TAG, "tv: %f, tvbh: %f, tr: %f, TvBH-Tv: %f, Tr-TvBH: %f, dhw: %f, bpv: %f, flow: %f, delay: %d, millis: %d, bpv_change: %d",
tv->state, tvbh->state, tr->state, m_max_spread.tvbh_tv, m_max_spread.tvbh_tr, dhw_mixer_position->state, bpv->state, flow_rate->state,
delay, millis(), (bpv->getLastValueChange()));
}

if (pEntity == error_code && error_code != nullptr) {
if (tvbh != nullptr && tv != nullptr && dhw_mixer_position != nullptr && flow_rate != nullptr) {
Expand All @@ -311,7 +316,7 @@ std::string DaikinRotexCanComponent::recalculate_state(EntityBase* pEntity, std:
}
}
if (tvbh != nullptr && tr != nullptr && bpv != nullptr && flow_rate != nullptr) {
if (tvbh->state > (tr->state + m_max_spread.tvbh_tr) && bpv->state == 100.0f && flow_rate->state > 600.0f) {
if (tvbh->state > (tr->state + m_max_spread.tvbh_tr) && bpv->state == 100.0f && millis() > (bpv->getLastValueChange() + delay) && flow_rate->state > 600.0f) {
ESP_LOGE(TAG, "3UV BPV defekt => tvbh: %f, tr: %f, max_spread: %f, dhw_mixer_pos: %f, flow_rate: %f",
tvbh->state, tr->state, m_max_spread.tvbh_tr, bpv->state, flow_rate->state);
return new_state + "|3UV BPV defekt";
Expand Down
1 change: 1 addition & 0 deletions components/daikin_rotex_can/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool TEntity::handle(uint32_t can_id, TMessage const& responseData) {
if (valid) {
const bool changed = current != previous;
if (changed) {
m_last_value_change_timestamp = millis();
m_post_handle_lambda(this, current, previous);
}

Expand Down
5 changes: 5 additions & 0 deletions components/daikin_rotex_can/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class TEntity {
return m_last_handle_timestamp;
}

uint32_t getLastValueChange() const {
return m_last_value_change_timestamp;
}

void set_canbus(esphome::esp32_can::ESP32Can* pCanbus) {
m_pCanbus = pCanbus;
}
Expand Down Expand Up @@ -164,6 +168,7 @@ class TEntity {
std::array<uint16_t, 7> m_expected_reponse;
uint32_t m_last_handle_timestamp;
uint32_t m_last_get_timestamp;
uint32_t m_last_value_change_timestamp;
TPostHandleLabda m_post_handle_lambda;
};

Expand Down

0 comments on commit 50f6b4e

Please sign in to comment.