Skip to content

Commit

Permalink
Add more signals to Luxtronik
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Suter committed Aug 31, 2023
1 parent d00826b commit d975957
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/HomeBlaze.Luxtronik/LuxtronikDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public class LuxtronikDevice : BackgroundService,
private ClientWebSocket? _webSocket;
private bool _isRunning = true;
private bool _isInitialized = false;
private DateTimeOffset? _totalCoolingOperatingTimeChange = null;
private XDocument? _metadataXml;

private DateTimeOffset? _totalHeatPumpOperatingTimeChange = null;
private DateTimeOffset? _totalHeatingOperatingTimeChange = null;
private DateTimeOffset? _totalWaterHeatingOperatingTimeChange = null;
private DateTimeOffset? _totalCoolingOperatingTimeChange = null;

public string? Title => DisplayTitle;

public string IconName => "fa-solid fa-fire";
Expand Down Expand Up @@ -163,9 +167,19 @@ public decimal? TotalCoefficientOfPerformance
public TimeSpan? TotalCoolingOperatingTime { get; private set; }


[State(IsEstimated = true)]
public bool IsHeatPumpOperating { get; private set; }

[State(IsEstimated = true)]
public bool IsHeating { get; private set; }

[State(IsEstimated = true)]
public bool IsWaterHeating { get; private set; }

[State(IsEstimated = true)]
public bool IsCooling { get; private set; }


public LuxtronikDevice(IThingManager thingManager, ILogger<LuxtronikDevice> logger)
{
_thingManager = thingManager;
Expand Down Expand Up @@ -326,19 +340,43 @@ private void ProcessValues(XDocument xmlDocument)

FlowRate = GetDecimal(allValues, incoming, new[] { "Durchfluss" });

var previousTotalHeatPumpOperatingTime = TotalHeatPumpOperatingTime;
var previousTotalHeatingOperatingTime = TotalHeatingOperatingTime;
var previousTotalWaterHeatingOperatingTime = TotalWaterHeatingOperatingTime;
var previousTotalCoolingOperatingTime = TotalCoolingOperatingTime;

TotalHeatPumpOperatingTime = GetTimeSpan(allValues, operatingHours, new[] { "Betriebstunden WP" });
TotalHeatingOperatingTime = GetTimeSpan(allValues, operatingHours, new[] { "Betriebstunden Heiz." });
TotalWaterHeatingOperatingTime = GetTimeSpan(allValues, operatingHours, new[] { "Betriebstunden WW" });

var previousTotalCoolingOperatingTime = TotalCoolingOperatingTime;
TotalCoolingOperatingTime = GetTimeSpan(allValues, operatingHours, new[] { "Betriebstunden Kuehl" });

if (previousTotalHeatPumpOperatingTime != null &&
previousTotalHeatPumpOperatingTime != TotalHeatPumpOperatingTime)
{
_totalHeatPumpOperatingTimeChange = DateTimeOffset.Now;
}

if (previousTotalHeatingOperatingTime != null &&
previousTotalHeatingOperatingTime != TotalHeatingOperatingTime)
{
_totalHeatingOperatingTimeChange = DateTimeOffset.Now;
}

if (previousTotalWaterHeatingOperatingTime != null &&
previousTotalWaterHeatingOperatingTime != TotalWaterHeatingOperatingTime)
{
_totalWaterHeatingOperatingTimeChange = DateTimeOffset.Now;
}

if (previousTotalCoolingOperatingTime != null &&
previousTotalCoolingOperatingTime != TotalCoolingOperatingTime)
{
_totalCoolingOperatingTimeChange = DateTimeOffset.Now;
}

IsHeatPumpOperating = DateTimeOffset.Now - _totalHeatPumpOperatingTimeChange < TimeSpan.FromMinutes(65);
IsHeating = DateTimeOffset.Now - _totalHeatingOperatingTimeChange < TimeSpan.FromMinutes(65);
IsWaterHeating = DateTimeOffset.Now - _totalWaterHeatingOperatingTimeChange < TimeSpan.FromMinutes(65);
IsCooling = DateTimeOffset.Now - _totalCoolingOperatingTimeChange < TimeSpan.FromMinutes(65);

TotalProducedHeatEnergy = GetDecimal(allValues, heatEnergy, new[] { "Heizung" }) * 1000;
Expand All @@ -363,6 +401,7 @@ private void ProcessValues(XDocument xmlDocument)
}

private decimal? _previousTotalConsumedEnergy;

private DateTimeOffset? _previousTotalConsumedEnergyTime;

private void RecalculatePowerConsumption()
Expand Down

0 comments on commit d975957

Please sign in to comment.