tuk90 / RemehaHome-Domoticz

MIT License
0 stars 0 forks source link

Energy consumption #10

Closed tuk90 closed 7 months ago

gizmocuz commented 7 months ago

My Remeha does not have these values. Maybe when the system has no 'hotWaterZones', this value needs to be polled?

tuk90 commented 7 months ago

I will add an iff clause somewhere that if appliancetype not like heatpump then skip this function.

But if you do the get daily consumption like this you do not get any results?

GET https://api.bdrthermea.net/Mobile/api/appliances/afb766c1-1c1f-4267-9e14-171492f2d53a/energyconsumption/daily?startDate=2024-01-01T00:00:00.000Z&endDate=2024-01-31T00:00:00.000Z HTTP/1.1 Ocp-Apim-Subscription-Key: df605c5470d846fc91e848b1cc653ddf Authorization: Bearer

gizmocuz commented 7 months ago

Yes, I do get values:

{
  'startDateTimeUsed': '1900-01-01T00:00:00+00:00',
  'endDateTimeUsed': '2023-12-31T00:00:00+00:00',
  'data': [
    {
      'timeStamp': '2021-12-31T00:00:00+00:00',
      'heatingEnergyConsumed': 572.0,
      'hotWaterEnergyConsumed': 643.0,
      'coolingEnergyConsumed': 0,
      'heatingEnergyDelivered': 0,
      'hotWaterEnergyDelivered': 0,
      'coolingEnergyDelivered': 0
    },
    {
      'timeStamp': '2022-12-31T00:00:00+00:00',
      'heatingEnergyConsumed': 976.0,
      'hotWaterEnergyConsumed': 1356.0,
      'coolingEnergyConsumed': 0,
      'heatingEnergyDelivered': 0,
      'hotWaterEnergyDelivered': 0,
      'coolingEnergyDelivered': 0
    },
    {
      'timeStamp': '2023-12-31T00:00:00+00:00',
      'heatingEnergyConsumed': 603.0,
      'hotWaterEnergyConsumed': 1067.0,
      'coolingEnergyConsumed': 0,
      'heatingEnergyDelivered': 0,
      'hotWaterEnergyDelivered': 0,
      'coolingEnergyDelivered': 0
    }
  ]
}

'hotWaterEnergyConsumed' is also available

But maybe you could make it an option.... or not poll at all. Is this information not available in your P1 meter?

I have a few issues with this....

If we want to enjoy reading/setting the temperature/setpoint, we should limit the API calls. That was the first reason why I implemented the poll interval, I think 30 seconds is way too many calls (2880 a day)

This new function 'getDailyEnergyConsumption', is not doing one call to the API, it is doing 4 calls, so we have a total of 5 calls = 14400 HTTP/API calls a day!?!

You can also call 'https://api.bdrthermea.net/Mobile/api/homes/dashboard' one time and store the result in a variable (self.dashboard) and use this throughout the code This will already safe quite a few HTTP calls

maybe limit the calls to 'getDailyEnergyConsumption' per hour?

But do you need this information in Domoticz?

Imagine if 1000 users where going to use this plugin with 14400 ....

I was invited once to the office of 'toon' ... because there servers where not functioning correctly anymore because we polled so much.

tuk90 commented 7 months ago

There is a reason why it is not yet in master, I agree on the amount of calls that is also why I created a friendly reminder for myself in: https://github.com/tuk90/RemehaHome-Domoticz/issues/12

The polling you created results in hardware not responding errors in Domoticz as bwboot mentioned. So the polling should be done often but the api calls should not be done everytime.

Before this goes to production I will dramatically decrease the amount of calls.

gizmocuz commented 7 months ago

Please note that I'm really happy with this plugin and that my comments are only suggestions! 😂👍

tuk90 commented 7 months ago

@gizmocuz I did some changes to the code, I set appliance_id and climate_zone_id as global variables, they will be set after the first heartbeat. Furthermore the get daily energy consumption only runs once an hour since it seems like the API only gets updated once an hour.

Are all you problems solved now :)?

gizmocuz commented 7 months ago

I was already very happy by seeing the setpoint, DHW and able to change the setpoint 😊😂 Now it's even beyond perfection! Great!!! Are you going to merge this in the main branch?

tuk90 commented 7 months ago

Yes I will:)