110 lines
3.7 KiB
C#
110 lines
3.7 KiB
C#
using BoilerMonitor.Models;
|
|
using LightMonitor.Models;
|
|
using NordPool.Models;
|
|
using ShowerMonitor.Models;
|
|
|
|
namespace HomeAssistant.HistoryReplay.Configuration;
|
|
|
|
public static class ReplayEntityMap
|
|
{
|
|
public static IReadOnlyList<string> GetNordPoolEntities() =>
|
|
[
|
|
"sensor.nordpool_kwh_lt_eur_3_10_0",
|
|
NordPoolConsts.CurrentPriceEntityId,
|
|
BoilerMonitorConsts.BoilerDailyHoursEntityId,
|
|
BoilerMonitorConsts.BoilerPriceCapEntityId,
|
|
BoilerMonitorConsts.BoilerReadyByEntityId,
|
|
BoilerMonitorConsts.SkipPriceCapEntityId
|
|
];
|
|
|
|
public static IReadOnlyList<string> GetBoilerEntities(string boilerPowerEntityId, string boilerSwitchEntityId) =>
|
|
[
|
|
boilerPowerEntityId,
|
|
boilerSwitchEntityId,
|
|
"sensor.nordpool_cheapest_intervals",
|
|
BoilerMonitorConsts.SkipPriceCapEntityId,
|
|
BoilerMonitorConsts.BudgetOverrideEntityId,
|
|
BoilerMonitorConsts.AutoManagementEntityId,
|
|
BoilerMonitorConsts.BoilerDailyHoursEntityId
|
|
];
|
|
|
|
public static IReadOnlyList<string> GetShowerEntities(string bathroomHumidityEntityId, string mainHomeHumidityEntityId) =>
|
|
[
|
|
bathroomHumidityEntityId,
|
|
mainHomeHumidityEntityId
|
|
];
|
|
|
|
public static IReadOnlyList<string> GetPowerEntities(string mainMeterEntityId) =>
|
|
[
|
|
mainMeterEntityId,
|
|
NordPoolConsts.CurrentPriceEntityId
|
|
];
|
|
|
|
public static IReadOnlyList<string> GetLightEntities(string sunEntityId, string lightEntityId, string[] personEntityIds)
|
|
{
|
|
var entities = new List<string> { sunEntityId, lightEntityId };
|
|
entities.AddRange(personEntityIds);
|
|
return entities;
|
|
}
|
|
|
|
public static IReadOnlyList<string> GetEntitiesRequiringAttributes() =>
|
|
[
|
|
"sensor.nordpool_cheapest_intervals"
|
|
];
|
|
|
|
public static IReadOnlyList<string> GetAllEntities(
|
|
string boilerPowerEntityId,
|
|
string boilerSwitchEntityId,
|
|
string bathroomHumidityEntityId,
|
|
string mainHomeHumidityEntityId,
|
|
string mainMeterEntityId,
|
|
string sunEntityId,
|
|
string lightEntityId,
|
|
string[] personEntityIds)
|
|
{
|
|
var all = new HashSet<string>();
|
|
|
|
foreach (var e in GetNordPoolEntities()) all.Add(e);
|
|
foreach (var e in GetBoilerEntities(boilerPowerEntityId, boilerSwitchEntityId)) all.Add(e);
|
|
foreach (var e in GetShowerEntities(bathroomHumidityEntityId, mainHomeHumidityEntityId)) all.Add(e);
|
|
foreach (var e in GetPowerEntities(mainMeterEntityId)) all.Add(e);
|
|
foreach (var e in GetLightEntities(sunEntityId, lightEntityId, personEntityIds)) all.Add(e);
|
|
|
|
return [.. all];
|
|
}
|
|
|
|
public static (IReadOnlyList<string> MinimalEntities, IReadOnlyList<string> FullEntities) GetPartitionedEntities(
|
|
string boilerPowerEntityId,
|
|
string boilerSwitchEntityId,
|
|
string bathroomHumidityEntityId,
|
|
string mainHomeHumidityEntityId,
|
|
string mainMeterEntityId,
|
|
string sunEntityId,
|
|
string lightEntityId,
|
|
string[] personEntityIds)
|
|
{
|
|
var allEntities = GetAllEntities(
|
|
boilerPowerEntityId, boilerSwitchEntityId,
|
|
bathroomHumidityEntityId, mainHomeHumidityEntityId,
|
|
mainMeterEntityId, sunEntityId, lightEntityId, personEntityIds);
|
|
|
|
var fullSet = new HashSet<string>(GetEntitiesRequiringAttributes(), StringComparer.OrdinalIgnoreCase);
|
|
var minimal = new List<string>();
|
|
var full = new List<string>();
|
|
|
|
foreach (var entity in allEntities)
|
|
{
|
|
if (fullSet.Contains(entity))
|
|
{
|
|
full.Add(entity);
|
|
}
|
|
else
|
|
{
|
|
minimal.Add(entity);
|
|
}
|
|
}
|
|
|
|
return (minimal, full);
|
|
}
|
|
}
|