Skip to content

Commit

Permalink
Merge pull request #768 from visualapproach/development_v4
Browse files Browse the repository at this point in the history
Development v4
  • Loading branch information
visualapproach authored Jul 19, 2024
2 parents 8cda33b + 08e8fe2 commit fac6ba2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Code/lib/BWC_unified/FW_VERSION.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define FW_VERSION "2024-07-18-1553"
#define FW_VERSION "2024-07-19-0816"
19 changes: 11 additions & 8 deletions Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ bool BWC::_handlecommand(Commands cmd, int64_t val, const String& txt="")
_heatingtime_ms = 0;
_airtime_ms = 0;
_energy_total_kWh = 0;
_energy_daily_Ws = 0;
_energy_cost = 0;
_save_settings_needed = true;
_new_data_available = true;
Expand Down Expand Up @@ -1196,20 +1197,22 @@ void BWC::_updateTimes(){
if(_override_dsp_brt_timer > 0) _override_dsp_brt_timer -= elapsedtime_ms; //counts down to or below zero

// watts, kWh today, total kWh
float heatingEnergy = (_heatingtime+_heatingtime_ms/1000)/3600.0 * cio->getHeaterPower();
float pumpEnergy = (_pumptime+_pumptime_ms/1000)/3600.0 * cio->getPowerLevels().PUMPPOWER;
float airEnergy = (_airtime+_airtime_ms/1000)/3600.0 * cio->getPowerLevels().AIRPOWER;
float idleEnergy = (_uptime+_uptime_ms/1000)/3600.0 * cio->getPowerLevels().IDLEPOWER;
float jetEnergy = (_jettime+_jettime_ms/1000)/3600.0 * cio->getPowerLevels().JETPOWER;
_energy_total_kWh = (heatingEnergy + pumpEnergy + airEnergy + idleEnergy + jetEnergy)/1000; //Wh -> kWh
// float heatingEnergy = (_heatingtime+_heatingtime_ms/1000)/3600.0 * cio->getHeaterPower();
// float pumpEnergy = (_pumptime+_pumptime_ms/1000)/3600.0 * cio->getPowerLevels().PUMPPOWER;
// float airEnergy = (_airtime+_airtime_ms/1000)/3600.0 * cio->getPowerLevels().AIRPOWER;
// float idleEnergy = (_uptime+_uptime_ms/1000)/3600.0 * cio->getPowerLevels().IDLEPOWER;
// float jetEnergy = (_jettime+_jettime_ms/1000)/3600.0 * cio->getPowerLevels().JETPOWER;
// _energy_total_kWh = (heatingEnergy + pumpEnergy + airEnergy + idleEnergy + jetEnergy)/1000; //Wh -> kWh
_energy_power_W = cio->cio_states.heatred * cio->getHeaterPower();
_energy_power_W += cio->cio_states.pump * cio->getPowerLevels().PUMPPOWER;
_energy_power_W += cio->cio_states.bubbles * cio->getPowerLevels().AIRPOWER;
_energy_power_W += cio->getPowerLevels().IDLEPOWER;
_energy_power_W += cio->cio_states.jets * cio->getPowerLevels().JETPOWER;

_energy_daily_Ws += elapsedtime_ms * _energy_power_W / 1000.0;
_energy_cost += elapsedtime_ms *_price * _energy_power_W / (1000.0 * 1000.0 * 3600.0); // money/kWh
constexpr double mws2kwh = 1/3600000000.0;
_energy_total_kWh += elapsedtime_ms * _energy_power_W * mws2kwh; //mWs -> kWh
_energy_daily_Ws += elapsedtime_ms * _energy_power_W *0.001;
_energy_cost += elapsedtime_ms *_price * _energy_power_W * mws2kwh; // money/kWh

if(_notes.size())
{
Expand Down
4 changes: 2 additions & 2 deletions Code/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void setup()
mqtt_info->mqttTelemetryInterval = 600;
mqtt_info->mqttUsername = MQTT_USER_F;
mqtt_info->useMqtt = true;
wifi_info = new sWifi_info;
wifi_info = new sWifi_info{.enableWmApFallback = true};
}
bwc->setup();
bwc->loop();
Expand Down Expand Up @@ -327,7 +327,7 @@ void startWiFi()
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
WiFi.hostname(DEVICE_NAME_F);
WiFi.mode(WIFI_STA);
WiFi.mode(WIFI_STA); //WiFi.setOutputPower(15.0);
loadWifi();

if (wifi_info->enableStaticIp4)
Expand Down

0 comments on commit fac6ba2

Please sign in to comment.