Improve alarm reporting
This commit is contained in:
parent
906db90651
commit
4728a18dcb
5
main.go
5
main.go
|
@ -18,8 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MessageNotMoreOftenThanSeconds = 15
|
PersistenceFilename = "hs_wro_last_seen.bin"
|
||||||
PersistenceFilename = "hs_wro_last_seen.bin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TgSender struct {
|
type TgSender struct {
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue