Danielhiversen / home_assistant_tibber_custom

Display Tibber prices and energy consumption as a graph. Tibber is available in Germany, Norway and Sweden Tibber has helped tens of thousands of new customers each month in Sweden, Norway & Germany to lower their energy bill and consumption. Tibber is using digital technology to make electricity consumption smarter. If you use this link to signup for Tibber, you get 50 euro to buy smart home products in the Tibber store: https://invite.tibber.com/6fd7a447
Apache License 2.0
80 stars 17 forks source link

Graph not updating. #15

Closed Coffeeman666 closed 3 years ago

Coffeeman666 commented 3 years ago

After various updates my Tibber Custom graph no longger updates. Tried to reinstall Tibber Custom a couple of times. And also tried to delete the graph manually. Resulting in no graph at all. It no longer saves the .png file. Anyone else with this problem?

Pythm commented 3 years ago

It stopped updating the graph some days ago. I had updated both HA and the tibber_custom the day before I noticed it. Have not done any further testing to try to make it work.

marhilde commented 3 years ago

I have a similar problem. Graph is not updating and I can't find any errors in the logs. It has been like this for a while now, maybe two weeks

Letalis commented 3 years ago

I encounter this aswell. I have removed integration completely and "installed" it again. Everything looks okej but no png is created. And no errors in the logs either. Even tried to use my postalcode instead of streetname since my contains the swedish "ö". Just to exclude that as a failure possible.

espenfjo commented 3 years ago

I removed the exception handling around the "save" part of the image generation function. The exception handling is only set to print its errors if debugging is turned on, should probably be a _LOGGER.critical..

Anyways, without the exception handling I get the following error message which shows why this fails:

2021-05-21 19:39:43 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 71, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 135, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 131, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 486, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 503, in handle
    image = await camera.async_camera_image()
  File "/config/custom_components/tibber_custom/camera.py", line 48, in async_camera_image
    await self._generate_fig()
  File "/config/custom_components/tibber_custom/camera.py", line 244, in _generate_fig
    await self.hass.async_add_executor_job(fig.savefig, self._path, dpi=200)
TypeError: async_add_executor_job() got an unexpected keyword argument 'dpi'

Removing dpi=200 from this function solves the issue for me. Not quite sure why this fails tho.. Cant reproduce it locally with matplotlib.

espenfjo commented 3 years ago

Removing dpi=200 from the call to await self.hass.async_add_executor_job(fig.savefig, self._path, dpi=200) should be safe since fig already have dpi=200 set: fig = plt.figure(figsize=(1200 / 200, 700 / 200), dpi=200).

Letalis commented 3 years ago

@espenfjo thank you for the finding. Much appreciated.

Coffeeman666 commented 3 years ago

Nice finding. Now it works like a charm again. Thanks!