house

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeAwaySeconds    = flag.Int64("timeout", 300, "")
	BleTimeAwaySeconds = flag.Int64("bleTimeout", 15, "")
)

IOT iotDevices

View Source
var (
	HomePrefix  = "/homes/"
	AlivePrefix = "/alive/"
	BlesPrefix  = "/bles/"
)

Functions

func GetManufacturer

func GetManufacturer(mac string) (*string, error)

GetManufacturer to get the vendor of the device

Types

type AssistantRelay

type AssistantRelay struct {
	GoogleAssistant

	QuoteLimitReached *time.Time
	// contains filtered or unexported fields
}

AssistantRelay is an implementation of the GoogleAssistant

func (*AssistantRelay) Call

func (ga *AssistantRelay) Call(command string) (*string, error)

Call assistant relay with command

type ByExecutedAt

type ByExecutedAt struct{ TimeCommands }

ByExecutedAt implements TimeCommands

func (ByExecutedAt) Less

func (s ByExecutedAt) Less(i, j int) bool

Less sorts the array using less than comparison

type DebugAssistantRelay

type DebugAssistantRelay struct {
	GoogleAssistant
}

DebugAssistantRelay is an implementation of the GoogleAssistant which only logs

func (*DebugAssistantRelay) Call

func (ga *DebugAssistantRelay) Call(command string) (*string, error)

Call to log the command

type DebugNotifier

type DebugNotifier struct {
	Notifier
}

DebugNotifier is a log implementation of the Notifier

func (*DebugNotifier) SendNotification

func (fcm *DebugNotifier) SendNotification(title string, message string, topic string) error

SendNotification to log output

type EtcdLeaser added in v0.1.5

type EtcdLeaser struct {
	etcdv3.Lease
}

func (*EtcdLeaser) DeleteLeaseByKey added in v0.1.5

func (leaser *EtcdLeaser) DeleteLeaseByKey(ctx context.Context, key string) error

func (*EtcdLeaser) GetLeaseByKey added in v0.1.5

func (leaser *EtcdLeaser) GetLeaseByKey(ctx context.Context, key string) (*etcdv3.LeaseStatus, *etcdv3.LeaseTimeToLiveResponse, error)

func (*EtcdLeaser) GrantLease added in v0.1.5

func (leaser *EtcdLeaser) GrantLease(ctx context.Context, path, mac string, ttl int64) (string, *etcdv3.LeaseID, error)

type FCMNotifier

type FCMNotifier struct {
	Notifier
	// contains filtered or unexported fields
}

FCMNotifier is an implementation of the Notifier

func (*FCMNotifier) SendNotification

func (fcm *FCMNotifier) SendNotification(title string, message string, topic string) error

SendNotification to GCM topic defined in fcmUrl

type GoogleAssistant

type GoogleAssistant interface {
	Call(command string) (*string, error)
}

GoogleAssistant interface for calling smart home api

func NewAssistant

func NewAssistant() GoogleAssistant

NewAssistant returns a new assistant client

type HomeManager

type HomeManager interface {
	IsHouseEmpty(ctx context.Context, home string) bool

	Devices(w http.ResponseWriter, req *http.Request)
	People(w http.ResponseWriter, req *http.Request)
	HomeEmptyState(w http.ResponseWriter, req *http.Request)
	GetContext() context.Context
	// contains filtered or unexported methods
}

HomeManager manages devices and metric collection

func NewServer

func NewServer(ctx context.Context) HomeManager

NewServer new instance of HomeManager

type Leaser added in v0.1.5

type Leaser interface {
	GrantLease(ctx context.Context, path, mac string, ttl int64) (string, *etcdv3.LeaseID, error)
	DeleteLeaseByKey(ctx context.Context, key string) error
	GetLeaseByKey(ctx context.Context, key string) (*etcdv3.LeaseStatus, *etcdv3.LeaseTimeToLiveResponse, error)
}

func NewEtcdLeaser added in v0.1.5

func NewEtcdLeaser(lease etcdv3.Lease) Leaser

type Notifier

type Notifier interface {
	SendNotification(title string, message string, topic string) error
}

Notifier represents and interface for notification sending

func NewNotifier

func NewNotifier(etcdClient etcdv3.KV) Notifier

NewNotifier returns a new Notifier

type Server

type Server struct {
	pb.UnimplementedHomeDetectorServer
	Kv                 etcdv3.KV
	AssistantClient    GoogleAssistant
	EtcdClient         Leaser
	NotificationClient Notifier

	Logger *slog.Logger
	// contains filtered or unexported fields
}

Server is an implementation of the proto HomeDetectorServer

func NewCustomServer

func NewCustomServer(ctx context.Context, e etcdv3.KV, g GoogleAssistant, n Notifier, handler slog.Handler) Server

NewCustomServer function to allow passing in Server dependencies

func (*Server) Ack

func (s *Server) Ack(ctx context.Context, in *pb.BleRequest) (*pb.Reply, error)

Ack for bluetooth reported MAC addresses

func (*Server) Address

func (s *Server) Address(ctx context.Context, in *pb.AddressRequest) (*pb.Reply, error)

Address Handler for receiving IP/MAC requests

