Split TrumaiNetBoxApp into multiple files.

This commit is contained in:
Your Name 2023-03-22 15:51:13 +01:00
parent 504a3012bf
commit 85d1afe874
24 changed files with 268 additions and 143 deletions

View File

@ -8,6 +8,9 @@ namespace truma_inetbox {
template<typename T, typename TResponse> class TrumaStausFrameResponseStorage : public TrumaStausFrameStorage<T> {
public:
void reset();
bool can_update() { return this->data_valid_; }
virtual TResponse *update_prepare() = 0;
void update_submit() { this->update_status_unsubmitted_ = true; }
// Prepared means `update_status_` was copied from `data_`.
bool update_status_prepared_ = false;

View File

@ -13,8 +13,11 @@ template<typename T> class TrumaStausFrameStorage {
// Value has changed notify listeners.
bool data_updated_ = false;
// bool get_status_valid() { return this->data_valid_; }
// const T *get_status() { return &this->data_; }
void add_on_message_callback(std::function<void(const T *)> callback) {
this->state_callback_.add(std::move(callback));
}
bool get_status_valid() { return this->data_valid_; }
const T *get_status() { return &this->data_; }
void update();
void reset();
};

View File

@ -229,6 +229,21 @@ struct StatusFrameAirconAuto { // NOLINT(altera-struct-pack-align)
TargetTemp target_temp;
} __attribute__((packed));
// TODO
struct StatusFrameAirconAutoResponse { // NOLINT(altera-struct-pack-align)
EnergyMix energy_mix_a;
u_int8_t unknown_02; // 0x00
EnergyMix energy_mix_b;
u_int8_t unknown_04; // 0x00
u_int8_t unknown_05; // 0x00
u_int8_t unknown_06; // 0x00
TargetTemp target_temp_aircon_auto;
ElectricPowerLevel el_power_level_a;
u_int8_t unknown_11; // 0x00
u_int8_t unknown_12; // 0x00
ElectricPowerLevel el_power_level_b;
} __attribute__((packed));
// Length 20 (0x14)
// TODO
struct StatusFrameAirconAutoInit { // NOLINT(altera-struct-pack-align)

View File

@ -92,68 +92,6 @@ template<typename T, typename TResponse> void TrumaStausFrameResponseStorage<T,
this->update_status_stale_ = false;
}
StatusFrameHeaterResponse *TrumaiNetBoxApp::update_heater_prepare() {
// An update is currently going on.
if (this->heater_.update_status_prepared_ || this->heater_.update_status_stale_) {
return &this->heater_.update_status_;
}
// prepare status heater response
this->heater_.update_status_ = {};
this->heater_.update_status_.target_temp_room = this->heater_.data_.target_temp_room;
this->heater_.update_status_.heating_mode = this->heater_.data_.heating_mode;
this->heater_.update_status_.el_power_level_a = this->heater_.data_.el_power_level_a;
this->heater_.update_status_.target_temp_water = this->heater_.data_.target_temp_water;
this->heater_.update_status_.el_power_level_b = this->heater_.data_.el_power_level_b;
this->heater_.update_status_.energy_mix_a = this->heater_.data_.energy_mix_a;
this->heater_.update_status_.energy_mix_b = this->heater_.data_.energy_mix_b;
this->heater_.update_status_prepared_ = true;
return &this->heater_.update_status_;
}
StatusFrameTimerResponse *TrumaiNetBoxApp::update_timer_prepare() {
// An update is currently going on.
if (this->timer_.update_status_prepared_ || this->timer_.update_status_stale_) {
return &this->timer_.update_status_;
}
// prepare status heater response
this->timer_.update_status_ = {};
this->timer_.update_status_.timer_target_temp_room = this->timer_.data_.timer_target_temp_room;
this->timer_.update_status_.timer_heating_mode = this->timer_.data_.timer_heating_mode;
this->timer_.update_status_.timer_el_power_level_a = this->timer_.data_.timer_el_power_level_a;
this->timer_.update_status_.timer_target_temp_water = this->timer_.data_.timer_target_temp_water;
this->timer_.update_status_.timer_el_power_level_b = this->timer_.data_.timer_el_power_level_b;
this->timer_.update_status_.timer_energy_mix_a = this->timer_.data_.timer_energy_mix_a;
this->timer_.update_status_.timer_energy_mix_b = this->timer_.data_.timer_energy_mix_b;
this->timer_.update_status_.timer_resp_active = this->timer_.data_.timer_active;
this->timer_.update_status_.timer_resp_start_minutes = this->timer_.data_.timer_start_minutes;
this->timer_.update_status_.timer_resp_start_hours = this->timer_.data_.timer_start_hours;
this->timer_.update_status_.timer_resp_stop_minutes = this->timer_.data_.timer_stop_minutes;
this->timer_.update_status_.timer_resp_stop_hours = this->timer_.data_.timer_stop_hours;
this->timer_.update_status_prepared_ = true;
return &this->timer_.update_status_;
}
StatusFrameAirconManualResponse *TrumaiNetBoxApp::update_aircon_prepare() {
// An update is currently going on.
if (this->airconManual_.update_status_prepared_ || this->airconManual_.update_status_stale_) {
return &this->airconManual_.update_status_;
}
// prepare status response
this->airconManual_.update_status_ = {};
this->airconManual_.update_status_.mode = this->airconManual_.data_.mode;
this->airconManual_.update_status_.operation = this->airconManual_.data_.operation;
this->airconManual_.update_status_.energy_mix = this->airconManual_.data_.energy_mix;
this->airconManual_.update_status_.target_temp_aircon = this->airconManual_.data_.target_temp_aircon;
this->airconManual_.update_status_prepared_ = true;
return &this->airconManual_.update_status_;
}
bool TrumaiNetBoxApp::answer_lin_order_(const u_int8_t pid) {
// Alive message
if (pid == LIN_PID_TRUMA_INET_BOX) {

View File

@ -4,6 +4,12 @@
#include "LinBusProtocol.h"
#include "esphome/core/automation.h"
#include "TrumaEnums.h"
#include "TrumaiNetBoxAppAirconAuto.h"
#include "TrumaiNetBoxAppAirconManual.h"
#include "TrumaiNetBoxAppClock.h"
#include "TrumaiNetBoxAppConfig.h"
#include "TrumaiNetBoxAppHeater.h"
#include "TrumaiNetBoxAppTimer.h"
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStausFrameStorage.h"
#include "TrumaStructs.h"
@ -69,7 +75,6 @@ union StatusFrame { // NOLINT(altera-struct-pack-align)
} inner;
} __attribute__((packed));
class TrumaiNetBoxApp : public LinBusProtocol {
public:
void update() override;
@ -78,48 +83,15 @@ class TrumaiNetBoxApp : public LinBusProtocol {
void lin_heartbeat() override;
void lin_reset_device() override;
bool get_status_heater_valid() { return this->heater_.data_valid_; }
const StatusFrameHeater *get_status_heater() { return &this->heater_.data_; }
bool get_status_timer_valid() { return this->timer_.data_valid_; }
const StatusFrameTimer *get_status_timer() { return &this->timer_.data_; }
bool get_status_clock_valid() { return this->clock_.data_valid_; }
const StatusFrameClock *get_status_clock() { return &this->clock_.data_; }
bool get_status_config_valid() { return this->config_.data_valid_; }
const StatusFrameConfig *get_status_config() { return &this->config_.data_; }
bool truma_heater_can_update() { return this->heater_.data_valid_; }
StatusFrameHeaterResponse *update_heater_prepare();
void update_heater_submit() { this->heater_.update_status_unsubmitted_ = true; }
bool truma_timer_can_update() { return this->timer_.data_valid_; }
StatusFrameTimerResponse *update_timer_prepare();
void update_timer_submit() { this->timer_.update_status_unsubmitted_ = true; }
bool truma_aircon_can_update() { return this->airconManual_.data_valid_; }
StatusFrameAirconManualResponse *update_aircon_prepare();
void update_aircon_submit() { this->airconManual_.update_status_unsubmitted_ = true; }
TrumaiNetBoxAppAirconAuto *get_aircon_auto() { return &this->airconAuto_; }
TrumaiNetBoxAppAirconManual *get_aircon_manual() { return &this->airconManual_; }
TrumaiNetBoxAppClock *get_clock() { return &this->clock_; }
TrumaiNetBoxAppConfig *get_config() { return &this->config_; }
TrumaiNetBoxAppHeater *get_heater() { return &this->heater_; }
TrumaiNetBoxAppTimer *get_timer() { return &this->timer_; }
int64_t get_last_cp_plus_request() { return this->device_registered_; }
// Automation
void add_on_heater_message_callback(std::function<void(const StatusFrameHeater *)> callback) {
this->heater_.state_callback_.add(std::move(callback));
}
void add_on_timer_message_callback(std::function<void(const StatusFrameTimer *)> callback) {
this->timer_.state_callback_.add(std::move(callback));
}
void add_on_clock_message_callback(std::function<void(const StatusFrameClock *)> callback) {
this->clock_.state_callback_.add(std::move(callback));
}
void add_on_config_message_callback(std::function<void(const StatusFrameConfig *)> callback) {
this->config_.state_callback_.add(std::move(callback));
}
void add_on_aircon_manual_message_callback(std::function<void(const StatusFrameAirconManual *)> callback) {
this->airconManual_.state_callback_.add(std::move(callback));
}
bool action_heater_room(u_int8_t temperature, HeatingMode mode = HeatingMode::HEATING_MODE_OFF);
bool action_heater_water(u_int8_t temperature);
bool action_heater_water(TargetTemp temperature);
@ -150,11 +122,12 @@ class TrumaiNetBoxApp : public LinBusProtocol {
TRUMA_DEVICE heater_device_ = TRUMA_DEVICE::HEATER_COMBI4;
TRUMA_DEVICE aircon_device_ = TRUMA_DEVICE::UNKNOWN;
TrumaStausFrameResponseStorage<StatusFrameHeater, StatusFrameHeaterResponse> heater_;
TrumaStausFrameResponseStorage<StatusFrameTimer, StatusFrameTimerResponse> timer_;
TrumaStausFrameResponseStorage<StatusFrameAirconManual, StatusFrameAirconManualResponse> airconManual_;
TrumaStausFrameStorage<StatusFrameConfig> config_;
TrumaStausFrameStorage<StatusFrameClock> clock_;
TrumaiNetBoxAppAirconAuto airconAuto_{};
TrumaiNetBoxAppAirconManual airconManual_{};
TrumaiNetBoxAppClock clock_{};
TrumaiNetBoxAppConfig config_{};
TrumaiNetBoxAppHeater heater_{};
TrumaiNetBoxAppTimer timer_{};
// last time CP plus was informed I got an update msg.
uint32_t update_time_ = 0;

View File

@ -0,0 +1,24 @@
#include "TrumaiNetBoxAppAirconAuto.h"
namespace esphome {
namespace truma_inetbox {
StatusFrameAirconAutoResponse *TrumaiNetBoxAppAirconAuto::update_prepare() {
// An update is currently going on.
if (this->update_status_prepared_ || this->update_status_stale_) {
return &this->update_status_;
}
// prepare status response
this->update_status_ = {};
// this->update_status_.mode = this->data_.mode;
// this->update_status_.operation = this->data_.operation;
// this->update_status_.energy_mix = this->data_.energy_mix;
// this->update_status_.target_temp_aircon = this->data_.target_temp_aircon;
this->update_status_prepared_ = true;
return &this->update_status_;
}
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,16 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppAirconAuto
: public TrumaStausFrameResponseStorage<StatusFrameAirconAuto, StatusFrameAirconAutoResponse> {
public:
StatusFrameAirconAutoResponse *update_prepare() override;
};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,24 @@
#include "TrumaiNetBoxAppAirconManual.h"
namespace esphome {
namespace truma_inetbox {
StatusFrameAirconManualResponse *TrumaiNetBoxAppAirconManual::update_prepare() {
// An update is currently going on.
if (this->update_status_prepared_ || this->update_status_stale_) {
return &this->update_status_;
}
// prepare status response
this->update_status_ = {};
this->update_status_.mode = this->data_.mode;
this->update_status_.operation = this->data_.operation;
this->update_status_.energy_mix = this->data_.energy_mix;
this->update_status_.target_temp_aircon = this->data_.target_temp_aircon;
this->update_status_prepared_ = true;
return &this->update_status_;
}
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,16 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppAirconManual
: public TrumaStausFrameResponseStorage<StatusFrameAirconManual, StatusFrameAirconManualResponse> {
public:
StatusFrameAirconManualResponse *update_prepare() override;
};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,12 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppClock : public TrumaStausFrameStorage<StatusFrameClock> {};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,12 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppConfig : public TrumaStausFrameStorage<StatusFrameConfig> {};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,27 @@
#include "TrumaiNetBoxAppHeater.h"
namespace esphome {
namespace truma_inetbox {
StatusFrameHeaterResponse *TrumaiNetBoxAppHeater::update_prepare() {
// An update is currently going on.
if (this->update_status_prepared_ || this->update_status_stale_) {
return &this->update_status_;
}
// prepare status heater response
this->update_status_ = {};
this->update_status_.target_temp_room = this->data_.target_temp_room;
this->update_status_.heating_mode = this->data_.heating_mode;
this->update_status_.el_power_level_a = this->data_.el_power_level_a;
this->update_status_.target_temp_water = this->data_.target_temp_water;
this->update_status_.el_power_level_b = this->data_.el_power_level_b;
this->update_status_.energy_mix_a = this->data_.energy_mix_a;
this->update_status_.energy_mix_b = this->data_.energy_mix_b;
this->update_status_prepared_ = true;
return &this->update_status_;
}
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,15 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppHeater : public TrumaStausFrameResponseStorage<StatusFrameHeater, StatusFrameHeaterResponse> {
public:
StatusFrameHeaterResponse* update_prepare() override;
};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,32 @@
#include "TrumaiNetBoxAppTimer.h"
namespace esphome {
namespace truma_inetbox {
StatusFrameTimerResponse *TrumaiNetBoxAppTimer::update_prepare() {
// An update is currently going on.
if (this->update_status_prepared_ || this->update_status_stale_) {
return &this->update_status_;
}
// prepare status heater response
this->update_status_ = {};
this->update_status_.timer_target_temp_room = this->data_.timer_target_temp_room;
this->update_status_.timer_heating_mode = this->data_.timer_heating_mode;
this->update_status_.timer_el_power_level_a = this->data_.timer_el_power_level_a;
this->update_status_.timer_target_temp_water = this->data_.timer_target_temp_water;
this->update_status_.timer_el_power_level_b = this->data_.timer_el_power_level_b;
this->update_status_.timer_energy_mix_a = this->data_.timer_energy_mix_a;
this->update_status_.timer_energy_mix_b = this->data_.timer_energy_mix_b;
this->update_status_.timer_resp_active = this->data_.timer_active;
this->update_status_.timer_resp_start_minutes = this->data_.timer_start_minutes;
this->update_status_.timer_resp_start_hours = this->data_.timer_start_hours;
this->update_status_.timer_resp_stop_minutes = this->data_.timer_stop_minutes;
this->update_status_.timer_resp_stop_hours = this->data_.timer_stop_hours;
this->update_status_prepared_ = true;
return &this->update_status_;
}
} // namespace truma_inetbox
} // namespace esphome

View File

@ -0,0 +1,15 @@
#pragma once
#include "TrumaStausFrameResponseStorage.h"
#include "TrumaStructs.h"
namespace esphome {
namespace truma_inetbox {
class TrumaiNetBoxAppTimer : public TrumaStausFrameResponseStorage<StatusFrameTimer, StatusFrameTimerResponse> {
public:
StatusFrameTimerResponse *update_prepare() override;
};
} // namespace truma_inetbox
} // namespace esphome

View File

@ -10,11 +10,11 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.TrumaiNetBoxApp";
bool TrumaiNetBoxApp::action_heater_room(u_int8_t temperature, HeatingMode mode) {
if (!this->truma_heater_can_update()) {
if (!this->heater_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto heater = this->update_heater_prepare();
auto heater = this->heater_.update_prepare();
heater->target_temp_room = decimal_to_room_temp(temperature);
@ -45,16 +45,16 @@ bool TrumaiNetBoxApp::action_heater_room(u_int8_t temperature, HeatingMode mode)
heater->energy_mix_a = EnergyMix::ENERGY_MIX_GAS;
}
this->update_heater_submit();
this->heater_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_heater_water(u_int8_t temperature) {
if (!this->truma_heater_can_update()) {
if (!this->heater_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto heater = this->update_heater_prepare();
auto heater = this->heater_.update_prepare();
heater->target_temp_water = decimal_to_water_temp(temperature);
@ -63,16 +63,16 @@ bool TrumaiNetBoxApp::action_heater_water(u_int8_t temperature) {
heater->energy_mix_a = EnergyMix::ENERGY_MIX_GAS;
}
this->update_heater_submit();
this->heater_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_heater_water(TargetTemp temperature) {
if (!this->truma_heater_can_update()) {
if (!this->heater_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto heater = this->update_heater_prepare();
auto heater = this->heater_.update_prepare();
// If parameter `temperature` contains a valid mode use it or else use `OFF`.
if (temperature == TargetTemp::TARGET_TEMP_WATER_ECO || temperature == TargetTemp::TARGET_TEMP_WATER_HIGH ||
@ -87,16 +87,16 @@ bool TrumaiNetBoxApp::action_heater_water(TargetTemp temperature) {
heater->energy_mix_a = EnergyMix::ENERGY_MIX_GAS;
}
this->update_heater_submit();
this->heater_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_heater_electric_power_level(u_int16_t value) {
if (!this->truma_heater_can_update()) {
if (!this->heater_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto heater = this->update_heater_prepare();
auto heater = this->heater_.update_prepare();
heater->el_power_level_a = decimal_to_el_power_level(value);
if (heater->el_power_level_a != ElectricPowerLevel::ELECTRIC_POWER_LEVEL_0) {
@ -108,16 +108,16 @@ bool TrumaiNetBoxApp::action_heater_electric_power_level(u_int16_t value) {
heater->energy_mix_a = EnergyMix::ENERGY_MIX_GAS;
}
this->update_heater_submit();
this->heater_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_heater_energy_mix(EnergyMix energy_mix, ElectricPowerLevel el_power_level) {
if (!this->truma_heater_can_update()) {
if (!this->heater_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto heater = this->update_heater_prepare();
auto heater = this->heater_.update_prepare();
// If parameter `el_power_level` contains a valid mode use it.
if (el_power_level == ElectricPowerLevel::ELECTRIC_POWER_LEVEL_0 ||
@ -147,27 +147,27 @@ bool TrumaiNetBoxApp::action_heater_energy_mix(EnergyMix energy_mix, ElectricPow
heater->energy_mix_a = EnergyMix::ENERGY_MIX_GAS;
}
this->update_heater_submit();
this->heater_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_timer_disable() {
if (!this->truma_timer_can_update()) {
if (!this->timer_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
auto timer = this->update_timer_prepare();
auto timer = this->timer_.update_prepare();
timer->timer_resp_active = TimerActive::TIMER_ACTIVE_OFF;
this->update_timer_submit();
this->timer_.update_submit();
return true;
}
bool TrumaiNetBoxApp::action_timer_activate(u_int16_t start, u_int16_t stop, u_int8_t room_temperature,
HeatingMode mode, u_int8_t water_temperature, EnergyMix energy_mix,
ElectricPowerLevel el_power_level) {
if (!this->truma_timer_can_update()) {
if (!this->timer_.can_update()) {
ESP_LOGW(TAG, "Cannot update Truma.");
return false;
}
@ -176,7 +176,7 @@ bool TrumaiNetBoxApp::action_timer_activate(u_int16_t start, u_int16_t stop, u_i
return false;
}
auto timer = this->update_timer_prepare();
auto timer = this->timer_.update_prepare();
timer->timer_resp_active = TimerActive::TIMER_ACTIVE_ON;
timer->timer_resp_start_hours = start / 60;
@ -235,7 +235,7 @@ bool TrumaiNetBoxApp::action_timer_activate(u_int16_t start, u_int16_t stop, u_i
}
}
this->update_timer_submit();
this->timer_.update_submit();
return true;
}

View File

@ -85,7 +85,7 @@ template<typename... Ts> class WriteTimeAction : public Action<Ts...>, public Pa
class TrumaiNetBoxAppHeaterMessageTrigger : public Trigger<const StatusFrameHeater *> {
public:
explicit TrumaiNetBoxAppHeaterMessageTrigger(TrumaiNetBoxApp *parent) {
parent->add_on_heater_message_callback([this](const StatusFrameHeater *message) { this->trigger(message); });
parent->get_heater()->add_on_message_callback([this](const StatusFrameHeater *message) { this->trigger(message); });
}
};

View File

@ -8,7 +8,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.heater_binary_sensor";
void TrumaHeaterBinarySensor::setup() {
this->parent_->add_on_heater_message_callback([this](const StatusFrameHeater *status_heater) {
this->parent_->get_heater()->add_on_message_callback([this](const StatusFrameHeater *status_heater) {
switch (this->type_) {
case TRUMA_BINARY_SENSOR_TYPE::HEATER_ROOM:
this->publish_state(status_heater->target_temp_room != TargetTemp::TARGET_TEMP_OFF);

View File

@ -8,7 +8,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.timer_binary_sensor";
void TrumaTimerBinarySensor::setup() {
this->parent_->add_on_timer_message_callback([this](const StatusFrameTimer *status_timer) {
this->parent_->get_timer()->add_on_message_callback([this](const StatusFrameTimer *status_timer) {
switch (this->type_) {
case TRUMA_BINARY_SENSOR_TYPE::TIMER_ACTIVE:
this->publish_state(status_timer->timer_active == TimerActive::TIMER_ACTIVE_ON);

View File

@ -6,7 +6,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.room_climate";
void TrumaRoomClimate::setup() {
this->parent_->add_on_heater_message_callback([this](const StatusFrameHeater *status_heater) {
this->parent_->get_heater()->add_on_message_callback([this](const StatusFrameHeater *status_heater) {
// Publish updated state
this->target_temperature = temp_code_to_decimal(status_heater->target_temp_room);
this->current_temperature = temp_code_to_decimal(status_heater->current_temp_room);
@ -43,7 +43,7 @@ void TrumaRoomClimate::control(const climate::ClimateCall &call) {
if (call.get_mode().has_value()) {
// User requested mode change
climate::ClimateMode mode = *call.get_mode();
auto status_heater = this->parent_->get_status_heater();
auto status_heater = this->parent_->get_heater()->get_status();
switch (mode) {
case climate::CLIMATE_MODE_HEAT:
if (status_heater->target_temp_room == TargetTemp::TARGET_TEMP_OFF) {
@ -58,7 +58,7 @@ void TrumaRoomClimate::control(const climate::ClimateCall &call) {
if (call.get_preset().has_value()) {
climate::ClimatePreset pres = *call.get_preset();
auto status_heater = this->parent_->get_status_heater();
auto status_heater = this->parent_->get_heater()->get_status();
auto current_target_temp = temp_code_to_decimal(status_heater->target_temp_room);
if (call.get_target_temperature().has_value()) {
current_target_temp = *call.get_target_temperature();

View File

@ -6,7 +6,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.water_climate";
void TrumaWaterClimate::setup() {
this->parent_->add_on_heater_message_callback([this](const StatusFrameHeater *status_heater) {
this->parent_->get_heater()->add_on_message_callback([this](const StatusFrameHeater *status_heater) {
// Publish updated state
this->target_temperature = temp_code_to_decimal(status_heater->target_temp_water);
this->current_temperature = temp_code_to_decimal(status_heater->current_temp_water);
@ -26,7 +26,7 @@ void TrumaWaterClimate::control(const climate::ClimateCall &call) {
if (call.get_mode().has_value()) {
climate::ClimateMode mode = *call.get_mode();
auto status_heater = this->parent_->get_status_heater();
auto status_heater = this->parent_->get_heater()->get_status();
switch (mode) {
case climate::CLIMATE_MODE_HEAT:
if (status_heater->target_temp_water == TargetTemp::TARGET_TEMP_OFF) {

View File

@ -8,7 +8,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.heater_number";
void TrumaHeaterNumber::setup() {
this->parent_->add_on_heater_message_callback([this](const StatusFrameHeater *status_heater) {
this->parent_->get_heater()->add_on_message_callback([this](const StatusFrameHeater *status_heater) {
switch (this->type_) {
case TRUMA_NUMBER_TYPE::TARGET_ROOM_TEMPERATURE:
this->publish_state(temp_code_to_decimal(status_heater->target_temp_room, 0));

View File

@ -8,7 +8,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.sensor";
void TrumaSensor::setup() {
this->parent_->add_on_heater_message_callback([this](const StatusFrameHeater *status_heater) {
this->parent_->get_heater()->add_on_message_callback([this](const StatusFrameHeater *status_heater) {
switch (this->type_) {
case TRUMA_SENSOR_TYPE::CURRENT_ROOM_TEMPERATURE:
this->publish_state(temp_code_to_decimal(status_heater->current_temp_room));

View File

@ -8,7 +8,7 @@ namespace truma_inetbox {
static const char *const TAG = "truma_inetbox.time";
void TrumaTime::setup() {
this->parent_->add_on_clock_message_callback([this](const StatusFrameClock *status_clock) {
this->parent_->get_clock()->add_on_message_callback([this](const StatusFrameClock *status_clock) {
if (this->auto_disable_count_ > 0) {
if (this->read_time() && this->auto_disable_) {
this->auto_disable_count_--;
@ -22,10 +22,10 @@ void TrumaTime::update() {}
void TrumaTime::dump_config() { ESP_LOGCONFIG(TAG, "Truma Time", this); }
bool TrumaTime::read_time() {
if (!this->parent_->get_status_clock_valid()) {
if (!this->parent_->get_clock()->get_status_valid()) {
return false;
}
auto status_clock = this->parent_->get_status_clock();
auto status_clock = this->parent_->get_clock()->get_status();
time::ESPTime rtc_time{.second = status_clock->clock_second,
.minute = status_clock->clock_minute,