state

package
v0.0.0-...-566c99a Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Snmp snmp.GetterSetter

	Clock clock.Clock
	TZ    *time.Location

	Sunriser sunrise.Sunriser
	// time of the SunriseTime
	SunriseTime time.Time
	// time of the SunsetTime
	SunsetTime time.Time
	// SunriseTime and SunsetTime are date specific, therefore need to
	// be updated. `SunsetUpdateDate` used as a cache mark
	// indicating the date of values. if today != SunsetUpdateDate
	// values need to be updated
	SunsetUpdateDate string

	Pirs       map[string]*Pir
	TimeoutOid string
}

func (*App) BackgroundCheck

func (a *App) BackgroundCheck()

func (*App) MaybeTurnPirOff

func (a *App) MaybeTurnPirOff(pir *Pir) error

func (*App) MaybeTurnPirOn

func (a *App) MaybeTurnPirOn(pir *Pir, newState relayState) error

func (*App) PirByName

func (a *App) PirByName(name string) *Pir

func (*App) ScheduleBackgroundUpdater

func (a *App) ScheduleBackgroundUpdater(doneCh <-chan os.Signal, tickInterval time.Duration)

func (*App) UpdatePirState

func (a *App) UpdatePirState(pir *Pir, data map[string]int64) error

func (*App) UpdateSchedule

func (a *App) UpdateSchedule()

func (*App) UpdateState

func (a *App) UpdateState() error

func (*App) ValidTime

func (a *App) ValidTime() bool

ValidTime returns True if current time is between SunsetTime and SunriseTime

type Pir

type Pir struct {
	Name string
	// remote State of the PIR
	State Unit
	// PIR is Enabled if pin set to 0 (MANUAL)
	Enabled Unit
	// current relayState of the Relay
	Relay Unit
	// timestamp when relayState changed to ON
	// used for tracking a single session duration
	TurnedOn   time.Time
	LastChange time.Time
	Timeout    time.Duration

	// indicates whether time schedule is Enabled
	TimeSchedule bool

	// Duration of lights being on
	DurationMetric *metrics.Summary
}

func NewPir

func NewPir(name, stateOid, modeOid, switchOid string, timeSchedule bool) *Pir

type Unit

type Unit struct {
	Oid   string
	Value int64
}

Jump to

Keyboard shortcuts

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