1
0
Fork 0

Improve alarm reporting

This commit is contained in:
Michał Rudowicz 2024-03-06 19:39:43 +01:00
parent 906db90651
commit 4728a18dcb
2 changed files with 14 additions and 4 deletions

View File

@ -18,7 +18,6 @@ import (
) )
const ( const (
MessageNotMoreOftenThanSeconds = 15
PersistenceFilename = "hs_wro_last_seen.bin" PersistenceFilename = "hs_wro_last_seen.bin"
) )
@ -153,7 +152,7 @@ func main() {
Consume(NotifyViaHTTP( Consume(NotifyViaHTTP(
SendToTg(tgEvents, tgSender, &wg, log.New(os.Stderr, "SendToTg", log.Lmicroseconds), tpl), SendToTg(tgEvents, tgSender, &wg, log.New(os.Stderr, "SendToTg", log.Lmicroseconds), tpl),
&wg, &wg,
logger, log.New(os.Stderr, "HTTPNotify", log.Lmicroseconds),
)) ))
go CloseSatelOnCtrlC(s) go CloseSatelOnCtrlC(s)

View File

@ -12,6 +12,9 @@ import (
const ( const (
ArmedPartition_Armed = true ArmedPartition_Armed = true
ArmedPartition_Unrmed = false ArmedPartition_Unrmed = false
PartitionAlarm_Alarm = false
PartitionAlarm_AlarmCancelled = true
) )
type SatelNameGetter interface { 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 { func (self SatelMsgContent) FormatEvent() string {
switch self.SatelEvent.Type { switch self.SatelEvent.Type {
case satel.ZoneViolation: case satel.ZoneViolation:
@ -134,7 +145,7 @@ func (self SatelMsgContent) FormatEvent() string {
case satel.PartitionBlockedForGuardRound: case satel.PartitionBlockedForGuardRound:
return fmt.Sprintf("%s: %t", self.SatelEvent.Type.String(), self.SatelEvent.Value) return fmt.Sprintf("%s: %t", self.SatelEvent.Type.String(), self.SatelEvent.Value)
case satel.PartitionAlarm: case satel.PartitionAlarm:
return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value)) return getPartitionAlarmStatus(self.SatelEvent.Value)
case satel.PartitionFireAlarm: case satel.PartitionFireAlarm:
return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value)) return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value))
case satel.PartitionAlarmMemory: case satel.PartitionAlarmMemory: