icof

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 2 Imported by: 0

README

icof

in case of fire

love

Due to the ongoing global pandemic I started to work mostly from home. Beside my job as a software engineer I am also a volunteer firefighter in my local community. This means that I'm on call for emergencies 24/7, also during my daily work as a SE. When I am in the office and get a call, I can speak to my colleagues in seconds that I have to go (Or they just see me running to my car). In booth cases they are informed that I am afk and can probably re-schedule or take over meetings for me. When working from home I want to send an absence notification to my colleagues. Chatting my 2-4 colleagues can be time-consuming. Well, I am an engineer. I can automate this in combination with a big red button. I like big red buttons.

gocrazy installation

First you need to plug-in the Pi SD card into your PC. If you have already installed an OS like raspbian on this SD card, I recommend flashing it. With the fdisk utility you can delete all existing partitions.

Now you can follow the go-krazy installation guide: https://github.com/gokrazy/gokrazy#installation

You can update your gokrazy installation via the web endpoint:

gokr-packer -update yes -hostname 192.168.178.49 -serial_console=disabled ./cmd/icof-cmd

Configuration

To run icof on gokrazy you have to create a startup configuration and place it in the following directory on the permanent data partition of your gocrazy installation: /perm/icof/start-config.json.

Configuration:

{
  "email_config": {
    "host": "",
    "port": 0,
    "username": "",
    "password": "",
    "from_email_address": ""
  },
  "email_receiver_config": {
    "alert_subject": "",
    "resolve_subject": "",
    "receivers": [
      {
        "name": "",
        "alert_template_message": "",
        "resolve_template_message": "",
        "addresses": [
          {
            "email": "",
            "name": "",
            "surname": ""
          }
        ]
      }
    ]
  }
}

Circuit

The circuit uses a pull down resistor. This will pull down the input signal at the GPIO pin to LOW if the switch is pressed and the power circuit is interrupted.

  • Emergency switch is wired in NC (normally closed).
  • A 10kΩ resistor is used
  • 3,3V power pin is enough

circuit

Shopping List

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, c Config) error

Run will handle all incoming alerts. It also considers to not send an alert if the last stored state was an alert and the current received state is an alert.

Types

type Config

type Config struct {
	Observer   Observer
	Notifiers  []Notifier
	Repository StateRepository
	Logger     *log.Logger
}

type Notifier

type Notifier interface {
	Alert(ctx context.Context) error
	Resolve(ctx context.Context) error
	Name() string
}

type Observer

type Observer interface {
	Observe(context.Context, chan<- ObserverState)
}

Observer is responsible to send states of an occurring alert with true as the alert started and false when the alert is resolved.

type ObserverState

type ObserverState bool
const (
	Alert    ObserverState = true
	Resolved ObserverState = false
)

func (ObserverState) String

func (o ObserverState) String() string

type StateRepository

type StateRepository interface {
	Save(ctx context.Context, state ObserverState) error
	GetLatest(ctx context.Context) (ObserverState, error)
}

Directories

Path Synopsis
cmd
Package mock_icof is a generated GoMock package.
Package mock_icof is a generated GoMock package.
pkg
notifier/mock-email
Package mock_notifier is a generated GoMock package.
Package mock_notifier is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL