home-assistant / home-assistant.io

:blue_book: Home Assistant User documentation
https://www.home-assistant.io
Other
4.56k stars 7.09k forks source link

Add example visualization for lovelace #29370

Open Tobboss opened 8 months ago

Tobboss commented 8 months ago

Feedback

While most of the integration documentation do not include how to visualize because they add entities of known and self explainable domains, this one is just creating a binary sensor and needs advanced knowledge to create a functional element.

My guess is one would need a Markdown Card or custom template card like Mushroom Template Card and dig into templating?

I would love a copy/paste example to start with, because getting started is a steep learning here for the average user compared to most other core integrations.

URL

https://www.home-assistant.io/integrations/dwd_weather_warnings/

Version

2023.10.3

Additional information

No response

home-assistant[bot] commented 8 months ago

Hey there @runningman84, @stephan192, @andarotajo, mind taking a look at this feedback as it has been labeled with an integration (dwd_weather_warnings) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dwd_weather_warnings` can trigger bot actions by commenting: - `@home-assistant close` Closes the feedback. - `@home-assistant rename Awesome new title` Renames the feedback. - `@home-assistant reopen` Reopen the feedback. - `@home-assistant unassign dwd_weather_warnings` Removes the current integration label and assignees on the feedback, add the integration domain after the command.
andarotajo commented 8 months ago

I'm not sure, if such information is "wanted" in the integration documentation, someone else would have to answer that part. That said, I agree that the sensors are not really "Lovelace friendly". I'm sure it's possible to get the relevant information using templated sensors, e.g. using a helper.

I've searched for something usable in HACS and found https://github.com/MrBartusek/MeteoalarmCard. You could try that for a simpler solution, it seems to support the core DWD integration.

Tobboss commented 8 months ago

Thank you, I tried Meteoalarm but it's not working. My entities are not recognized as dwd entities (HA in German). Will have to file an issue there. I know it's uncommon to document more than just the integration in the wiki. But here I am stuck as never before and maybe it's suitable to give hints or a little best practice on how to get started with this integration in a stock HA way.

andarotajo commented 8 months ago

Ah my HA is in English, maybe thats why it worked for me in my test just now. My configuration for reference:

type: custom:meteoalarm-card
entities:
  - entity: sensor.test_current_warning_level
  - entity: sensor.test_advance_warning_level
integration: dwd
disable_swiper: false
override_headline: false
hide_when_no_warning: false
hide_caption: false
scaling_mode: headline_and_scale
Tobboss commented 8 months ago

Yes I will check why meteo is not working. I just used the proposed demo config and also tried with the GUI. Nevertheless, main goal would be not to be dependend on a HACS frontend element when using a core integration. So maybe someone comes up with a head start for simple usage or everything docu related stays as it is :)

andarotajo commented 8 months ago

Due to the nature of the integration, i.e. dynamically added attributes for the warning data, it's not easy to process the data in a satisfying way for the frontend. Personally, I'm using Appdaemon to send myself notifications, if any relevant weather warnings appear (like hail) because using Python is just way easier for this sort of stuff.

That said, I've played around a bit with templates and can offer a snippet you can experiment with

{% set warnings = int(states("sensor.test_current_warning_level", 0)) %}
{% if warnings == 1 %}
  {% set data = state_attr("sensor.test_current_warning_level", "warning_1") %}
  {{ data.event }}
{% endif %}

I'm not really good myself, though I can recommend going down this rabbit hole as you can do useful stuff with templating :) This snippet checks the sensor for the warning count and reads the event attribute for the first warning. You could do it like this for every interesting attribute and create template sensors like sensor.test_current_warning_1_event.

You could also concatenate multiple strings by replacing {{ data.event }} with {{ data.event }}, {{ data.event_code }}. But this would just be for 1 warning. The integration creates a block of information for each warning, so you'd have to create x sensors in case there's more than 1 warning.

Hope that helps a bit

stephan192 commented 7 months ago

@Tobboss there is thread about a markdown card existing in the community forum. https://community.home-assistant.io/t/dwd-warnwetter-markdown-card/180274/27

Tobboss commented 7 months ago

This is great. Will have to do some adaptions since entity names changed, but this is a good start. I will try to adapt the knowledge to a custom button card for using icons. Thanks for the hint