fileMon - broadcastCh #60

Closed
opened 2026-10-05 01:18:40 +02:00 by adam · 2 comments
Owner

Great code!

While most other broadcastCh elements accept a comma delimited series of channels - Attempting to do so under fileMon results in exception.

file_monitor_broadcastCh = config['fileMon'].getint('broadcastCh', 2) # default 2

File "/usr/lib/python3.8/configparser.py", line 1303, in get
return _impl(self._name, option, raw=raw, vars=vars,
File "/usr/lib/python3.8/configparser.py", line 818, in getint
return self._get_conv(section, option, int, raw=raw, vars=vars,
File "/usr/lib/python3.8/configparser.py", line 808, in _get_conv
return self._get(section, conv, option, raw=raw, vars=vars,
File "/usr/lib/python3.8/configparser.py", line 803, in _get
return conv(self.get(section, option, **kwargs))
ValueError: invalid literal for int() with base 10: '0,2'

Looks like the value is being swooped up from CFG INI properly (0,2) is present. But then it's passed elsewhere that is expecting an INT. I assume code isn't splitting on comma and simply attempting to pass down "0,2" that results in error.

Appreciate everyone.

Great code! While most other broadcastCh elements accept a comma delimited series of channels - Attempting to do so under fileMon results in exception. file_monitor_broadcastCh = config['fileMon'].getint('broadcastCh', 2) # default 2 File "/usr/lib/python3.8/configparser.py", line 1303, in get return _impl(self._name, option, raw=raw, vars=vars, File "/usr/lib/python3.8/configparser.py", line 818, in getint return self._get_conv(section, option, int, raw=raw, vars=vars, File "/usr/lib/python3.8/configparser.py", line 808, in _get_conv return self._get(section, conv, option, raw=raw, vars=vars, File "/usr/lib/python3.8/configparser.py", line 803, in _get return conv(self.get(section, option, **kwargs)) ValueError: invalid literal for int() with base 10: '0,2' Looks like the value is being swooped up from CFG INI properly (0,2) is present. But then it's passed elsewhere that is expecting an INT. I assume code isn't splitting on comma and simply attempting to pass down "0,2" that results in error. Appreciate everyone. <!-- github-sync-id:3128754581 -->
adam closed this issue 2026-10-05 01:18:40 +02:00
Author
Owner

Thanks! Should be resolved

Thanks! Should be resolved <!-- github-comment-id:2954473409 -->
Author
Owner

I got it working on my side... Found several issues. But keep in mind I am new to your code base.

1 - modules/system.py
It kept hitting the ELSE loop for antiSpam even though it is hard coded to False in the settings file. I changed it to NOT and also added the int(ch) and int(publicChannel) because I thought maybe that part of the else was failing since it was being sluped in as a string VS an int.

Here is the code that works on my side (checkout part 2 below as well)

            # if fileWatchBroadcastCh list contains multiple channels, broadcast to all
            if type(file_monitor_broadcastCh) is list:
                for ch in file_monitor_broadcastCh:
                    logger.debug(f"System: fileMon loop 1 - working ch {ch} publicChannel {publicChannel} antiSpam = {antiSpam}")
                    if not antiSpam and int(ch) != int(publicChannel):
                        logger.debug(f"System: fileMon loop 1 = Preparing to send msg {msg} to ch {ch}")
                        send_message(msg, int(ch), 0, 1)
                        time.sleep(responseDelay)
                        if multiple_interface:
                            for i in range(2, 10):
                                if globals().get(f'interface{i}_enabled'):
                                    send_message(msg, int(ch), 0, i)
                                    time.sleep(responseDelay)
                    else:
                        logger.warning(f"System: antiSpam or ch {ch} mismatch of pubCh {publicChannel} prevented Alert from FileWatcher 1")
            else:
                if not antiSpam and file_monitor_broadcastCh != publicChannel:
                    send_message(msg, int(file_monitor_broadcastCh), 0, 1)
                    time.sleep(responseDelay)
                    if multiple_interface:
                        for i in range(2, 10):
                            if globals().get(f'interface{i}_enabled'):
                                send_message(msg, int(file_monitor_broadcastCh), 0, i)
                                time.sleep(responseDelay)
                else:
                    logger.warning(f"System: antiSpam prevented Alert from FileWatcher 2")

2 - modules/settings.py around line 337 wasn't splitting the incoming values. So i checked code elsewhere and saw it was splitting on inbound values. Since I am using several channgels for fileMon alerts - I didn't bother testing this with a single value. But this is what worked for me:
##COmmented by todd ORIG file_monitor_broadcastCh = config['fileMon'].getint('broadcastCh', 2) # default 2
file_monitor_broadcastCh = config['fileMon'].get('broadcastCh', '').split(',')##Todd Fix

^^^ Changing the above sections of code is what got the fileMon working for me. The other thing I did was add the full path to the alert.txt file within the config.ini file - I did that because I am starting the code from a script in another directory that is linked to a manager and runs all of our startup stuff. Just to be safe on the CWD - I just hard coded the fullpath to be safe.

In closing...
I appreciate everyone who has contributed to this project! After being in North Carolina after the hurricanes in the fall of 2024 - All coms were down for a long time. Having meshtastic would have been a game changer for those of us in the field.

We def need more people involved and creating cool stuff like this bot helps keep people engaged and excited about tinkering with stuff.

Best wishes to family and team.

AFRS.US

I got it working on my side... Found several issues. But keep in mind I am new to your code base. 1 - modules/system.py It kept hitting the ELSE loop for antiSpam even though it is hard coded to False in the settings file. I changed it to NOT and also added the int(ch) and int(publicChannel) because I thought maybe that part of the else was failing since it was being sluped in as a string VS an int. Here is the code that works on my side (checkout part 2 below as well) # if fileWatchBroadcastCh list contains multiple channels, broadcast to all if type(file_monitor_broadcastCh) is list: for ch in file_monitor_broadcastCh: logger.debug(f"System: fileMon loop 1 - working ch {ch} publicChannel {publicChannel} antiSpam = {antiSpam}") if not antiSpam and int(ch) != int(publicChannel): logger.debug(f"System: fileMon loop 1 = Preparing to send msg {msg} to ch {ch}") send_message(msg, int(ch), 0, 1) time.sleep(responseDelay) if multiple_interface: for i in range(2, 10): if globals().get(f'interface{i}_enabled'): send_message(msg, int(ch), 0, i) time.sleep(responseDelay) else: logger.warning(f"System: antiSpam or ch {ch} mismatch of pubCh {publicChannel} prevented Alert from FileWatcher 1") else: if not antiSpam and file_monitor_broadcastCh != publicChannel: send_message(msg, int(file_monitor_broadcastCh), 0, 1) time.sleep(responseDelay) if multiple_interface: for i in range(2, 10): if globals().get(f'interface{i}_enabled'): send_message(msg, int(file_monitor_broadcastCh), 0, i) time.sleep(responseDelay) else: logger.warning(f"System: antiSpam prevented Alert from FileWatcher 2") 2 - modules/settings.py around line 337 wasn't splitting the incoming values. So i checked code elsewhere and saw it was splitting on inbound values. Since I am using several channgels for fileMon alerts - I didn't bother testing this with a single value. But this is what worked for me: ##COmmented by todd ORIG file_monitor_broadcastCh = config['fileMon'].getint('broadcastCh', 2) # default 2 file_monitor_broadcastCh = config['fileMon'].get('broadcastCh', '').split(',')##Todd Fix ^^^ Changing the above sections of code is what got the fileMon working for me. The other thing I did was add the full path to the alert.txt file within the config.ini file - I did that because I am starting the code from a script in another directory that is linked to a manager and runs all of our startup stuff. Just to be safe on the CWD - I just hard coded the fullpath to be safe. In closing... I appreciate everyone who has contributed to this project! After being in North Carolina after the hurricanes in the fall of 2024 - All coms were down for a long time. Having meshtastic would have been a game changer for those of us in the field. We def need more people involved and creating cool stuff like this bot helps keep people engaged and excited about tinkering with stuff. Best wishes to family and team. AFRS.US <!-- github-comment-id:2954513617 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/meshing-around#60