relay

package
v0.0.0-...-a79553f Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device interface {
	Name() string
	On()
	Off()
	State() (bool, error)
	Number() int
	TypeInfo() DeviceTypeInfo
}

type DeviceCategory

type DeviceCategory int
const (
	Fans DeviceCategory = iota
	Lights
)

func (DeviceCategory) String

func (d DeviceCategory) String() string

type DeviceOpt

type DeviceOpt func(s *Service)

func WithDevice

func WithDevice(device Device) DeviceOpt

type DeviceTypeInfo

type DeviceTypeInfo struct {
	Category DeviceCategory
}

type Normality

type Normality uint8
const (
	NormallyOpen Normality = iota
	NormallyClosed
	Undefined Normality = 8
)

func (Normality) String

func (n Normality) String() string

type Relay

type Relay struct {
	Normality  Normality
	DeviceName string
	DeviceTypeInfo
	// contains filtered or unexported fields
}

func NewRelay

func NewRelay(deviceName string, pinNumber int, relayNumber int, normality Normality, category DeviceCategory) *Relay

func (*Relay) Name

func (r *Relay) Name() string

func (*Relay) Number

func (r *Relay) Number() int

func (*Relay) Off

func (r *Relay) Off()

func (*Relay) On

func (r *Relay) On()

func (*Relay) State

func (r *Relay) State() (bool, error)

func (*Relay) TypeInfo

func (r *Relay) TypeInfo() DeviceTypeInfo

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...DeviceOpt) *Service

func (*Service) DeviceByRelay

func (s *Service) DeviceByRelay(number int) (Device, error)

func (*Service) Devices

func (s *Service) Devices() map[string]Device

func (*Service) Fans

func (s *Service) Fans() Device

func (*Service) Lights

func (s *Service) Lights() Device

func (*Service) SetAllTo

func (s *Service) SetAllTo(signal Signal)

type Signal

type Signal uint8
const (
	Off Signal = iota
	On
)

Jump to

Keyboard shortcuts

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