Closed M1K3-NL closed 3 years ago
Maybe any idea?
I cannot reproduce it, I run the app now, and see many messages with multiple capcodes:
If you can share your capcodes.txt file, I can check. Maybe it's not a plain text ansi file?
I don't know if you can download it, but here it is.
Maybe any idea also how to filter 002029568 and 002029569 out of the capcode part. That is: If a notification comes in with three capcodes, including 002029568 that it doesn't appear and only the other two do, because I don't need that group code and is only extra junk in the capcode list if it's on the index.html or on the print on the terminal.
Your capcodes file works good, I did not find problems. If you can copy full FLEX message lines from the terminal that cause the error, I will check.
For the groups filtering, the easiest way without big program changes, is to add additional file for ignored capcodes. Add this code after "print("Capcodes: {} records loaded".format(len(capcodesDict)))" line:
pythoncapcodesIgnore = loadCapcodesDict(dir_path + os.sep + "capcodes_ignore.txt")
print("Capcodes ignore: {} records loaded".format(len(capcodesIgnore)))
Add this code after "if checkFilter(capcode) is False: continue" line:
if capcode in capcodesIgnore:
print("Message {} to {} ignored".format(message, capcode))
continue
Fill the file "capcodes_ignore.txt" using the same way. Then messages to selected groups will be always skipped (but it can cause a problem if the group is the only one receiver of the message).
FLEX|2020-10-16 19:42:08|1600/2/K/A|10.078|002029568 000220999 000220113 000126999|ALN|A2 10113 Rit 122274 Pontweg Den Burg
Will show as:
A2 10113 Rit 122274 Pontweg Den Burg
002029568 000220999 000220113 000126999
But 002029568 is added to the capcodes.txt, so that one should show a text instead of only capcodes, but it simply doesn't do it... 😒😕
And I want to filter 002029568 and 002029569 out, but I still want to receive the message but simple only with the capcodes behind it. But if that's not possible, then I will rename the capcode to something else.
Are you Dutch by any chance? So we can continue in Dutch 😅
I see now, messages grouping is a new feature of the last multimon-ng. Install older version (I use 1.1.7), should be working fine. I will add this later, nobody asked before.
Ik ben geen nederlander, maar woon in Nederland ;)
Okay I will look into installing an older multimon later and inform you how it went 🙂🙂
Sadly it's crashing now since I downgraded Multimon.
Okay. The problem with the capcode has fixed with MNG 1.7. But now the issue I get: When the data is pushed to the index webpage, it will be combined, but I don't use that because I send everything to Telegram.
So what's happening now, is that the messages get duplicated with every capcode.
And this is the way how I filter to get it to Telegram. So if the line contains a city name, it will Telegram it.
So or somehow I need to find out how to combine them between the part it strips the FLEX line and send it to Telegram or I need to find something how to filter it. Because I need both capcodes to be in one Telegram message.
So now it is:
P 1 BDH-02 OMS Geverifieerd (brandmelding OMS) Sticht. Constant Rebecqueplein De Constant Rebecqu SGRAVH 157830
Brandweer Haaglanden (Monitorcode) (001503902)
P 1 BDH-02 OMS Geverifieerd (brandmelding OMS) Sticht. Constant Rebecqueplein De Constant Rebecqu SGRAVH 157830
Brandweer Haaglanden Centrum (Kazernealarm) (001500142)
And it needs to become:
P 1 BDH-02 OMS Geverifieerd (brandmelding OMS) Sticht. Constant Rebecqueplein De Constant Rebecqu SGRAVH 157830
Brandweer Haaglanden (Monitorcode) (001503902)
Brandweer Haaglanden Centrum (Kazernealarm) (001500142)
Hi,
I pushed a fix for multimon-ng 1.1.9 now, should be working.
About posting to the Telegram, you can append your code to the postToServer method, that was made especially to the posting to the 3rd party servers. No messages should be duplicated.
Hi, thanks for the update. The issue is I don't have any experience with the PostToServer method. I tried some things, but it didn't work. Because I don't have anything that could post the JSON info in a respectable way to Telegram. I don't work based on capcodes, I work based on city names:
It's not mandatory to use JSON, you can access all fields directly. I added now message_raw parameter to the MessageItem, that contains the original line from multimon-ng. You can use something like this in postToServer:
if "DELFT" in self.message_raw:
requests.post(url + '<b>' + self.body + '</b>' + self.receivers + '</i>')
PS: Instead of duplicating the lines "DELFT" and "Delft", it will be shorter for you to write:
if "delft" in self.message_raw.lower():
...
Then you don't need to parse twice different letter registers.
I did that because the normale FIRE and AMBU messages contained DELFT and the Lifeliner was just Delft. And if it was DELFT it didn't recognize Delft. That wasn't a big deal, because sometimes you have the "delftsestraat rotterdam" and I don't want that one, because it isn't Delft. So i'm still working a lot on it to make it better and better. I used to use Pagermon, but when a messages like 0000000000 00000000000 111111111111 0000000000000 came through it crashed xD
Yes, that makes sense. You can take some ideas also from this thread: https://stackoverflow.com/questions/5319922/python-check-if-word-is-in-a-string
And maybe it's better to parse fields self.body and self.receivers separately, it will be more flexible.
I'll check that out, otherwise, I'll return back to the old way :-)
Hi man, I figured the part out and it's currently working like a charm! Thanks for your great assistance!
Only sadly the date is UTC due to shitty MultimonNG and not dutch time.
Good to know that it works 👍 I closing this issue now.
You can remove the line 658 "msg.timestamp = timestamp", then local Raspberry Pi timestamp will be used in MessageItem.
I have added all the required capcodes to the capcodes.txt, but if there is more than one capcode in a message, it will not display them. I've tried everything, but it doesn't work.
So if you have one capcode with a message ex: 001100220 and you added this to the capcode file, it will show the name. ex: 001100220,TestCapcode Will show: TestCapcode (001100220) But ex: 001100220 002211550 won't show it. And the capcode 002029568 and 002029569 are GROUP IDs (https://monitor.p2000alarm.nl/capcode/2029568 and https://monitor.p2000alarm.nl/capcode/2029569) but they show as a normal capcode. Can I somehow filter these out?
Any idea of how this can work?