bosch-thermostat / home-assistant-bosch-custom-component

HA custom component for Bosch thermostats
Apache License 2.0
233 stars 46 forks source link

Wrong statistic with v0.21.0 #271

Closed igieon closed 1 year ago

igieon commented 1 year ago

Describe the bug In statistics its displayed negative consumption ;-/ image

Also its just now i fix to 2 via statistics adjust but its returned to -2 here its debug scan bosch_scan.json.txt

Also after upgrade i have spike in gas consuption and also negative values like: Recording ractualDHWPower 931 kWh Recording ractualCHPower -9 kWh

image

igieon commented 1 year ago

And now in statistics for this -2 is displayed 657 kwh which is wrong. Also home assitant version is Home Assistant 2023.3.3 Frontend 20230309.0 - image

igieon commented 1 year ago

@pszafer ok today same problem but also for today is missing heating data. Now also doesnt work trick which works with version 0.20.0 where you under reload the data is loaded. image here is bosh scan bosch_scan.json.txt and when you look into recording /recordings/heatSources/actualCHPower?interval=2023-3-15 its this data and you see we have recorded values:

actualch.txt but no values in statistics. also for dhw here is recordings: actualdhw.txt and now update statistics: image

Can you point me in code where i can see what can be wrong or how to mock it in code with this recording to see if its correct inserted.

pszafer commented 1 year ago

I'm trying to fix it. Unfortunately I or some HA helper function messes up with timezones.

igieon commented 1 year ago

If you can point me on part of code i can try review it or i can dest it something with debug loggin enabled.

igieon commented 1 year ago

Ok when i execute for previous day:

service: bosch.fetch_recordings_sensor_range
data: 
  uuid: 
  day: "2023-03-15"
  statistic_id: "recording:recording_ractualchpowerexternal"

statistics are fixed

pszafer commented 1 year ago

Check out https://github.com/bosch-thermostat/home-assistant-bosch-custom-component/releases/tag/v0.22.0dev1

igieon commented 1 year ago

I upgrade to 0.22.0dev1 buti get error:

2023-03-21 22:39:52.288 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall bosch.fetch_recordings_sensor_range xxxxxx, day=2023-03-20, statistic_id=recording:recording_ractualchpowerexternal>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1826, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/bosch/services.py", line 95, in async_handle_recording_sensor_fetch_past
    await entity.insert_statistics_range(start_time=day)
  File "/config/custom_components/bosch/sensor/statistic_helper.py", line 130, in insert_statistics_range
    await self._upsert_past_statistics(start=start, stop=stop)
  File "/config/custom_components/bosch/sensor/recording.py", line 94, in _upsert_past_statistics
    stats = await self.fetch_past_data(
  File "/config/custom_components/bosch/sensor/statistic_helper.py", line 141, in fetch_past_data
    return await self._bosch_object.fetch_range(
  File "/usr/local/lib/python3.10/site-packages/bosch_thermostat_client/sensors/recording.py", line 65, in fetch_range
    data = await self._connector.get(uri)
  File "/usr/local/lib/python3.10/site-packages/bosch_thermostat_client/connectors/xmpp.py", line 97, in get
    raise DeviceException(f"Error requesting data from {path}")
bosch_thermostat_client.exceptions.DeviceException: Error requesting data from /recordings/heatSources/actualCHPower?interval=2023-03-20

You add IVT_MBLAN what is this device ? also error is using xmpp but i have it as local configured.

After some reload and i can execute again:

service: bosch.fetch_recordings_sensor_range
data:
  uuid: "953420077"
  day: "2023-03-20"
  statistic_id: recording:recording_ractualchpowerexternal

I dont get anymore error i fetched recordign for march and seems data are same as in app for energy consuption. I will look if reading are correct for next days

pszafer commented 1 year ago

@igieon IVT_MBLAN are devices which doesn't provide serial number but are working on ivt protocol... Anyway, statistic should be correct in the newest version

igieon commented 1 year ago

@pszafer yes statics are now correct. Thank you for fix. I was trying to understand code but not so much luck or effort ;-).