FL550 / dwd_weather

Deutscher Wetterdienst integration for Home-Assistant
MIT License
197 stars 13 forks source link

Mark the home position on the weather map #151

Closed jf-64 closed 4 weeks ago

jf-64 commented 2 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

It would be nice to see the position of the (in HA) saved Home on the weather map pictures.

Describe the solution you'd like A clear and concise description of what you want to happen.

Currently a mark at the center of the shown weather map can optionally be switched on/off in the configuration. It would be useful, if an additional switch in the configuration (e.g.: Should the Home position be marked on the map? / Soll die Heim-Position auf der Karte markiert werden?) would do the same with the saved Home position.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

If someone is selecting a map not containing the Home position and this mark is switched on, then: Options:

  1. (preferred) Nothing shall happen.
  2. If you have time for that: An arrow at the border of the picture could show the relative direction to the saved Home position.

Additional context Add any other context or screenshots about the feature request here.

n/a

FL550 commented 2 months ago

I'll like the idea! I'll implement it when I have time the next days.

FL550 commented 1 month ago

The biggest part is already done, I only have to make this configureable in HA before I can publish this. Will be probably ready on friday. Cheers

jf-64 commented 1 month ago

Cool! Thank you!

FL550 commented 1 month ago

@jf-64 It took me a while longer as I was quite busy the last days. I just released this, please let me know if it fit your needs or if I should improve something. Best regards

armin-gh commented 1 month ago

Not jf-64, but while this issue is still open: throws an exception when selecting "Configure" on an existing map ( works for newly created map). Core Installation Python venv, v2.1.14 installed, Service restarted after installation. Sound like it is looking for an configuration item not existing when the map was created with an older version?

Oct 08 19:55:25 smarthome hass[2500]: 2024-10-08 19:55:25.294 ERROR (MainThread) [aiohttp.server] Error handling request
Oct 08 19:55:25 smarthome hass[2500]: Traceback (most recent call last):
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
Oct 08 19:55:25 smarthome hass[2500]:     resp = await request_handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/ban.py", line 85, in ban_middleware
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/auth.py", line 242, in auth_middleware
Oct 08 19:55:25 smarthome hass[2500]:     return await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/headers.py", line 32, in headers_middleware
Oct 08 19:55:25 smarthome hass[2500]:     response = await handler(request)
Oct 08 19:55:25 smarthome hass[2500]:                ^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/helpers/http.py", line 73, in handle
Oct 08 19:55:25 smarthome hass[2500]:     result = await handler(request, **request.match_info)
Oct 08 19:55:25 smarthome hass[2500]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/decorators.py", line 81, in with_admin
Oct 08 19:55:25 smarthome hass[2500]:     return await func(self, request, *args, **kwargs)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/config/config_entries.py", line 262, in post
Oct 08 19:55:25 smarthome hass[2500]:     return await super().post(request)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/components/http/data_validator.py", line 74, in wrapper
Oct 08 19:55:25 smarthome hass[2500]:     return await method(view, request, data, *args, **kwargs)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/helpers/data_entry_flow.py", line 77, in post
Oct 08 19:55:25 smarthome hass[2500]:     return await self._post_impl(request, data)
Oct 08 19:55:25 smarthome hass[2500]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
Oct 08 19:55:25 smarthome hass[2500]:     result = await self._flow_mgr.async_init(
Oct 08 19:55:25 smarthome hass[2500]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 345, in async_init
Oct 08 19:55:25 smarthome hass[2500]:     result = await self._async_handle_step(flow, flow.init_step, data)
Oct 08 19:55:25 smarthome hass[2500]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/srv/homeassistant312/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
Oct 08 19:55:25 smarthome hass[2500]:     result: _FlowResultT = await getattr(flow, method)(user_input)
Oct 08 19:55:25 smarthome hass[2500]:                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]:   File "/home/homeassistant/.homeassistant/custom_components/dwd_weather/config_flow.py", line 683, in async_step_init
Oct 08 19:55:25 smarthome hass[2500]:     default=self.config_entry.data[CONF_MAP_HOMEMARKER_SHAPE],
Oct 08 19:55:25 smarthome hass[2500]:             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 08 19:55:25 smarthome hass[2500]: KeyError: 'map_homemarker_shape'

thanks Armin

FL550 commented 1 month ago

Ah, I missed this one. I'll fix this tomorrow. Thanks for reporting and sorry for the inconvenience.

FL550 commented 1 month ago

This should be fixed now. Version is released again

jf-64 commented 1 month ago

First of all, I like the realization with the possibility of the selections for color, size and shape for the newly inserted mark.

My LogViewer showed at the beginning few warnings, but it is not coming any more: image

I would suggest few optimizations for some of the next releases, s. the German version here: image

  1. The naming of the labels is not consequent (s. the yellow and red marks).
  2. The font size and color of the "red labels" is not consequent: 1st and 3rd vs. 2nd.
  3. The position of the "red labels" is not consequent, s. the green lines.
  4. There is no reason for those "red options" to be enabled (or be visible), when the "yellow" one is in OFF state.
belenon commented 1 month ago

Hi, I really like this feature, thanks for that!

I would like to mention an issue I ran into: After reconfiguring the radar and disabling the home marker, I get the following error and the radar image does not show.

2024-10-12 21:36:27.411 INFO (MainThread) [homeassistant.components.camera] Setting up dwd_weather.camera
2024-10-12 21:36:33.112 ERROR (MainThread) [custom_components.dwd_weather] Unexpected error fetching DWD Map Coordinator data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dwd_weather/connector.py", line 713, in async_update
    return await self._hass.async_add_executor_job(self._update)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dwd_weather/connector.py", line 717, in _update
    self._update_loop()
  File "/config/custom_components/dwd_weather/connector.py", line 828, in _update_loop
    self._images = maploop.get_images()
                   ^^^^^^^
UnboundLocalError: cannot access local variable 'maploop' where it is not associated with a value

After reintorducing the home marker, it works again. So I'm stuck using the marker for now, which prevents me from hackily using the radar image to predict rain by checking pixels via pyscript.

FL550 commented 1 month ago

Thank you for your response, I'm happy you like it. Regarding your suggestions:

  1. The naming of the labels is not consequent (s. the yellow and red marks).

You are absolutely right, I'll change them to be the same.

  1. The font size and color of the "red labels" is not consequent: 1st and 3rd vs. 2nd.
  2. The position of the "red labels" is not consequent, s. the green lines.

This is unfortunately nothing I can change. The display of the configuration layout is completely handled by HA, I only provide the required configuration options for the relevant step. I am unable to modify the UI there :( If I'm wrong and there is a way to modify this, I would be very happy if someone provides me info on this.

  1. There is no reason for those "red options" to be enabled (or be visible), when the "yellow" one is in OFF state.

This is also something I have thought about, but focused on releasing a working version first. I'll change this.

FL550 commented 1 month ago

@belenon

I would like to mention an issue I ran into: After reconfiguring the radar and disabling the home marker, I get the following error and the radar image does not show.

Nice bug you have found! It was an indentation error on the configuration checking. This is now fixed.

After reintorducing the home marker, it works again. So I'm stuck using the marker for now, which prevents me from hackily using the radar image to predict rain by checking pixels via pyscript.

I always think about this, but until now I was not able to find a solution which is robust enough to actually implement it. If you are willing to share your implementation and further discuss this, please open a new issue with this. I would be very happy to implement this into the integration.