Skip to content

Commit

Permalink
feat: device changed notify logical refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
topsworld committed Dec 24, 2024
1 parent aa0400e commit 97e343e
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 40 deletions.
26 changes: 17 additions & 9 deletions custom_components/xiaomi_home/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class XiaomiMihomeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
_area_name_rule: str
_action_debug: bool
_hide_non_standard_entities: bool
_display_devices_changed_notify: bool
_display_devices_changed_notify: list[str]

_auth_info: dict
_nick_name: str
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(self) -> None:
self._area_name_rule = self.DEFAULT_AREA_NAME_RULE
self._action_debug = False
self._hide_non_standard_entities = False
self._display_devices_changed_notify = True
self._display_devices_changed_notify = ['add', 'del', 'offline']
self._auth_info = {}
self._nick_name = DEFAULT_NICK_NAME
self._home_selected = {}
Expand Down Expand Up @@ -614,7 +614,8 @@ async def async_step_advanced_options(
vol.Required(
'display_devices_changed_notify',
default=self._display_devices_changed_notify # type: ignore
): bool,
): cv.multi_select(
self._miot_i18n.translate(key='config.device_state')),
}),
last_step=False,
)
Expand Down Expand Up @@ -814,7 +815,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
_home_selected_list: list
_action_debug: bool
_hide_non_standard_entities: bool
_display_devs_notify: bool
_display_devs_notify: list[str]

_oauth_redirect_url_full: str
_auth_info: dict
Expand Down Expand Up @@ -861,7 +862,7 @@ def __init__(self, config_entry: config_entries.ConfigEntry):
self._hide_non_standard_entities = self._entry_data.get(
'hide_non_standard_entities', False)
self._display_devs_notify = self._entry_data.get(
'display_devices_changed_notify', True)
'display_devices_changed_notify', ['add', 'del', 'offline'])
self._home_selected_list = list(
self._entry_data['home_selected'].keys())

