Documentation
¶
Index ¶
- Variables
- func GetManufacturer(mac string) (*string, error)
- type AssistantRelay
- type ByExecutedAt
- type DebugAssistantRelay
- type DebugNotifier
- type EtcdLeaser
- func (leaser *EtcdLeaser) DeleteLeaseByKey(ctx context.Context, key string) error
- func (leaser *EtcdLeaser) GetLeaseByKey(ctx context.Context, key string) (*etcdv3.LeaseStatus, *etcdv3.LeaseTimeToLiveResponse, error)
- func (leaser *EtcdLeaser) GrantLease(ctx context.Context, path, mac string, ttl int64) (string, *etcdv3.LeaseID, error)
- type FCMNotifier
- type GoogleAssistant
- type HomeManager
- type Leaser
- type Notifier
- type Server
- func (s *Server) Ack(ctx context.Context, in *pb.BleRequest) (*pb.Reply, error)
- func (s *Server) Address(ctx context.Context, in *pb.AddressRequest) (*pb.Reply, error)
- func (s *Server) Addresses(ctx context.Context, in *pb.AddressesRequest) (*pb.Reply, error)
- func (s *Server) CompleteTimedCommand(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) CompleteTimedCommands(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) CreateTimedCommand(ctx context.Context, request *pb.TimedCommands) (*pb.Reply, error)
- func (s *Server) DeleteCommandQueue(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) DeleteDevice(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) DeleteTimedCommand(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) Devices(w http.ResponseWriter, req *http.Request)
- func (s *Server) GetContext() context.Context
- func (s *Server) GetDevice(id string) (*pb.Devices, error)
- func (s *Server) GetPeopleInHouses(ctx context.Context, home string) ([]string, error)
- func (s *Server) GrantLease(ctx context.Context, data map[string]string, ttl int64) error
- func (s *Server) HomeEmptyState(w http.ResponseWriter, req *http.Request)
- func (s *Server) HouseEmpty(ctx context.Context, request *pb.StringRequest) (*pb.Reply, error)
- func (s *Server) IsHouseEmpty(ctx context.Context, home string) bool
- func (s *Server) ListCommandQueue(ctx context.Context, _ *empty.Empty) (*pb.CQsResponse, error)
- func (s *Server) ListDevices(ctx context.Context, _ *empty.Empty) (*pb.DevicesResponse, error)
- func (s *Server) ListPeople(ctx context.Context, _ *emptypb.Empty) (*pb.PeopleResponse, error)
- func (s *Server) ListPeopleRequest(ctx context.Context) (*pb.PeopleResponse, error)
- func (s *Server) ListTimedCommands(ctx context.Context, _ *empty.Empty) (*pb.TCsResponse, error)
- func (s *Server) People(w http.ResponseWriter, req *http.Request)
- func (s *Server) ProcessIncomingAddress(ctx context.Context, in *pb.AddressRequest) (*pb.Reply, error)
- func (s *Server) ReadBleConfig() (map[string]*pb.BleDevices, error)
- func (s *Server) ReadHomesConfig() (map[string]*bool, error)
- func (s *Server) ReadNetworkConfig() (map[string]*pb.Devices, error)
- func (s *Server) RegisterBleMetric(item *pb.BleDevices, agent string)
- func (s *Server) RegisterMetric(item *pb.Devices)
- func (s *Server) ToggleHouseStatus(home string, houseEmpty bool) error
- func (s *Server) TogglePerson(ctx context.Context, device *pb.Devices) (*pb.Reply, error)
- func (s *Server) UpdateDevice(ctx context.Context, request *pb.Devices) (*pb.Reply, error)
- func (s *Server) WriteNetworkDevice(ctx context.Context, item *pb.Devices) error
- type TimeCommands
Constants ¶
This section is empty.
Variables ¶
var ( TimeAwaySeconds = flag.Int64("timeout", 300, "") BleTimeAwaySeconds = flag.Int64("bleTimeout", 15, "") )
IOT iotDevices
var ( HomePrefix = "/homes/" AlivePrefix = "/alive/" BlesPrefix = "/bles/" )
Functions ¶
func GetManufacturer ¶
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
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
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
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)
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 ¶
GoogleAssistant interface for calling smart home api
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
type Notifier ¶
Notifier represents and interface for notification sending
func NewNotifier ¶
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) 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 ¶
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 (*Server) GetPeopleInHouses ¶ added in v0.1.5
func (*Server) GrantLease ¶ added in v0.1.5
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
UpdateDevice Handler for updating Devices
func (*Server) ListCommandQueue ¶
ListCommandQueue Handler for Listing all the TimedCommands
func (*Server) ListDevices ¶
ListDevices lists all the Devices
func (*Server) ListPeople ¶ added in v0.1.5
func (*Server) ListPeopleRequest ¶ added in v0.1.5
func (*Server) ListTimedCommands ¶
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 (*Server) ReadBleConfig ¶
func (s *Server) ReadBleConfig() (map[string]*pb.BleDevices, error)
func (*Server) ReadNetworkConfig ¶
func (*Server) RegisterBleMetric ¶ added in v0.1.5
func (s *Server) RegisterBleMetric(item *pb.BleDevices, agent string)
func (*Server) RegisterMetric ¶
func (*Server) ToggleHouseStatus ¶
func (*Server) TogglePerson ¶ added in v0.1.5
func (*Server) UpdateDevice ¶
UpdateDevice Handler for updating Devices
type TimeCommands ¶
type TimeCommands []*pb.TimedCommands
TimeCommands implements sort.Interface by providing Less and using the Len and
func (TimeCommands) Swap ¶
func (s TimeCommands) Swap(i, j int)
Swap sorts the array using equivalent comparison