# Entities and events

> The sensors and weather entity each place gets, their attributes, the account device, and the wxalerts_storm_cell, wxalerts_alert and wxalerts_hazard events.

Home Assistant · Reference · https://wxalerts.org/docs/integrations/home-assistant/entities/

Entity ids follow Home Assistant's device plus name convention. A place named
**Home** is the device *WxAlerts Home*, so its entities start with
`wxalerts_home_`. The examples below use `home`; use your own place name.

## Storm cells, per place

| Entity | State |
| - | - |
| `binary_sensor.wxalerts_home_storm_cell_approaching` | `on` while a storm cell threatens the place. Device class `safety`. |
| `sensor.wxalerts_home_storm_cell_eta` | Minutes until the cell arrives. Counts down between updates. Unknown with no storm. |
| `sensor.wxalerts_home_storm_cell_threat` | The threat level as an enum (below). `none` with no storm. |

When several cells threaten one place, the one with the highest threat drives
all three, and the soonest arrival breaks a tie.

### Attributes of `storm_cell_approaching`

| Attribute | Meaning |
| - | - |
| `eta_min` | Minutes to arrival. `0` when the cell has arrived, `null` when it is not moving. |
| `rung`, `rung_label` | The threat level as a number and in words, such as `40` and `Thunderstorm Risk`. |
| `threat` | The same level as the enum value of `storm_cell_threat`. |
| `prob_severe`, `prob_tor`, `prob_hail`, `prob_wind` | Probabilities in percent. |
| `speed_kmh`, `bearing_deg` | How fast and toward which compass bearing the cell is moving. |
| `distance_km` | Distance from the place. |
| `storm_id` | Stable id for the cell while it lives. |
| `episode` | `open`, `escalate` or `update`. |
| `updated_at` | When the server last refreshed the cell. |
| `storm_count` | How many cells threaten the place right now. |
| `feed_age_seconds` | Seconds since the WxAlerts server last reported in. |

### Threat levels

`storm_cell_threat` is one of `none`, `thunderstorm_risk`,
`thunderstorm_detected`, `tornado_risk`, `tornado_risk_high`,
`tornado_detected` or `tornado_confirmed`, plus `wind_outlook`,
`high_wind_detected`, `thunderstorm_outlook` and `tornado_outlook` when the
server sends them.

  If the feed stops reporting for 15 minutes, or reports itself offline, the
  storm cell entities turn `unavailable` rather than claiming the sky is clear.

## NWS alerts, per place

| Entity | State |
| - | - |
| `binary_sensor.wxalerts_home_active_alert` | `on` when any NWS alert is live for the place. Device class `safety`. |
| `sensor.wxalerts_home_highest_severity` | `Extreme`, `Severe`, `Moderate`, `Minor` or `None`. |
| `sensor.wxalerts_home_active_alerts` | The count, with the full list in the `alerts` attribute. |
| `sensor.wxalerts_home_top_alert` | The most urgent alert by name. A warning outranks a watch. |
| `binary_sensor.wxalerts_home_tornado_warning` | One per alert type picked in the options. |

Each entry in the `alerts` attribute of `active_alerts` has `event`,
`event_type`, `severity`, `urgency`, `certainty`, `headline`, `instruction`,
`onset`, `ends` and `vtec`. The per type binary sensors carry the same fields
for their own type, plus `alert_count`. `top_alert` carries `event_type`,
`severity`, `headline`, `instruction`, `onset`, `ends` and `alert_count`.

An alert belongs to a place when the place is inside it. A polygon warning
shows only on the places inside the polygon, so two places in one county no
longer share a warning that covers only one of them. When part of an alert is
cancelled, it leaves the places it releases and stays on the others.

`instruction` is read from the WxAlerts API a moment after the alert arrives.
If that read fails, the alert still shows, with `instruction` empty until its
next update.

A place with no US county (offshore, or outside the US) is no longer left
out. Its alert entities work, and show an alert when one covers the place.

When Home Assistant starts, and after every reconnect, the integration reads
the alerts in force at each place from the API and then follows the live
feed. An alert whose end was never heard is dropped an hour after its end
time.

## Weather, per place

Current conditions come from the observing stations nearest the place.

| Entity | State |
| - | - |
| `weather.wxalerts_home` | Current conditions, a 7 day daily forecast and a 48 hour hourly forecast. Attributes `station`, `station_id`, `distance_km` and `observed_at`. |
| `sensor.wxalerts_home_temperature`, `_dew_point`, `_feels_like`, `_humidity`, `_wind_speed`, `_wind_gust`, `_wind_bearing`, `_pressure`, `_visibility`, `_precipitation_last_hour` | One reading each, with a device class, so Home Assistant shows it in your units and keeps statistics. |
| `sensor.wxalerts_home_condition` | The observed weather in words, with the stable `condition_code` as an attribute. |

The conditions and the forecast are independent: either one missing leaves the
other working. Read the forecast in an automation with the
`weather.get_forecasts` action.

The conditions entities are unavailable when the latest observation is more
than two hours old or missing, and a reading the station did not report is
unknown. A forecast issued more than 24 hours ago is withdrawn.

## Account device

The device named `WxAlerts`:

| Entity | State |
| - | - |
| `sensor.wxalerts_feed_age` | Seconds since the WxAlerts server last reported in. Keeps rising if it goes quiet. |
| `binary_sensor.wxalerts_connected` | The connection to the broker. |

## Map markers

Each live alert with a shape becomes a `geo_location` entity at the centre of
its polygon, with the polygon in the `geometry` attribute. Add a **Map** card
and pick `wxalerts` as a geolocation source to draw them. They disappear when
the alert ends.

## Events

| Event | Fires when | Data |
| - | - | - |
| `wxalerts_storm_cell` | A storm cell episode opens or escalates for a place | `episode` (`open` or `escalate`), `place_id`, `place_name`, `storm_id`, `eta_min`, `rung`, `rung_label`, `threat`, the four probabilities, `speed_kmh`, `bearing_deg`, `distance_km`, `issued_at`, `updated_at` |
| `wxalerts_alert` | A new NWS alert is issued for a place | `place_id`, `place_name`, `event`, `event_type`, `severity`, `headline`, `instruction`, `onset`, `ends` |
| `wxalerts_hazard` | An alert type begins or ends for a place | `place_id`, `place_name`, `event_type`, `event`, `action` (`begin` or `end`), `severity`, `headline`, `ends` |

None of these fire for what is already in effect when Home Assistant starts or
reconnects, so a restart never announces a warning twice. Use the entities when
you also want to catch something that was already live.

## Device triggers

Pick a place device in the automation editor. Every NWS alert type is listed as
*begins* and *ends*, plus **Storm cell approaching** (`storm_cell_open`) and
**Storm cell threat escalates** (`storm_cell_escalate`).
