Improve alarm reporting

command_handler
Michał Rudowicz 2024-03-06 19:39:43 +01:00
rodzic 906db90651
commit 4728a18dcb
2 zmienionych plików z 14 dodań i 4 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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: