Skip to content

amargo/met_alerts_hu

 
 

Repository files navigation

hacs_badge

Buy me a coffee

Home Assistant custom component for meteo alerts in Hungary

This custom component gathers regular and special meteo alerts from met.hu (valid only for Hungary).

The state of the sensor will be the alert level of most dominant alert. The name of the alert with highest alert level will also be added into a dedicated attribute.

The sensor will also report in attributes the values of all other meteo alerts, if there are any.

Installation

The easiest way to install it is through HACS (Home Assistant Community Store), search for MET Alerts Hungary in the Integrations.

Configuration:

Define sensor with the following configuration parameters:


Name Optional Default Description
name Y met_alerts_hu name of the sensor
region_id Y 101 (Budapest) region identifier
county_id Y 13 (Pest county) county identifier

region_id can found as kt value in the URL when hovering on the region at MET Vészjelzés.

county_id can found as serial value of the county when counties are sorted alphabetically (1: reserved, 2: Baranya;...; 20: Zala).

Example

platform: met_alerts_hu
name: 'MET alerts'

Lovelace UI

If you want to show the dominant alert use the following:

type: conditional
conditions:
  - entity: sensor.met_alerts
    state_not: '0'
card:
  type: custom:button-card
  size: 30px
  styles:
    label:
      - font-size: 90%
    card:
      - height: 80px
    icon:
      - color: >
          [[[
            var met_level = states['sensor.met_alerts'].state;
            if ( met_level == 0 ) {
              return "green";
            } else if ( met_level == 1 ) {
              return "var(--paper-item-icon-active-color)";
            } else if ( met_level == 2 ) {
              return "orange";
            } else if ( met_level == 3 ) {
              return "red";
            }
            return "black";
          ]]]
  label: >
    [[[
      var met_alert = states['sensor.met_alerts'].attributes.dominant_met_alert;
      return met_alert;
    ]]]
  show_label: true
  show_name: false
  entity: sensor.met_alerts
  color_type: icon

Most dominant meteo alert example

If you want to show all alerts use the following (please note that this height of the card will allow only three alerts to be shown):

type: conditional
conditions:
  - entity: sensor.met_alerts
    state_not: '0'
card:
  type: custom:button-card
  size: 30px
  styles:
    label:
      - font-size: 90%
    card:
      - height: 80px
  label: >
    [[[
      var label = ""
      var icolor = "black"
      var met_alerts = states['sensor.met_alerts'].attributes.alerts;
      for (var k=0; k < states['sensor.met_alerts'].attributes.nr_of_alerts; k++) {
        if ( met_alerts[k].level == 1 ) {
          icolor = "var(--paper-item-icon-active-color)";
        } else if ( met_alerts[k].level == 2 ) {
          icolor = "orange";
        } else if ( met_alerts[k].level == 3 ) {
          icolor = "red";
        }
        label += `<ha-icon icon="` + met_alerts[k].icon +
                 `" style="width: 28px; height: 28px; color:` + icolor + `;"></ha-icon>&nbsp;` +
                 (states['sensor.met_alerts'].attributes.nr_of_alerts == 1 ? `<br>` : ``) +
                 `<span>` + met_alerts[k].type + `</span><br>`;
      }
      return label;
    ]]]
    show_label: true
    show_name: false
    show_icon: false
    entity: sensor.met_alerts
    color_type: icon

All meteo alerts example

Thanks

Thanks to all the people who have contributed!

contributors

About

Meteo alerts for Hungary

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%