- Python 98.9%
- Dockerfile 1.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| p2pquake | ||
| LICENSE | ||
| README.md | ||
| renovate.json | ||
| repository.yaml | ||
P2Pquake Bridge (Home Assistant add-on)
Bridges P2P地震情報 (P2Pquake) Earthquake Early Warning (緊急地震速報・警報, code 556) and Tsunami Warnings (津波予報, code 552) from the v2 WebSocket to your MQTT broker, with Home Assistant MQTT discovery.
It connects to the P2Pquake WebSocket, filters earthquake and tsunami messages,
de-duplicates them by id, and republishes to MQTT. Reconnection (including
the test endpoint's 10-minute forced disconnect) and broker credential discovery are
handled for you.
Not a life-safety system. P2Pquake states the content and delivery quality are unguaranteed and run without redundancy — an outage means no delivery and no catch-up. Keep your phone's cell-broadcast alert as the authoritative source; treat this as a convenience/automation layer.
Install
- In Home Assistant, go to Settings → Add-ons → Add-on Store.
- Open the ⋮ menu (top-right) → Repositories.
- Add
https://git.tiuxo.com/brian/ha-p2pquakeand click Add. - Close the dialog — P2Pquake Bridge now appears in the store.
- Open it → Install → Start. Enable Watchdog and Start on boot on the add-on's info page.
No MQTT settings to enter: with services: mqtt:need the add-on pulls the
broker host/credentials from the Supervisor MQTT service — the same Mosquitto
your Zigbee2MQTT already uses.
Building locally
To build the image yourself instead of pulling from the registry, clone this
repo into /addons/ on your HA host, remove the image: line from
p2pquake/config.yaml, and install from the local add-ons section.
Options
| Option | Default | Meaning |
|---|---|---|
test_mode |
false |
Use the P2Pquake test WebSocket and publish synthetic test events on startup so you can verify the whole pipeline without waiting for a real quake. Set back to false for live data. |
base_topic |
p2pquake |
MQTT topic prefix. |
earthquake_regions |
[] (all) |
List of 府県予報区 regions to monitor for earthquake warnings. Only warnings that predict shaking in at least one listed region are published. An empty list means all regions (nationwide). Cancellations always pass through. |
earthquake_expiry |
600 |
Seconds after which the earthquake sensor resets to 待機中 (standing by). Set to 0 to keep the last warning indefinitely. |
tsunami_regions |
[] (all) |
List of 津波予報区 regions to monitor for tsunami warnings. Only warnings that include at least one listed region are published. An empty list means all regions (nationwide). Cancellations always pass through. |
tsunami_expiry |
3600 |
Seconds after which the tsunami sensor resets to 待機中. Set to 0 to keep the last warning indefinitely. |
verbose |
false |
Debug logging. |
What it creates
-
sensor.p2pquake_earthquake— Earthquake Early Warning sensor. State is待機中(standing by) when idle, or a summary string during/after a warning. Attributes includemax_scale,max_intensity,hypocenter,magnitude,cancelled,test, per-area predictions, andraw. Resets to待機中afterearthquake_expiryseconds. -
sensor.p2pquake_tsunami— Tsunami Warning sensor. State is待機中when idle, or a summary string during a tsunami advisory. Attributes includegrade,grade_label,cancelled, per-area details (grade, arrival time, max height), andraw. Resets to待機中aftertsunami_expiryseconds.
MQTT topics
Earthquake:
p2pquake/earthquake— non-retained, one message per earthquake report. Trigger automations here.p2pquake/earthquake/last— retained, drives the earthquake dashboard sensor.
Tsunami:
p2pquake/tsunami— non-retained, one message per tsunami report. Trigger automations here.p2pquake/tsunami/last— retained, drives the tsunami dashboard sensor.
Shared:
p2pquake/status— retainedonline/offlineavailability (LWT).
Reference values
Earthquake intensity (max_scale / scale_to) uses JMA's ×10 convention:
45 = 震度5弱, 50 = 5強, 55 = 6弱, 60 = 6強, 70 = 7.
Tsunami grade:
| API value | Japanese | English |
|---|---|---|
MajorWarning |
大津波警報 | Major tsunami warning |
Warning |
津波警報 | Tsunami warning |
Watch |
津波注意報 | Tsunami advisory |
Example automations
Earthquake — strong shaking near me
With earthquake_regions configured in the add-on options, every warning that
reaches MQTT already affects your area:
alias: Earthquake – strong shaking near me
mode: queued
trigger:
- platform: mqtt
topic: p2pquake/earthquake
condition:
- condition: template
value_template: >-
{% set p = trigger.payload_json %}
{{ not p.cancelled and (p.max_scale | int(-1)) >= 45 }}
action:
- service: light.turn_on
target:
entity_id: light.living_room
Adjust the >= 45 threshold to control the minimum intensity.
If you leave earthquake_regions empty (nationwide) you can filter by prefecture in the
condition instead:
{{ not p.cancelled
and (p.max_scale | int(-1)) >= 45
and '東京' in (p.areas | map(attribute='pref') | join('|')) }}
Prefecture strings use the 府県予報区 pref value from the API (e.g. 東京,
北海道道南, 宮城) — not the full 都道府県 name.
Tsunami — any warning or advisory
alias: Tsunami warning
mode: queued
trigger:
- platform: mqtt
topic: p2pquake/tsunami
condition:
- condition: template
value_template: >-
{% set p = trigger.payload_json %}
{{ not p.cancelled }}
action:
- service: notify.notify
data:
title: "Tsunami {{ p.grade_label }}"
message: "{{ trigger.payload_json.summary }}"
To filter by severity, check grade: MajorWarning, Warning, or Watch.
Verifying
Set test_mode: true and start the add-on. On startup it publishes synthetic
test events for both earthquake and tsunami, populating the sensors immediately.
The test WebSocket also replays real 2023 data (earthquake warnings, quake info,
and tsunami warnings in sequence, ~30 s apart), though code 556 events are
sparse in the replay. Confirm your automations fire, then set test_mode: false
and restart for live data.