From a6f5e6c4995c28aae4bdbc65d5cfa360d019ecee Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 6 Jan 2024 10:26:39 +1100 Subject: [PATCH] MQTT enable scheduler #522 --- front/plugins/_publisher_mqtt/config.json | 35 +++++++++++++++++++++-- front/plugins/_publisher_mqtt/mqtt.py | 5 ---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/front/plugins/_publisher_mqtt/config.json b/front/plugins/_publisher_mqtt/config.json index 18231835..1f33a5d6 100755 --- a/front/plugins/_publisher_mqtt/config.json +++ b/front/plugins/_publisher_mqtt/config.json @@ -254,7 +254,7 @@ "events": ["test"], "type": "text.select", "default_value":"disabled", - "options": ["disabled", "on_notification" ], + "options": ["disabled", "on_notification", "once", "schedule", "always_after_scan", "on_new_device" ], "localized": ["name", "description"], "name" :[{ "language_code": "en_us", @@ -267,7 +267,7 @@ "description": [ { "language_code": "en_us", - "string" : "Enable sending notifications via MQTT to your Home Assistance instance." + "string" : "Enable sending notifications via MQTT to your Home Assistance instance. Usually, on_notification is recommended." }, { "language_code": "es_es", @@ -298,6 +298,37 @@ "string" : "Comando a ejecutar" }] }, + { + "function": "RUN_SCHD", + "type": "text", + "default_value":"0 2 * * 3", + "options": [], + "localized": ["name", "description"], + "name" : [{ + "language_code":"en_us", + "string" : "Schedule" + }, + { + "language_code":"es_es", + "string" : "Schedule" + }, + { + "language_code":"de_de", + "string" : "Schedule" + }], + "description": [{ + "language_code":"en_us", + "string" : "Only enabled if you select schedule in the MQTT_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes." + }, + { + "language_code":"es_es", + "string" : "Solo está habilitado si selecciona schedule en la configuración MQTT_RUN. Asegúrese de ingresar la programación en el formato similar a cron correcto (por ejemplo, valide en crontab.guru). Por ejemplo, ingresar 0 4 * * * ejecutará el escaneo después de las 4 a.m. en el TIMEZONE que configuró arriba. Se ejecutará la PRÓXIMA vez que pase el tiempo." + }, + { + "language_code":"de_de", + "string" : "Nur aktiviert, wenn Sie schedule in der MQTT_RUN-Einstellung auswählen. Stellen Sie sicher, dass Sie den Zeitplan im richtigen Cron-ähnlichen Format eingeben (z. B. validieren unter crontab.guru). Wenn Sie beispielsweise 0 4 * * * eingeben, wird der Scan nach 4 Uhr morgens in der TIMEZONE den Sie oben festgelegt haben. Wird das NÄCHSTE Mal ausgeführt, wenn die Zeit vergeht." + }] + }, { "function": "RUN_TIMEOUT", "type": "integer", diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index 2fd54135..5bc801bc 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -46,11 +46,6 @@ mqtt_connected_to_broker = False client = None # mqtt client def main(): - - mylog('debug', [f"[{pluginName}] DEBUG TEST"]) - mylog('verbose', [f"[{pluginName}] VERBOSE TEST"]) - mylog('minimal', [f"[{pluginName}] MINIMAL TEST"]) - mylog('none', [f"[{pluginName}] NONE TEST"]) mylog('verbose', [f'[{pluginName}](publisher) In script'])