From 09e921ed91bf54e8d52bab2bebcd1239a674277c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:09:40 +0200 Subject: [PATCH 1/6] Update modem.py --- resources/smsd/gsmmodem/modem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/smsd/gsmmodem/modem.py b/resources/smsd/gsmmodem/modem.py index 2871fcf..211e492 100644 --- a/resources/smsd/gsmmodem/modem.py +++ b/resources/smsd/gsmmodem/modem.py @@ -817,13 +817,13 @@ def ownNumber(self): response = self.write('AT+CPBS?') selected_phonebook = response[0][6:].split('"')[1] # first line, remove the +CSCS: prefix, split, first parameter - if selected_phonebook is not "ON": + if selected_phonebook != "ON": self.write('AT+CPBS="ON"') response = self.write("AT+CPBR=1") self.write('AT+CPBS="{0}"'.format(selected_phonebook)) - if response is "OK": # command is supported, but no number is set + if response == "OK": # command is supported, but no number is set return None elif len(response) == 2: # OK and phone number. Actual number is in the first line, second parameter, and is placed inside quotation marks cnumLine = response[0] @@ -843,7 +843,7 @@ def ownNumber(self): @ownNumber.setter def ownNumber(self, phone_number): actual_phonebook = self.write('AT+CPBS?') - if actual_phonebook is not "ON": + if actual_phonebook != "ON": self.write('AT+CPBS="ON"') self.write('AT+CPBW=1,"' + phone_number + '"') From 907d587987782afb65a788510f59164cab9804d7 Mon Sep 17 00:00:00 2001 From: Mips2648 Date: Sat, 7 Sep 2024 08:28:06 +0200 Subject: [PATCH 2/6] collections.mapping is deprecated since python3.7 --- resources/smsd/jeedom/jeedom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/smsd/jeedom/jeedom.py b/resources/smsd/jeedom/jeedom.py index 2478dc8..40fbbe0 100644 --- a/resources/smsd/jeedom/jeedom.py +++ b/resources/smsd/jeedom/jeedom.py @@ -18,7 +18,7 @@ import threading import requests import datetime -import collections +from collections.abc import Mapping import serial import os from queue import Queue @@ -120,8 +120,8 @@ def get_change(self): def merge_dict(self, d1, d2): for k, v2 in d2.items(): v1 = d1.get(k) # returns None if v1 has no value for this key - if (isinstance(v1, collections.Mapping) and - isinstance(v2, collections.Mapping)): + if (isinstance(v1, Mapping) and + isinstance(v2, Mapping)): self.merge_dict(v1, v2) else: d1[k] = v2 From f0b25678897b0f49821eb54069da1191160ca5af Mon Sep 17 00:00:00 2001 From: Mips2648 Date: Sat, 7 Sep 2024 08:35:09 +0200 Subject: [PATCH 3/6] Logging should be lazy --- resources/smsd/smsd.py | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/resources/smsd/smsd.py b/resources/smsd/smsd.py index 216eaa7..94b5d61 100644 --- a/resources/smsd/smsd.py +++ b/resources/smsd/smsd.py @@ -35,7 +35,7 @@ def handleSms(sms): - logging.debug("Got SMS message : "+str(sms)) + logging.debug("Got SMS message : %s", sms) if not sms.text: logging.debug("No text so nothing to do") return @@ -57,12 +57,12 @@ def listen(): logging.debug("Text mode false") gsm.smsTextMode = False if _pin != 'None': - logging.debug("Enter pin code : "+_pin) + logging.debug("Enter pin code : %s ", _pin) gsm.connect(_pin, 1) else: gsm.connect(None, 1) if _smsc != 'None': - logging.debug("Configure smsc : "+_smsc) + logging.debug("Configure smsc : %s", _smsc) gsm.write('AT+CSCA="{0}"'.format(_smsc)) logging.debug("Waiting for network...") gsm.waitForNetworkCoverage() @@ -80,7 +80,7 @@ def listen(): except Exception as e: if str(e).find('object has no attribute') != -1: pass - logging.error("Exception on 'ME': %s" % str(e)) + logging.error("Exception on 'ME': %s", e) try: gsm.write('AT+CPMS="SM","SM","SM"') @@ -88,7 +88,7 @@ def listen(): except Exception as e: if str(e).find('object has no attribute') != -1: pass - logging.error("Exception on 'SM': %s" % str(e)) + logging.error("Exception on 'SM': %s", e) except Exception as e: if str(e).find('object has no attribute') != -1: pass @@ -109,14 +109,14 @@ def listen(): signal_strength_store = gsm.signalStrength jeedom_com.send_change_immediate({'number': 'signal_strength', 'message': str(gsm.signalStrength)}) except Exception as e: - logging.error("Exception on GSM : %s" % str(e)) + logging.error("Exception on GSM : %s", e) if str(e) == 'Attempting to use a port that is not open' or str(e) == 'Timeout' or str(e) == 'Device not searching for network operator': logging.error("Exit 1 because this exeption is fatal") shutdown() try: read_socket() except Exception as e: - logging.error("Exception on socket : %s" % str(e)) + logging.error("Exception on socket : %s", e) except KeyboardInterrupt: shutdown() @@ -128,7 +128,7 @@ def read_socket(): logging.debug("Message received in socket JEEDOM_SOCKET_MESSAGE") message = json.loads(JEEDOM_SOCKET_MESSAGE.get().decode("utf-8")) if message['apikey'] != _apikey: - logging.error("Invalid apikey from socket : " + str(message)) + logging.error("Invalid apikey from socket : ", message) return gsm.waitForNetworkCoverage() logging.info("Envoi d'un message à %s: %s", message['number'], message['message']) @@ -138,13 +138,13 @@ def read_socket(): def handler(signum=None, frame=None): - logging.debug("Signal %i caught, exiting..." % int(signum)) + logging.debug("Signal %i caught, exiting...", signum) shutdown() def shutdown(): logging.debug("Shutdown") - logging.debug("Removing PID file " + str(_pidfile)) + logging.debug("Removing PID file %s", _pidfile) try: os.remove(_pidfile) except: @@ -217,17 +217,17 @@ def shutdown(): jeedom_utils.set_log_level(_log_level) logging.info('Start smsd') -logging.info('Log level : '+str(_log_level)) -logging.info('Socket port : '+str(_socket_port)) -logging.info('Socket host : '+str(_socket_host)) -logging.info('PID file : '+str(_pidfile)) -logging.info('Device : '+str(_device)) -logging.info('Callback : '+str(_callback)) -logging.info('Cycle : '+str(_cycle)) -logging.info('Serial rate : '+str(_serial_rate)) -logging.info('Pin : '+str(_pin)) -logging.info('Text mode : '+str(_text_mode)) -logging.info('SMSC : '+str(_smsc)) +logging.info('Log level : %s', _log_level) +logging.info('Socket port : %s', _socket_port) +logging.info('Socket host : %s', _socket_host) +logging.info('PID file : %s', _pidfile) +logging.info('Device : %s', _device) +logging.info('Callback : %s', _callback) +logging.info('Cycle : %s', _cycle) +logging.info('Serial rate : %s', _serial_rate) +logging.info('Pin : %s', _pin) +logging.info('Text mode : %s', _text_mode) +logging.info('SMSC : %s', _smsc) if _device == 'auto': @@ -238,7 +238,7 @@ def shutdown(): for stick in know_sticks: _device = jeedom_utils.find_tty_usb(stick['idVendor'], stick['idProduct'], stick['name']) if _device is not None: - logging.info('Find device : '+str(_device)) + logging.info('Find device : %s', _device) break @@ -258,6 +258,6 @@ def shutdown(): jeedom_socket = jeedom_socket(port=_socket_port, address=_socket_host) listen() except Exception as e: - logging.error('Fatal error : '+str(e)) + logging.error('Fatal error : %s', e) logging.debug(traceback.format_exc()) shutdown() From 8c3000ffd956971a8b8b6aae30b8e26afc8e2872 Mon Sep 17 00:00:00 2001 From: Mips2648 Date: Sat, 7 Sep 2024 08:39:33 +0200 Subject: [PATCH 4/6] dedicated log daemon --- core/class/sms.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/sms.class.php b/core/class/sms.class.php index d0b7889..311b932 100644 --- a/core/class/sms.class.php +++ b/core/class/sms.class.php @@ -75,7 +75,7 @@ public static function deamon_start() { $cmd .= ' --apikey ' . jeedom::getApiKey('sms'); $cmd .= ' --pid ' . jeedom::getTmpFolder('sms') . '/deamon.pid'; log::add('sms', 'info', 'Lancement démon sms : ' . $cmd); - $result = exec($cmd . ' >> ' . log::getPathToLog('sms') . ' 2>&1 &'); + $result = exec($cmd . ' >> ' . log::getPathToLog('smsd') . ' 2>&1 &'); $i = 0; while ($i < 30) { $deamon_info = self::deamon_info(); From 97ecb78b6228c509cfb3965381235a735086fe37 Mon Sep 17 00:00:00 2001 From: Mips2648 Date: Sat, 7 Sep 2024 08:42:21 +0200 Subject: [PATCH 5/6] changelog --- docs/fr_FR/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/fr_FR/changelog.md b/docs/fr_FR/changelog.md index 4b1f687..01d040d 100644 --- a/docs/fr_FR/changelog.md +++ b/docs/fr_FR/changelog.md @@ -4,6 +4,10 @@ > >Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte +## 08/09/2024 + +- Fix sur la réception des SMS + ## 31/08/2024 - Compatibilité Debian 12 From 176ceb57cb7f87d3143c0d1ef4e62ac824b4b090 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Sat, 7 Sep 2024 23:06:22 +0000 Subject: [PATCH 6/6] [Jenkins] Updated translation --- docs/de_DE/changelog.md | 4 ++++ docs/en_US/changelog.md | 4 ++++ docs/es_ES/changelog.md | 4 ++++ docs/i18n/de_DE.json | 2 ++ docs/i18n/en_US.json | 2 ++ docs/i18n/es_ES.json | 2 ++ docs/i18n/fr_FR.json | 2 ++ docs/i18n/pt_PT.json | 2 ++ docs/pt_PT/changelog.md | 4 ++++ 9 files changed, 26 insertions(+) diff --git a/docs/de_DE/changelog.md b/docs/de_DE/changelog.md index a0a1bbc..3d6a2dd 100644 --- a/docs/de_DE/changelog.md +++ b/docs/de_DE/changelog.md @@ -4,6 +4,10 @@ > >Zur Erinnerung: Wenn keine Informationen zum Update vorhanden sind, bedeutet dies, dass es sich nur um die Aktualisierung von Dokumentation, Übersetzung oder Text handelt +## 08.09.2024 + +- Problem beim Empfang von SMS behoben + ## 31.08.2024 - Debian 12-Kompatibilität diff --git a/docs/en_US/changelog.md b/docs/en_US/changelog.md index 988cd0e..d5feebb 100644 --- a/docs/en_US/changelog.md +++ b/docs/en_US/changelog.md @@ -4,6 +4,10 @@ > >As a reminder if there is no information on the update, it means that it only concerns the updating of documentation, translation or text +## 08/09/2024 + +- Fix on receiving SMS + ## 08/31/2024 - Debian 12 Compatibility diff --git a/docs/es_ES/changelog.md b/docs/es_ES/changelog.md index 447b0a7..9646fda 100644 --- a/docs/es_ES/changelog.md +++ b/docs/es_ES/changelog.md @@ -4,6 +4,10 @@ > >Como recordatorio si no hay información sobre la actualización, significa que solo se refiere a la actualización de documentación, traducción o texto +## 08/09/2024 + +- Corrección al recibir SMS + ## 31/08/2024 - Compatibilidad con Debian 12 diff --git a/docs/i18n/de_DE.json b/docs/i18n/de_DE.json index eabc524..9cc790e 100644 --- a/docs/i18n/de_DE.json +++ b/docs/i18n/de_DE.json @@ -2,6 +2,8 @@ "changelog.md": { "Changelog SMS": "Changelog SMS", "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte": "Zur Erinnerung: Wenn keine Informationen zum Update vorhanden sind, bedeutet dies, dass es sich nur um die Aktualisierung von Dokumentation, Übersetzung oder Text handelt", + "08\/09\/2024": "08.09.2024", + "Fix sur la réception des SMS": "Problem beim Empfang von SMS behoben", "31\/08\/2024": "31.08.2024", "Compatibilité Debian 12": "Debian 12-Kompatibilität", "Version minimum jeedom requise": "Mindestversion von Jeedom erforderlich", diff --git a/docs/i18n/en_US.json b/docs/i18n/en_US.json index 500061d..aff21dd 100644 --- a/docs/i18n/en_US.json +++ b/docs/i18n/en_US.json @@ -2,6 +2,8 @@ "changelog.md": { "Changelog SMS": "Changelog SMS", "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte": "As a reminder if there is no information on the update, it means that it only concerns the updating of documentation, translation or text", + "08\/09\/2024": "08\/09\/2024", + "Fix sur la réception des SMS": "Fix on receiving SMS", "31\/08\/2024": "08\/31\/2024", "Compatibilité Debian 12": "Debian 12 Compatibility", "Version minimum jeedom requise": "Minimum jeedom version required", diff --git a/docs/i18n/es_ES.json b/docs/i18n/es_ES.json index 2b72b0a..288f86a 100644 --- a/docs/i18n/es_ES.json +++ b/docs/i18n/es_ES.json @@ -2,6 +2,8 @@ "changelog.md": { "Changelog SMS": "Changelog SMS", "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte": "Como recordatorio si no hay información sobre la actualización, significa que solo se refiere a la actualización de documentación, traducción o texto", + "08\/09\/2024": "08\/09\/2024", + "Fix sur la réception des SMS": "Corrección al recibir SMS", "31\/08\/2024": "31\/08\/2024", "Compatibilité Debian 12": "Compatibilidad con Debian 12", "Version minimum jeedom requise": "Se requiere una versión mínima de jeedom", diff --git a/docs/i18n/fr_FR.json b/docs/i18n/fr_FR.json index 7b21f45..3b08e00 100644 --- a/docs/i18n/fr_FR.json +++ b/docs/i18n/fr_FR.json @@ -3,6 +3,8 @@ "Changelog SMS": "Changelog SMS", "IMPORTANT": "IMPORTANT", "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte": "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte", + "08\/09\/2024": "08\/09\/2024", + "Fix sur la réception des SMS": "Fix sur la réception des SMS", "31\/08\/2024": "31\/08\/2024", "Compatibilité Debian 12": "Compatibilité Debian 12", "Version minimum jeedom requise": "Version minimum jeedom requise", diff --git a/docs/i18n/pt_PT.json b/docs/i18n/pt_PT.json index 9f1d585..4f9ba40 100644 --- a/docs/i18n/pt_PT.json +++ b/docs/i18n/pt_PT.json @@ -2,6 +2,8 @@ "changelog.md": { "Changelog SMS": "Changelog SMS", "Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte": "Como lembrete, se não houver informações sobre a atualização, isso significa que se trata apenas da atualização da documentação, tradução ou texto", + "08\/09\/2024": "08\/09\/2024", + "Fix sur la réception des SMS": "Correção no recebimento de SMS", "31\/08\/2024": "31\/08\/2024", "Compatibilité Debian 12": "Compatibilidade com Debian 12", "Version minimum jeedom requise": "Versão mínima do jeedom necessária", diff --git a/docs/pt_PT/changelog.md b/docs/pt_PT/changelog.md index 4f34be4..a234d36 100644 --- a/docs/pt_PT/changelog.md +++ b/docs/pt_PT/changelog.md @@ -4,6 +4,10 @@ > >Como lembrete, se não houver informações sobre a atualização, isso significa que se trata apenas da atualização da documentação, tradução ou texto +## 08/09/2024 + +- Correção no recebimento de SMS + ## 31/08/2024 - Compatibilidade com Debian 12