custom-components / weatheralerts

A sensor that gives you weather alerts from alerts.weather.gov.
MIT License
126 stars 15 forks source link

No card type found on the conditional yaml? #48

Closed cvocvo closed 3 years ago

cvocvo commented 3 years ago

Version of the custom_component Latest version

Describe the bug I installed the yaml package and the latest version of the HACS component, however when I go to add the card YAML for either of the conditional cards listed here: https://github.com/custom-components/weatheralerts/blob/master/documentation/LOVELACE_EXAMPLES.md#examples-yaml-package-required

HomeAssistant gives me an error: “No card type found”

Log EFCDE8DA-2780-4F5B-9C95-2BDF96DB3F0D

Any ideas? Thank you!

jlverhagen commented 3 years ago

Thanks for pointing that out. I'll update the instructions and code. The hyphen/space before card: is only needed if editing the raw lovelace yaml, but not used if editing via the Add Card option in the UI. When adding the card code in the UI, via the Add Card button, and using the Show Code Editor to edit the card code, the code should be formatted like this:

card:
  content: >
    <hr>  {% set alerts = [
      "sensor.weatheralerts_1_alert_1",
      "sensor.weatheralerts_1_alert_2",
      "sensor.weatheralerts_1_alert_3",
      "sensor.weatheralerts_1_alert_4",
      "sensor.weatheralerts_1_alert_5"] %}
    {% for alert in alerts if is_state(alert, 'on') %} {% if 'warning' or
    'severe' in state_attr( alert, 'display_title')|lower() %} <font
    color="red">  {% endif %} <b>{{ state_attr( alert, 'display_title')
    }}</b>  {%- if 'warning' or 'severe' in state_attr( alert,
    'display_title')|lower() -%} </font> {%- endif %} <br>{{ state_attr(
    alert, 'display_message') }} {% if loop.last %} {% else %} <hr> {% endif
    %} {% endfor %}
  title: Weather Alerts
  type: markdown
conditions:
  - entity: sensor.weatheralerts_1_alerts_are_active
    state: 'Yes'
type: conditional

The first line of card code from the instructions:

  - card:

should not have the hyphen or any spaces in it, The indentation of the rest of the lines should be adjusted (by deleting the first four blank spaces at the beginning of each line) to maintain proper formatting.

cvocvo commented 3 years ago

Oh yep that did the trick—thank you for the fast reply!