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

HA custom component for Bosch thermostats
Apache License 2.0
218 stars 45 forks source link

fetch_recordings_sensor_range service doesn't work #266

Closed doudz closed 1 year ago

doudz commented 1 year ago

Trying to use fetch_recordings_sensor_range I got the following error

Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/websocket_api/commands.py", line 647, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 1524, in async_run
await asyncio.shield(run.async_run())
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 409, in async_run
await self._async_step(log_exceptions=False)
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 453, in _async_step
self._handle_exception(
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 476, in _handle_exception
raise exception
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 451, in _async_step
await getattr(self, handler)()
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/script.py", line 684, in _async_call_service_step
await service_task
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1808, in async_call
task.result()
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 1845, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/home/doudz/.homeassistant/custom_components/bosch/services.py", line 95, in async_handle_recording_sensor_fetch_past
await entity.insert_statistics_range(start_time=day)
AttributeError: 'EnergySensor' object has no attribute 'insert_statistics_range'
pszafer commented 1 year ago

it's for recording sensors currently. I can make it for Energy as well if you found it useful.

doudz commented 1 year ago

oh ok it can be useful since there is data missing... image

pszafer commented 1 year ago

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

doudz commented 1 year ago

no more error but it doesn't seems to work but maybe I'm wrong ? image

image

pszafer commented 1 year ago

Service added in v0.22.1

doudz commented 1 year ago

Thanks ! But could you please tell how it works ? I tried the following to retrieve missing data but it does nothing... image

pszafer commented 1 year ago

Turn on debug logs for the time of service call and check: It should try to fetch data page by page until it'd find date you want. image

doudz commented 1 year ago

Hi

I tried

2023-04-06 20:16:08.044 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139791145465792] Received {'type': 'execute_script', 'sequence': [{'service': 'bosch.fetch_recordings_sensor_range', 'data': {'uuid': '101027819', 'day': '2023-03-06', 'statistic_id': 'sensors:ehwenergy_hot_waterexternal'}}], 'id': 42}
2023-04-06 20:16:08.046 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2023-04-06 20:16:08.047 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2023-04-06 20:16:08.048 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=bosch, service=fetch_recordings_sensor_range, service_data=uuid=101027819, day=2023-03-06, statistic_id=sensors:ehwenergy_hot_waterexternal>
2023-04-06 20:16:08.049 DEBUG (MainThread) [custom_components.bosch.services] Performing sensor update on service request. UUID: 101027819
2023-04-06 20:16:08.050 DEBUG (MainThread) [custom_components.bosch] Next update of 1-hour sensors scheduled at: 2023-04-06 21:06:00+02:00
2023-04-06 20:16:08.051 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139791145465792] Sending {"id":42,"type":"result","success":true,"result":{"context":{"id":"01GXBWGXKD3SJ3FYFYSEWX9YN5","parent_id":null,"user_id":"82dec7e7b0f54de399b80bf36264fa89"}}}
2023-04-06 20:16:08.052 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=bosch, service=fetch_recordings_sensor_range, service_data=uuid=101027819, day=2023-03-06, statistic_id=sensors:ehwenergy_hot_waterexternal>)

and that's all... I don't see any request to history