Fire alarm notifications
This commit is contained in:
parent
4c50b33e1c
commit
a03de0648c
4
go.mod
4
go.mod
|
|
@ -3,16 +3,16 @@ module alarm_bot
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240306182245-7ac13d8e4733
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20260301150932-91a5a9ae6f2f
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
|
||||
github.com/stretchr/testify v1.8.4
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/probakowski/go-satel => git.sr.ht/~michalr/go-satel v0.0.0-20211120120346-bed9818777ce
|
||||
|
|
|
|||
18
go.sum
18
go.sum
|
|
@ -1,25 +1,12 @@
|
|||
git.sr.ht/~michalr/go-satel v0.0.0-20240303214713-fcbf3bd29f6f h1:+jaUKR+4mKlJASOlLBfHxFr4qXfhubYbBM37fepIJug=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240303214713-fcbf3bd29f6f/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240304192450-999413ca9994 h1:uIDVu4eIJKT4AE0cckgId143xR8vlKFKSVBfQFKPHRg=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240304192450-999413ca9994/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240304210948-c93d9db530fe h1:huAwK9SgnCqgrbEn5p2nBvkoAAfl4icoGj2zXWl1ItQ=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240304210948-c93d9db530fe/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240305205259-053187c5d1a0 h1:E5gMgMCgaZltNC9nM5s8gouzbO/X51zymT7+S4LNvvM=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240305205259-053187c5d1a0/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240306065228-8979c2dd1ed8 h1:edwd27GRcof9fC93rBv0yTolaEcs5AlFmWyVquYKRK0=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240306065228-8979c2dd1ed8/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240306182245-7ac13d8e4733 h1:pvnT5ZT9LlY2/s8PBPA0PJz3Sw63nGLU18o6MQMzJUM=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20240306182245-7ac13d8e4733/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20260301150932-91a5a9ae6f2f h1:3TaQ9tx82pUblJuRCq3YwrWUU1GSvN0/OXivGl+mjHE=
|
||||
git.sr.ht/~michalr/go-satel v0.0.0-20260301150932-91a5a9ae6f2f/go.mod h1:J/Bnb8xBRmuEq03dvJKLf3eCwizIhGuomUY4lVGa/6U=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
|
@ -53,7 +40,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
|||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ const (
|
|||
|
||||
PartitionAlarm_Alarm = true
|
||||
PartitionAlarm_AlarmCancelled = false
|
||||
|
||||
PartitionFireAlarm_Alarm = true
|
||||
PartitionFireAlarm_AlarmCancelled = false
|
||||
)
|
||||
|
||||
type SatelNameGetter interface {
|
||||
|
|
@ -101,6 +104,14 @@ func getPartitionAlarmStatus(v bool) string {
|
|||
}
|
||||
}
|
||||
|
||||
func getPartitionFireAlarmStatus(v bool) string {
|
||||
if v == PartitionFireAlarm_Alarm {
|
||||
return "🔥🔥 FIRE ALARM! 🔥🔥"
|
||||
} else {
|
||||
return "Fire alarm cancelled 🧯"
|
||||
}
|
||||
}
|
||||
|
||||
func (self SatelMsgContent) FormatEvent() string {
|
||||
switch self.SatelEvent.Type {
|
||||
case satel.ZoneViolation:
|
||||
|
|
@ -144,7 +155,7 @@ func (self SatelMsgContent) FormatEvent() string {
|
|||
case satel.PartitionAlarm:
|
||||
return getPartitionAlarmStatus(self.SatelEvent.Value)
|
||||
case satel.PartitionFireAlarm:
|
||||
return fmt.Sprintf("%s: %s", self.SatelEvent.Type.String(), getEmojiWhenTrueIsBad(self.SatelEvent.Value))
|
||||
return getPartitionFireAlarmStatus(self.SatelEvent.Value)
|
||||
case satel.PartitionAlarmMemory:
|
||||
return fmt.Sprintf("%s: %t", self.SatelEvent.Type.String(), self.SatelEvent.Value)
|
||||
case satel.PartitionFireAlarmMemory:
|
||||
|
|
|
|||
Loading…
Reference in New Issue