Expand Down Expand Up @@ -1127,7 +1128,8 @@ async def async_step_config_options(self, user_input=None):
vol.Required(
'display_devices_changed_notify',
default=self._display_devs_notify # type: ignore
): bool,
): cv.multi_select(
self._miot_i18n.translate('config.device_state')),
vol.Required(
'update_trans_rules',
default=self._update_trans_rules # type: ignore
Expand Down Expand Up @@ -1545,6 +1547,8 @@ async def async_step_config_confirm(self, user_input=None):
key='config.option_status.enable')
disable_text = self._miot_i18n.translate(
key='config.option_status.disable')
trans_devs_display: dict = self._miot_i18n.translate(
key='config.device_state')
return self.async_show_form(
step_id='config_confirm',
data_schema=vol.Schema({
Expand All @@ -1566,9 +1570,13 @@ async def async_step_config_confirm(self, user_input=None):
'hide_non_standard_entities': (
enable_text if self._hide_non_standard_entities_new
else disable_text),
'display_devices_changed_notify': (
enable_text if self._display_devs_notify
else disable_text)
'display_devices_changed_notify': (' '.join(
trans_devs_display[key]
for key in self._display_devs_notify
if key in trans_devs_display)
if self._display_devs_notify
else self._miot_i18n.translate(
key='config.other.no_display'))
}, # type: ignore
errors={'base': 'not_confirm'} if user_input else {},
last_step=True
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "Geräte",
"found_central_gateway": ", lokales zentrales Gateway gefunden",
"without_room": "Kein Raum zugewiesen"
"without_room": "Kein Raum zugewiesen",
"no_display": "nicht anzeigen"
},
"control_mode": {
"auto": "automatisch",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "aktivieren",
"disable": "deaktivieren"
},
"device_state": {
"add": "hinzufügen",
"del": "nicht verfügbar",
"offline": "offline"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Hinweis]** Es wurden mehrere Netzwerkkarten erkannt, die möglicherweise mit demselben Netzwerk verbunden sind. Bitte achten Sie auf die Auswahl.",
"net_unavailable": "Schnittstelle nicht verfügbar"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "Devices",
"found_central_gateway": ", Found Local Central Hub Gateway",
"without_room": "No room assigned"
"without_room": "No room assigned",
"no_display": "Do not display"
},
"control_mode": {
"auto": "Auto",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "Enable",
"disable": "Disable"
},
"device_state": {
"add": "Add",
"del": "Unavailable",
"offline": "Offline"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Notice]** Multiple network cards detected that may be connected to the same network. Please pay attention to the selection.",
"net_unavailable": "Interface unavailable"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "dispositivos",
"found_central_gateway": ", se encontró la puerta de enlace central local",
"without_room": "Sin habitación asignada"
"without_room": "Sin habitación asignada",
"no_display": "no mostrar"
},
"control_mode": {
"auto": "automático",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "habilitar",
"disable": "deshabilitar"
},
"device_state": {
"add": "agregar",
"del": "no disponible",
"offline": "fuera de línea"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Aviso]** Se detectaron varias tarjetas de red que pueden estar conectadas a la misma red. Por favor, preste atención a la selección.",
"net_unavailable": "Interfaz no disponible"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "appareils",
"found_central_gateway": ", passerelle centrale locale trouvée",
"without_room": "Aucune pièce attribuée"
"without_room": "Aucune pièce attribuée",
"no_display": "ne pas afficher"
},
"control_mode": {
"auto": "automatique",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "activer",
"disable": "désactiver"
},
"device_state": {
"add": "Ajouter",
"del": "Supprimer",
"offline": "hors ligne"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Remarque]** Plusieurs cartes réseau détectées qui peuvent être connectées au même réseau. Veuillez faire attention à la sélection.",
"net_unavailable": "Interface non disponible"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "デバイス",
"found_central_gateway": "、ローカル中央ゲートウェイが見つかりました",
"without_room": "部屋が割り当てられていません"
"without_room": "部屋が割り当てられていません",
"no_display": "表示しない"
},
"control_mode": {
"auto": "自動",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "有効",
"disable": "無効"
},
"device_state": {
"add": "追加",
"del": "利用不可",
"offline": "オフライン"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[注意]** 複数のネットワークカードが同じネットワークに接続されている可能性があります。選択に注意してください。",
"net_unavailable": "インターフェースが利用できません"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "Apparaten",
"found_central_gateway": ", Lokale centrale hub-gateway gevonden",
"without_room": "Niet toegewezen kamer"
"without_room": "Niet toegewezen kamer",
"no_display": "Niet weergeven"
},
"control_mode": {
"auto": "Automatisch",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "Inschakelen",
"disable": "Uitschakelen"
},
"device_state": {
"add": "Toevoegen",
"del": "Niet beschikbaar",
"offline": "Offline"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Let op]** Meerdere netwerkkaarten gedetecteerd die mogelijk zijn verbonden met hetzelfde netwerk. Let op bij de selectie.",
"net_unavailable": "Interface niet beschikbaar"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "dispositivos",
"found_central_gateway": "encontrado o gateway central local",
"without_room": "sem quarto atribuído"
"without_room": "sem quarto atribuído",
"no_display": "não exibir"
},
"control_mode": {
"auto": "automático",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "habilitado",
"disable": "desabilitado"
},
"device_state": {
"add": "adicionar",
"del": "indisponível",
"offline": "offline"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Aviso]** Detectado múltiplas interfaces de rede que podem estar conectando à mesma rede, por favor, selecione a correta.",
"net_unavailable": "Interface indisponível"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "dispositivos",
"found_central_gateway": ", encontrou a central de gateway local",
"without_room": "Sem quarto atribuído"
"without_room": "Sem quarto atribuído",
"no_display": "Não exibir"
},
"control_mode": {
"auto": "Automático",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "Habilitar",
"disable": "Desabilitar"
},
"device_state": {
"add": "Adicionar",
"del": "Indisponível",
"offline": "Offline"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Aviso]** Detectado que várias interfaces podem estar conectadas à mesma rede, escolha com cuidado.",
"net_unavailable": "Interface indisponível"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "устройства",
"found_central_gateway": ", найден локальный центральный шлюз",
"without_room": "без комнаты"
"without_room": "без комнаты",
"no_display": "не отображать"
},
"control_mode": {
"auto": "автоматический",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "Включить",
"disable": "Отключить"
},
"device_state": {
"add": "Добавить",
"del": "Недоступно",
"offline": "Не в сети"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[Уведомление]** Обнаружено несколько сетевых карт, которые могут быть подключены к одной и той же сети. Пожалуйста, обратите внимание на выбор.",
"net_unavailable": "Интерфейс недоступен"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "个设备",
"found_central_gateway": ",发现本地中枢网关",
"without_room": "未分配房间"
"without_room": "未分配房间",
"no_display": "不显示"
},
"control_mode": {
"auto": "自动",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "启用",
"disable": "禁用"
},
"device_state": {
"add": "新增",
"del": "不可用",
"offline": "离线"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[提示]** 检测到多个网卡可能连接同一个网络,请注意选择。",
"net_unavailable": "接口不可用"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/xiaomi_home/miot/i18n/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"other": {
"devices": "個設備",
"found_central_gateway": ",發現本地中樞網關",
"without_room": "未分配房間"
"without_room": "未分配房間",
"no_display": "不顯示"
},
"control_mode": {
"auto": "自動",
Expand Down Expand Up @@ -53,6 +54,11 @@
"enable": "啟用",
"disable": "禁用"
},
"device_state": {
"add": "新增",
"del": "不可用",
"offline": "離線"
},
"lan_ctrl_config": {
"notice_net_dup": "\r\n**[提示]** 檢測到多個網卡可能連接同一個網絡,請注意選擇。",
"net_unavailable": "接口不可用"
Expand Down
Loading

0 comments on commit 97e343e

Please sign in to comment.