func (*Server) Addresses

func (s *Server) Addresses(ctx context.Context, in *pb.AddressesRequest) (*pb.Reply, error)

Addresses Handler for receiving array of IP/MAC requests

func (*Server) CompleteTimedCommand

func (s *Server) CompleteTimedCommand(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

CompleteTimedCommand Handler for finishing TimedCommands Now!

func (*Server) CompleteTimedCommands

func (s *Server) CompleteTimedCommands(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

CompleteTimedCommands Handler for finishing TimedCommands Now!

func (*Server) CreateTimedCommand

func (s *Server) CreateTimedCommand(ctx context.Context, request *pb.TimedCommands) (*pb.Reply, error)

CreateTimedCommand Handler for creating TimedCommands!

func (*Server) DeleteCommandQueue

func (s *Server) DeleteCommandQueue(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

DeleteCommandQueue Deletes an entire job from CommandQueue

func (*Server) DeleteDevice

func (s *Server) DeleteDevice(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

DeleteDevice Handler for deleting Devices

func (*Server) DeleteTimedCommand

func (s *Server) DeleteTimedCommand(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

DeleteTimedCommand Deletes an Individual Timed Command from the CommandQueue

func (*Server) Devices

func (s *Server) Devices(w http.ResponseWriter, req *http.Request)

Devices API endpoint to determine devices status

func (*Server) GetContext added in v0.1.5

func (s *Server) GetContext() context.Context

func (*Server) GetDevice added in v0.1.5

func (s *Server) GetDevice(id string) (*pb.Devices, error)

func (*Server) GetPeopleInHouses added in v0.1.5

func (s *Server) GetPeopleInHouses(ctx context.Context, home string) ([]string, error)

func (*Server) GrantLease added in v0.1.5

func (s *Server) GrantLease(ctx context.Context, data map[string]string, ttl int64) error

func (*Server) HomeEmptyState

func (s *Server) HomeEmptyState(w http.ResponseWriter, req *http.Request)

HomeEmptyState API endpoint to determine house empty status

func (*Server) HouseEmpty added in v0.1.5

func (s *Server) HouseEmpty(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)

UpdateDevice Handler for updating Devices

func (*Server) IsHouseEmpty

func (s *Server) IsHouseEmpty(ctx context.Context, home string) bool

func (*Server) ListCommandQueue

func (s *Server) ListCommandQueue(ctx context.Context, _ *empty.Empty) (*pb.CQsResponse, error)

ListCommandQueue Handler for Listing all the TimedCommands

func (*Server) ListDevices

func (s *Server) ListDevices(ctx context.Context, _ *empty.Empty) (*pb.DevicesResponse, error)

ListDevices lists all the Devices

func (*Server) ListPeople added in v0.1.5

func (s *Server) ListPeople(ctx context.Context, _ *emptypb.Empty) (*pb.PeopleResponse, error)

func (*Server) ListPeopleRequest added in v0.1.5

func (s *Server) ListPeopleRequest(ctx context.Context) (*pb.PeopleResponse, error)

func (*Server) ListTimedCommands

func (s *Server) ListTimedCommands(ctx context.Context, _ *empty.Empty) (*pb.TCsResponse, error)

ListTimedCommands lists all the TimedCommands basically the bles

func (*Server) People

func (s *Server) People(w http.ResponseWriter, req *http.Request)

People API endpoint to determine person device status

func (*Server) ProcessIncomingAddress

func (s *Server) ProcessIncomingAddress(ctx context.Context, in *pb.AddressRequest) (*pb.Reply, error)

func (*Server) ReadBleConfig

func (s *Server) ReadBleConfig() (map[string]*pb.BleDevices, error)

func (*Server) ReadHomesConfig

func (s *Server) ReadHomesConfig() (map[string]*bool, error)

func (*Server) ReadNetworkConfig

func (s *Server) ReadNetworkConfig() (map[string]*pb.Devices, error)

func (*Server) RegisterBleMetric added in v0.1.5

func (s *Server) RegisterBleMetric(item *pb.BleDevices, agent string)

func (*Server) RegisterMetric

func (s *Server) RegisterMetric(item *pb.Devices)

func (*Server) ToggleHouseStatus

func (s *Server) ToggleHouseStatus(home string, houseEmpty bool) error

func (*Server) TogglePerson added in v0.1.5

func (s *Server) TogglePerson(ctx context.Context, device *pb.Devices) (*pb.Reply, error)

func (*Server) UpdateDevice

func (s *Server) UpdateDevice(ctx context.Context, request *pb.Devices) (*pb.Reply, error)

UpdateDevice Handler for updating Devices

func (*Server) WriteNetworkDevice added in v0.1.5

func (s *Server) WriteNetworkDevice(ctx context.Context, item *pb.Devices) error

type TimeCommands

type TimeCommands []*pb.TimedCommands

TimeCommands implements sort.Interface by providing Less and using the Len and

func (TimeCommands) Len

func (s TimeCommands) Len() int

Len returns length of TimeCommands Array

func (TimeCommands) Swap

func (s TimeCommands) Swap(i, j int)

Swap sorts the array using equivalent comparison

Jump to

Keyboard shortcuts

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