Skip to content

Commit

Permalink
add cloud profile option to enable fw check
Browse files Browse the repository at this point in the history
  • Loading branch information
krahabb committed Jul 28, 2023
1 parent 9d0fb5a commit 99601b4
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions custom_components/meross_lan/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions custom_components/meross_lan/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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


Expand Down
6 changes: 4 additions & 2 deletions custom_components/meross_lan/meross_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .const import (
CONF_ALLOW_MQTT_PUBLISH,
CONF_CHECK_FIRMWARE_UPDATES,
CONF_CREATE_DIAGNOSTIC_ENTITIES,
CONF_DEVICE_ID,
CONF_EMAIL,
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
3 changes: 3 additions & 0 deletions custom_components/meross_lan/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"password": "メロスパスワード",
"save_password": "パスワードを保存する",
"allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する",
"check_firmware_updates": "ファームウェアのアップデートを確認する",
"create_diagnostic_entities": "診断エンティティの作成"
}
},
Expand Down Expand Up @@ -151,6 +152,7 @@
"password": "メロスパスワード",
"save_password": "パスワードを保存する",
"allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する",
"check_firmware_updates": "ファームウェアのアップデートを確認する",
"create_diagnostic_entities": "診断エンティティの作成"
}
}
Expand All @@ -169,6 +171,7 @@
"password": "メロスパスワード",
"save_password": "パスワードを保存する",
"allow_mqtt_publish": "クラウド MQTT パブリッシュを許可する",
"check_firmware_updates": "ファームウェアのアップデートを確認する",
"create_diagnostic_entities": "診断エンティティの作成"
}
}
Expand Down

0 comments on commit 99601b4

Please sign in to comment.