From 99601b4a1019fdf3da41a57cccbd1dc80097f165 Mon Sep 17 00:00:00 2001 From: krahabb <13969600+krahabb@users.noreply.github.com> Date: Fri, 28 Jul 2023 07:54:03 +0000 Subject: [PATCH] add cloud profile option to enable fw check --- custom_components/meross_lan/config_flow.py | 6 ++++++ custom_components/meross_lan/const.py | 2 ++ custom_components/meross_lan/meross_profile.py | 6 ++++-- custom_components/meross_lan/translations/cs.json | 3 +++ custom_components/meross_lan/translations/de.json | 3 +++ custom_components/meross_lan/translations/en.json | 3 +++ custom_components/meross_lan/translations/es.json | 3 +++ custom_components/meross_lan/translations/fr.json | 3 +++ custom_components/meross_lan/translations/it.json | 3 +++ custom_components/meross_lan/translations/ja.json | 3 +++ 10 files changed, 33 insertions(+), 2 deletions(-) diff --git a/custom_components/meross_lan/config_flow.py b/custom_components/meross_lan/config_flow.py index ba56c32d..0cc12e0e 100644 --- a/custom_components/meross_lan/config_flow.py +++ b/custom_components/meross_lan/config_flow.py @@ -222,6 +222,12 @@ async def async_step_profile(self, user_input=None): description={DESCR: profile_config.get(mlc.CONF_ALLOW_MQTT_PUBLISH)}, ) ] = bool + config_schema[ + vol.Optional( + mlc.CONF_CHECK_FIRMWARE_UPDATES, + description={DESCR: profile_config.get(mlc.CONF_CHECK_FIRMWARE_UPDATES)}, + ) + ] = bool config_schema[ vol.Optional( mlc.CONF_CREATE_DIAGNOSTIC_ENTITIES, diff --git a/custom_components/meross_lan/const.py b/custom_components/meross_lan/const.py index b1d69123..32263cb3 100644 --- a/custom_components/meross_lan/const.py +++ b/custom_components/meross_lan/const.py @@ -84,6 +84,7 @@ class DeviceConfigType(DeviceConfigTypeMinimal, total=False): CONF_PASSWORD: Final = hac.CONF_PASSWORD CONF_SAVE_PASSWORD: Final = "save_password" CONF_ALLOW_MQTT_PUBLISH: Final = "allow_mqtt_publish" +CONF_CHECK_FIRMWARE_UPDATES: Final = "check_firmware_updates" CONF_CREATE_DIAGNOSTIC_ENTITIES: Final = "create_diagnostic_entities" @@ -95,6 +96,7 @@ class ProfileConfigType(cloudapi.MerossCloudCredentials, total=False): password: str | None save_password: bool | None allow_mqtt_publish: bool | None + check_firmware_updates: bool | None create_diagnostic_entities: bool | None diff --git a/custom_components/meross_lan/meross_profile.py b/custom_components/meross_lan/meross_profile.py index eff54e7f..0f46b798 100644 --- a/custom_components/meross_lan/meross_profile.py +++ b/custom_components/meross_lan/meross_profile.py @@ -18,6 +18,7 @@ from .const import ( CONF_ALLOW_MQTT_PUBLISH, + CONF_CHECK_FIRMWARE_UPDATES, CONF_CREATE_DIAGNOSTIC_ENTITIES, CONF_DEVICE_ID, CONF_EMAIL, @@ -1025,16 +1026,17 @@ async def async_check_query_device_info(self): return None async def async_check_query_latest_version(self, epoch: float, token: str): - if ( + if self.config.get(CONF_CHECK_FIRMWARE_UPDATES) and ( epoch - self._data[MerossCloudProfile.KEY_LATEST_VERSION_TIME] ) > PARAM_CLOUDPROFILE_QUERY_LATESTVERSION_TIMEOUT: self._data[MerossCloudProfile.KEY_LATEST_VERSION_TIME] = epoch - with self.exception_warning("async_check_query_latestversion"): + with self.exception_warning("async_check_query_latest_version"): self._data[ MerossCloudProfile.KEY_LATEST_VERSION ] = await async_cloudapi_device_latestversion( token, async_get_clientsession(ApiProfile.hass) ) + self._schedule_save_store() for device in ApiProfile.active_devices(): if latest_version := self.get_latest_version(device.descriptor): device.update_latest_version(latest_version) diff --git a/custom_components/meross_lan/translations/cs.json b/custom_components/meross_lan/translations/cs.json index d8109844..7e55a363 100644 --- a/custom_components/meross_lan/translations/cs.json +++ b/custom_components/meross_lan/translations/cs.json @@ -92,6 +92,7 @@ "password": "Heslo k účtu Meross", "save_password": "Uložit heslo", "allow_mqtt_publish": "Povolit cloudové publikování MQTT", + "check_firmware_updates": "Zkontrolujte aktualizace firmwaru", "create_diagnostic_entities": "Vytvářejte diagnostické entity" } }, @@ -152,6 +153,7 @@ "password": "Heslo k účtu Meross", "save_password": "Uložit heslo", "allow_mqtt_publish": "Povolit cloudové publikování MQTT", + "check_firmware_updates": "Zkontrolujte aktualizace firmwaru", "create_diagnostic_entities": "Vytvářejte diagnostické entity" } } @@ -170,6 +172,7 @@ "password": "Heslo k účtu Meross", "save_password": "Uložit heslo", "allow_mqtt_publish": "Povolit cloudové publikování MQTT", + "check_firmware_updates": "Zkontrolujte aktualizace firmwaru", "create_diagnostic_entities": "Vytvářejte diagnostické entity" } } diff --git a/custom_components/meross_lan/translations/de.json b/custom_components/meross_lan/translations/de.json index 5b3174a2..b9e4f191 100644 --- a/custom_components/meross_lan/translations/de.json +++ b/custom_components/meross_lan/translations/de.json @@ -91,6 +91,7 @@ "password": "Meross Passwort", "save_password": "Passwort speichern", "allow_mqtt_publish": "Cloud-MQTT-Veröffentlichung zulassen", + "check_firmware_updates": "Überprüfen Sie Firmware-Updates", "create_diagnostic_entities": "Erstellen Sie Diagnoseeinheiten" } }, @@ -151,6 +152,7 @@ "password": "Meross Passwort", "save_password": "Passwort speichern", "allow_mqtt_publish": "Cloud-MQTT-Veröffentlichung zulassen", + "check_firmware_updates": "Überprüfen Sie Firmware-Updates", "create_diagnostic_entities": "Erstellen Sie Diagnoseeinheiten" } } @@ -169,6 +171,7 @@ "password": "Meross Passwort", "save_password": "Passwort speichern", "allow_mqtt_publish": "Cloud-MQTT-Veröffentlichung zulassen", + "check_firmware_updates": "Überprüfen Sie Firmware-Updates", "create_diagnostic_entities": "Erstellen Sie Diagnoseeinheiten" } } diff --git a/custom_components/meross_lan/translations/en.json b/custom_components/meross_lan/translations/en.json index ee5373b9..ca2711ac 100644 --- a/custom_components/meross_lan/translations/en.json +++ b/custom_components/meross_lan/translations/en.json @@ -91,6 +91,7 @@ "password": "Meross password", "save_password": "Save password", "allow_mqtt_publish": "Allow cloud MQTT publish", + "check_firmware_updates": "Check firmware updates", "create_diagnostic_entities": "Create diagnostic entities" } }, @@ -151,6 +152,7 @@ "password": "Meross password", "save_password": "Save password", "allow_mqtt_publish": "Allow cloud MQTT publish", + "check_firmware_updates": "Check firmware updates", "create_diagnostic_entities": "Create diagnostic entities" } } @@ -169,6 +171,7 @@ "password": "Meross password", "save_password": "Save password", "allow_mqtt_publish": "Allow cloud MQTT publish", + "check_firmware_updates": "Check firmware updates", "create_diagnostic_entities": "Create diagnostic entities" } } diff --git a/custom_components/meross_lan/translations/es.json b/custom_components/meross_lan/translations/es.json index 0d162dab..4e20be22 100644 --- a/custom_components/meross_lan/translations/es.json +++ b/custom_components/meross_lan/translations/es.json @@ -91,6 +91,7 @@ "password": "Contraseña de Meross", "save_password": "Guardar contraseña", "allow_mqtt_publish": "Permitir la publicación de MQTT en la nube", + "check_firmware_updates": "Comprobar actualizaciones de firmware", "create_diagnostic_entities": "Crear entidades de diagnóstico" } }, @@ -151,6 +152,7 @@ "password": "Contraseña de Meross", "save_password": "Guardar contraseña", "allow_mqtt_publish": "Permitir la publicación de MQTT en la nube", + "check_firmware_updates": "Comprobar actualizaciones de firmware", "create_diagnostic_entities": "Crear entidades de diagnóstico" } } @@ -169,6 +171,7 @@ "password": "Contraseña de Meross", "save_password": "Guardar contraseña", "allow_mqtt_publish": "Permitir la publicación de MQTT en la nube", + "check_firmware_updates": "Comprobar actualizaciones de firmware", "create_diagnostic_entities": "Crear entidades de diagnóstico" } } diff --git a/custom_components/meross_lan/translations/fr.json b/custom_components/meross_lan/translations/fr.json index 035e637d..09644d8f 100644 --- a/custom_components/meross_lan/translations/fr.json +++ b/custom_components/meross_lan/translations/fr.json @@ -91,6 +91,7 @@ "password": "Mot de passe Meross", "save_password": "Enregistrer le mot de passe", "allow_mqtt_publish": "Autoriser la publication cloud MQTT", + "check_firmware_updates": "Vérifier les mises à jour du firmware", "create_diagnostic_entities": "Créer des entités de diagnostic" } }, @@ -151,6 +152,7 @@ "password": "Mot de passe Meross", "save_password": "Enregistrer le mot de passe", "allow_mqtt_publish": "Autoriser la publication cloud MQTT", + "check_firmware_updates": "Vérifier les mises à jour du firmware", "create_diagnostic_entities": "Créer des entités de diagnostic" } } @@ -169,6 +171,7 @@ "password": "Mot de passe Meross", "save_password": "Enregistrer le mot de passe", "allow_mqtt_publish": "Autoriser la publication cloud MQTT", + "check_firmware_updates": "Vérifier les mises à jour du firmware", "create_diagnostic_entities": "Créer des entités de diagnostic" } } diff --git a/custom_components/meross_lan/translations/it.json b/custom_components/meross_lan/translations/it.json index d5100420..31733871 100644 --- a/custom_components/meross_lan/translations/it.json +++ b/custom_components/meross_lan/translations/it.json @@ -91,6 +91,7 @@ "password": "Meross password", "save_password": "Salva password", "allow_mqtt_publish": "Consenti pubblicazione MQTT", + "check_firmware_updates": "Verifica aggiornamenti firmware", "create_diagnostic_entities": "Crea entità disagnostiche" } }, @@ -150,6 +151,7 @@ "password": "Meross password", "save_password": "Salva password", "allow_mqtt_publish": "Consenti pubblicazione MQTT", + "check_firmware_updates": "Verifica aggiornamenti firmware", "create_diagnostic_entities": "Crea entità disagnostiche" } } @@ -168,6 +170,7 @@ "password": "Meross password", "save_password": "Salva password", "allow_mqtt_publish": "Consenti pubblicazione MQTT", + "check_firmware_updates": "Verifica aggiornamenti firmware", "create_diagnostic_entities": "Crea entità disagnostiche" } } diff --git a/custom_components/meross_lan/translations/ja.json b/custom_components/meross_lan/translations/ja.json index aa369aa2..f4c20855 100644 --- a/custom_components/meross_lan/translations/ja.json +++ b/custom_components/meross_lan/translations/ja.json @@ -91,6 +91,7 @@ "password": "メロスパスワード", "save_password": "パスワードを保存する", "allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する", + "check_firmware_updates": "ファームウェアのアップデートを確認する", "create_diagnostic_entities": "診断エンティティの作成" } }, @@ -151,6 +152,7 @@ "password": "メロスパスワード", "save_password": "パスワードを保存する", "allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する", + "check_firmware_updates": "ファームウェアのアップデートを確認する", "create_diagnostic_entities": "診断エンティティの作成" } } @@ -169,6 +171,7 @@ "password": "メロスパスワード", "save_password": "パスワードを保存する", "allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する", + "check_firmware_updates": "ファームウェアのアップデートを確認する", "create_diagnostic_entities": "診断エンティティの作成" } }