Skip to content

Commit

Permalink
Release 1.3.3
Browse files Browse the repository at this point in the history
New: When websocket is unavailable, get data from HTTP(temporary).
New: Add Protocol and Region in sensor attribute.
Fixes: Free plan config entry had incorrect name.
Changed: RTS Notification attributes content.
Changed: RTS Notification device class.
Changed: Github repository information.

* Update README.
  • Loading branch information
J1A-T13N committed Aug 16, 2024
1 parent 9b2dc87 commit f227ad8
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 116 deletions.
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ English | [繁體中文](README_zhHant.md)<br>
![config_flow_image](https://github.com/J1A-T13N/ha-trem/assets/29163857/a6f4cc49-0521-4f27-a894-9fb1273be1cf)
![simulator_earthquake_demo](https://github.com/J1A-T13N/ha-trem/assets/29163857/b62dab7a-2935-4477-8297-f7e275df0a81)


<hr>
<br>

Expand All @@ -31,6 +30,16 @@ English | [繁體中文](README_zhHant.md)<br>
>The source of earthquake early warning is provided by ExpTech Studio and is for reference only.<br>
>The actual results are subject to the content published by [CWA](https://scweb.cwa.gov.tw/en-US).
<hr>
<br>


## Feature

- [x] Isoseismal map image (can also be saved as file).
- [x] Simulator earthquake service.
- [x] RTS Notification (Exptech VIP Only).
- [x] Tsunami Notification (Exptech VIP Only).

<hr>
<br>
Expand Down Expand Up @@ -93,12 +102,16 @@ English | [繁體中文](README_zhHant.md)<br>
- If the integration didn't show up in the list please REFRESH the page
- If the integration is still not in the list, you need to clear the browser cache.

*A Region code can be search [here](https://github.com/ExpTechTW/API/blob/master/resource/region.json).*<br>
<hr>
<br>


## API Node
## Data Source
- [x] HTTPS API (or use your self-server)
- [x] Websocket. (Exptech VIP Only)

### HTTPS API
| Node | Description |
| :----------------: | :-----------------------------------------: |
| tainan_cache_limit | The number of requests is limited |
Expand All @@ -112,20 +125,24 @@ English | [繁體中文](README_zhHant.md)<br>
| pingtung | The data is real-time but the load is high |
| pingtung_2 | The data is real-time but the load is high |

### Websocket
**Exptech VIP Only**
You can goto [https://exptech.com.tw/pricing](https://exptech.com.tw/pricing) to subscribe.

*An API server can be monitored [here](https://status.exptech.dev/).*<br>


## Known issues

> :tada: No issues found yet
1. Not support Home Assistant 2024.8 and higher yet.

<hr>
<br>


## Contribution

- ExpTech Studio `EEW Source`
- ExpTech Studio `Data Source`
- watermelon1024 `Contributor`
- kukuxx `Test Partner`

Expand All @@ -135,20 +152,6 @@ English | [繁體中文](README_zhHant.md)<br>
<br>


## Future

- [x] Integration: Convert components from sensor to platform.
- [x] Integration: Add isoseismal map image.
- [x] Integration Service: Simulator earthquake.
- [x] Integration Service: Save as image.
- [x] Integration Service: Reload entity.
- [x] ExptechTW Features: Earthquake early warning Source from WebSocket. (Exptech VIP Only)
- [ ] ExptechTW Features: TREM-Net EEW、RTS...etc. (Exptech VIP Only)

<hr>
<br>


## Donate

| Buy me a coffee | LINE Bank | JKao Pay |
Expand All @@ -162,6 +165,8 @@ English | [繁體中文](README_zhHant.md)<br>
## License
AGPL-3.0 license

**2024-08-15 Agreement reached with ExpTech Studio.**


[releases-shield]: https://img.shields.io/github/release/gaojiafamily/ha-trem.svg?style=for-the-badge
[releases]: https://github.com/gaojiafamily/ha-trem/releases
Expand Down
48 changes: 30 additions & 18 deletions README_zhHant.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
<br>


## Feature

- [x] Isoseismal map image (can also be saved as file).
- [x] Simulator earthquake service.
- [x] RTS Notification (Exptech VIP Only).
- [x] Tsunami Notification (Exptech VIP Only).

<hr>
<br>


## 測試結果

| 環境 | Home Assistant OS | Home Assistant Core | Home Assistant Supervisor |
Expand Down Expand Up @@ -84,14 +95,23 @@


## 設定

**請跟隨設定流程新增.**

1. 配置 > 整合 > 新增整合 > Taiwan Real-time Earthquake Monitoring
- 如果整合未顯示在清單中,請重新整理頁面
- 如果整合仍然不在清單中,您需要清除瀏覽器快取。

*地區代碼可以[到這](https://github.com/ExpTechTW/API/blob/master/resource/region.json) 查詢*<br>
<hr>
<br>


## API 節點
## 資料來源
- [x] HTTPS API (or use your self-server)
- [x] Websocket. (Exptech VIP Only)

### HTTPS API
| Node | Description |
| :----------------: | :--------------: |
| tainan_cache_limit | 請求次數遭到限制  |
Expand All @@ -105,12 +125,16 @@
| pingtung | 即時資料,但延遲高 |
| pingtung_2 | 即時資料,但延遲高 |

*An API server can be monitored [here](https://status.exptech.dev/).*<br>
### Websocket
**需要Exptech VIP**
您可以到 [https://exptech.com.tw/pricing](https://exptech.com.tw/pricing) 訂閱VIP

*伺服器狀態可 [在這](https://status.exptech.dev/) 查看*<br>


## 已知問題

> :tada: 暫時沒有發現問題
1. 暫不支援 2024.8 及更高版本的 Home Assistant

<hr>
<br>
Expand All @@ -128,20 +152,6 @@
<br>


## 未來功能

- [x] Integration 相關: Convert components from sensor to platform.
- [x] Integration 功能: 新增等震圖.
- [x] Integration 功能: 模擬地震 (用於測試自動化)。
- [x] Integration 服務: 另存等震圖.
- [x] Integration 服務: 重新載入整合.
- [x] ExptechTW 訂閱功能: 使用WebSocket作為地震速報來源,減少流量及延遲。 (Exptech VIP 資格)
- [ ] ExptechTW 訂閱功能: TREM-Net EEW、RTS...等。 (Exptech VIP 資格)

<hr>
<br>


## 贊助

| Buy me a coffee | LINE Bank | JKao Pay |
Expand All @@ -153,7 +163,9 @@


## 授權
AGPL-3.0 license
AGPL-3.0 license.

**2024-08-15 Agreement reached with ExpTech Studio.**


[releases-shield]: https://img.shields.io/github/release/gaojiafamily/ha-trem.svg?style=for-the-badge
Expand Down
1 change: 0 additions & 1 deletion custom_components/trem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
CLIENT_NAME,
CONF_NODE,
CONF_PASS,
DEFAULT_NAME,
DOMAIN,
HTTPS_API_COORDINATOR_UPDATE_INTERVAL,
MIN_HA_MAJ_VER,
Expand Down
25 changes: 13 additions & 12 deletions custom_components/trem/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import logging
from typing import Any

from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, CONF_EMAIL
from homeassistant.core import HomeAssistant, callback
Expand All @@ -18,7 +21,6 @@
ATTRIBUTION,
DOMAIN,
MANUFACTURER,
MONITOR_ICON,
TREM_COORDINATOR,
TREM_NAME,
)
Expand Down Expand Up @@ -82,14 +84,13 @@ def __init__(
def update(self):
"""Schedule a custom update via the common entity update service."""

self._attr_value = {}
self._attributes[ATTR_NODE] = self._coordinator.station

rtsData: dict = self._coordinator.rtsData
if "int" in rtsData:
rts: list = rtsData["int"]
if len(rts) == 0:
self._attr_value = {}
else:
if len(rts) > 0:
for k in rts:
self._attr_value[k["code"]] = k["i"]

Expand All @@ -116,23 +117,23 @@ def available(self):
return True

@property
def state(self) -> bool:
def is_on(self) -> bool:
"""Return the state of the sensor."""

return self._state

@property
def icon(self) -> str:
"""Icon to use in the frontend, if any."""

return MONITOR_ICON

@property
def unit_of_measurement(self):
"""Return the unit of measurement."""

return None

@property
def device_class(self):
"""Return the device class."""

return BinarySensorDeviceClass.VIBRATION

@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return extra attributes."""
Expand Down
6 changes: 0 additions & 6 deletions custom_components/trem/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def __init__(self) -> None:
self._node: str | None = None
self._email: str | None = None
self._password: str | None = None
self._token: str | None = None
self._preserve_data: bool | None = None
self._draw_map: bool | None = None

Expand Down Expand Up @@ -291,7 +290,6 @@ async def async_step_cloud(
self._email = user_input.get(CONF_EMAIL, "")
self._password = user_input.get(CONF_PASSWORD, "")
self._region = user_input.get(CONF_REGION, None)
# self._token = user_input.get(CONF_TOKEN, "")
self._preserve_data = user_input.get(CONF_PRESERVE_DATA, False)
self._draw_map = user_input.get(CONF_DRAW_MAP, False)

Expand All @@ -300,7 +298,6 @@ async def async_step_cloud(
vol.Required(CONF_EMAIL, default=self._email): str,
vol.Required(CONF_PASSWORD, default=self._password): str,
vol.Required(CONF_REGION, default=self._region): int,
# vol.Optional(CONF_TOKEN, default=self._token): str,
vol.Optional(CONF_PRESERVE_DATA, default=self._preserve_data): bool,
vol.Optional(CONF_DRAW_MAP, default=self._draw_map): bool,
}
Expand All @@ -324,7 +321,6 @@ def __init__(self, config_entry: ConfigEntry) -> None:
self._node: str | None = None
self._email: str | None = None
self._password: str | None = None
self._token: str | None = None
self._preserve_data: bool | None = None
self._draw_map: bool | None = None

Expand Down Expand Up @@ -416,15 +412,13 @@ async def async_step_cloud(
self._region = self._config.options.get(CONF_REGION, None)
self._email = self._config.options.get(CONF_EMAIL, "")
self._password = self._config.options.get(CONF_PASSWORD, "")
self._token = self._config.options.get(CONF_TOKEN, "")
self._preserve_data = self._config.options.get(CONF_PRESERVE_DATA, False)
self._draw_map = self._config.options.get(CONF_DRAW_MAP, False)

data_schema = vol.Schema(
{
vol.Required(CONF_EMAIL, default=self._email): str,
vol.Optional(CONF_PASSWORD, default=self._password): str,
# vol.Optional(CONF_TOKEN, default=self._token): str,
vol.Optional(CONF_PRESERVE_DATA, default=self._preserve_data): bool,
vol.Optional(CONF_DRAW_MAP, default=self._draw_map): bool,
}
Expand Down
15 changes: 5 additions & 10 deletions custom_components/trem/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
# Initialize
DEFAULT_NAME = "TREM"
DEFAULT_ICON = "mdi:checkbox-blank-outline"
MONITOR_ICON = "mdi:monitor-eye"
TSUNAMI_ICON = "mdi:tsunami"
DOMAIN = "trem"
PLATFORMS = ["binary_sensor", "image", "sensor"]

# Proj
CLIENT_NAME = "TREM-HA"
PROJECT_URL = "https://github.com/J1A-T13N/ha-trem/"
PROJECT_URL = "https://github.com/gaojiafamily/ha-trem/"
ISSUE_URL = f"{PROJECT_URL}issues"

# Version
MIN_HA_MAJ_VER = 2024
MIN_HA_MIN_VER = 3
__min_ha_version__ = f"{MIN_HA_MAJ_VER}.{MIN_HA_MIN_VER}.0"
__version__ = "1.3.2"
__version__ = "1.3.3"

# Earthquake Icon
EARTHQUAKE_ICON = {
Expand Down Expand Up @@ -50,6 +49,7 @@
ATTR_EST = "estimate"
ATTR_CODE = "region"
ATTR_NODE = "API_Node"
ATTR_PROTOCOL = "protocol"
ATTR_EQDATA = "earthquake_data"
EARTHQUAKE_ATTR = [
ATTR_ID,
Expand All @@ -62,7 +62,6 @@
ATTR_TIME,
ATTR_INT,
ATTR_EST,
ATTR_CODE,
]
TSUNAMI_ATTR = [
ATTR_ID,
Expand All @@ -77,18 +76,14 @@
CONF_PRESERVE_DATA = "preserve_data"

# Coordinator
DPIP_COORDINATOR = "dpip_coordinator"
TREM_COORDINATOR = "trem_coordinator"
TREM_NAME = "trem_name"
UPDATE_LISTENER = "update_listener"
HTTPS_API_COORDINATOR_UPDATE_INTERVAL = timedelta(seconds=5)
WEBSOCKET_COORDINATOR_UPDATE_INTERVAL = timedelta(seconds=1)
DPIP_COORDINATOR_UPDATE_INTERVAL = timedelta(seconds=60)

# REST
HA_USER_AGENT = (
"TREM custom integration for Home Assistant (https://github.com/j1a-t13n/ha-trem)"
)
HA_USER_AGENT = "TREM custom integration for Home Assistant (https://github.com/gaojiafamily/ha-trem)"
BASE_URLS = {
"tainan_cache_limit": "https://api-1.exptech.com.tw",
"tainan_cache": "https://api-1.exptech.dev",
Expand Down Expand Up @@ -117,7 +112,7 @@
# STRINGS
CUSTOMIZE_PLAN = "Customize (Free Plan)"
FREE_PLAN = "Http(s) API (Free Plan)"
SUBSCRIBE_PLAN = "WebSocket (Subscribe Plan)"
SUBSCRIBE_PLAN = "Websocket (Subscribe Plan)"

WS_MSG_TOO_BIG = (
f"Please consider increasing message size with `{DEFAULT_MAX_MSG_SIZE}`."
Expand Down
2 changes: 1 addition & 1 deletion custom_components/trem/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from homeassistant.components.image import ImageEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, CONF_EMAIL, CONF_REGION
from homeassistant.const import ATTR_ATTRIBUTION, CONF_REGION
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.util import dt as dt_util
Expand Down
Loading

0 comments on commit f227ad8

Please sign in to comment.