From 4728a18dcbcc6541d31b3fc967b5b6eb871a3318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Rudowicz?= Date: Wed, 6 Mar 2024 19:39:43 +0100 Subject: [PATCH] Improve alarm reporting --- main.go | 5 ++--- message_contents.go | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 03687c3..8aa5481 100644 --- a/main.go +++ b/main.go @@ -18,8 +18,7 @@ import ( ) const ( - MessageNotMoreOftenThanSeconds = 15 - PersistenceFilename = "hs_wro_last_seen.bin" + PersistenceFilename = "hs_wro_last_seen.bin" ) type TgSender struct { @@ -153,7 +152,7 @@ func main() { Consume(NotifyViaHTTP( SendToTg(tgEvents, tgSender, &wg, log.New(os.Stderr, "SendToTg", log.Lmicroseconds), tpl), &wg, - logger, + log.New(os.Stderr, "HTTPNotify", log.Lmicroseconds), )) go CloseSatelOnCtrlC(s) diff --git a/message_contents.go b/message_contents.go index 79f7ca8..21b71b0 100644 --- a/message_contents.go +++ b/message_contents.go @@ -12,6 +12,9 @@ import ( const ( ArmedPartition_Armed = true ArmedPartition_Unrmed = false + + PartitionAlarm_Alarm = false + PartitionAlarm_AlarmCancelled = true ) type SatelNameGetter interface { @@ -93,6 +96,14 @@ func getArmedPartitionStatus(v bool) string { } } +func getPartitionAlarmStatus(v bool) string { + if v == PartitionAlarm_Alarm { + return "⚠️⚠️ ALARM! ⚠️⚠️" + } else { + return "Alarm cancelled" + } +} + func (self SatelMsgContent) FormatEvent() string { switch self.SatelEvent.Type { case satel.ZoneViolation: @@ -134,7 +145,7 @@ func (self SatelMsgContent) FormatEvent() string { case satel.PartitionBlockedForGuardRound: return fmt.Sprintf("%s: %t", self.SatelEvent.Type.String(), self.SatelEvent.Value) case satel.PartitionAlarm: - return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value)) + return getPartitionAlarmStatus(self.SatelEvent.Value) case satel.PartitionFireAlarm: return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value)) case satel.PartitionAlarmMemory: