Newan / ioBroker.evcc

ioBroker Adapter to control your evcc instance
MIT License
10 stars 6 forks source link

Feature Request - Sum chargedEnergy #28

Open michiproep opened 7 months ago

michiproep commented 7 months ago

Hi, I'm not sure if it's feasible but it would be great to have two additional datapoints per loadpoint

As a background, I'm using evcc for my heatpump and I would like to be able to calculate the energyconsumption for my heatpump per day while differentiating between totalConsumption vs "consumptionWithoutEvccTriggeredConsumption". Does that make sense?

timoglaess commented 6 months ago

Hi, interessting would be also:

to show the values in iobroker vis and work with influx and grafana...

Update: There is already a "statistics" datapoint array. I finally managed to get out the Energy values from the array :-)

on({ id: [].concat(['evcc.0.status.statistics']), change: 'ne' }, async (obj) => {
  let value = obj.state.val;
  let oldValue = obj.oldState.val;
  Liste = getState('evcc.0.status.statistics').val;
  setState('0_userdata.0.evcc.SumChargedEnergyMonth' /* SumChargedEnergyMonth */, getAttr(Liste, '30d.chargedKWh'), true);
  setState('0_userdata.0.evcc.AveragePriceMonth' /* AveragePriceMonth */, getAttr(Liste, '30d.avgPrice'), true);
  setState('0_userdata.0.evcc.RealCostMonth' /* RealCostMonth */, Math.round((getState('0_userdata.0.evcc.SumChargedEnergyMonth').val * getState('0_userdata.0.evcc.AveragePriceMonth').val) * 100) / 100, true);
  setState('0_userdata.0.evcc.SumChargedEnergyYear' /* SumChargedEnergyYear */, getAttr(Liste, '365d.chargedKWh'), true);
  setState('0_userdata.0.evcc.AveragePriceYear' /* AveragePriceYear */, getAttr(Liste, '365d.avgPrice'), true);
  setState('0_userdata.0.evcc.RealCostYear' /* RealCostYear */, Math.round((getState('0_userdata.0.evcc.SumChargedEnergyYear').val * getState('0_userdata.0.evcc.AveragePriceYear').val) * 100) / 100, true);
  setState('0_userdata.0.evcc.SumChargedEnergyTotal' /* SumChargedEnergyTotal */, getAttr(Liste, 'total.chargedKWh'), true);
  setState('0_userdata.0.evcc.AveragePriceTotal' /* AveragePriceTotal */, getAttr(Liste, 'total.avgPrice'), true);
  setState('0_userdata.0.evcc.RealCostTotal' /* RealCostTotal */, Math.round((getState('0_userdata.0.evcc.SumChargedEnergyTotal').val * getState('0_userdata.0.evcc.AveragePriceTotal').val) * 100) / 100, true);
});