occupancysensor

package
v0.0.0-...-97303ad Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions = []resource.Option{
	WithInitialOccupancy(&traits.Occupancy{}),
}

DefaultModelOptions holds the default options for the model.

Functions

func WithInitialOccupancy

func WithInitialOccupancy(occupancy *traits.Occupancy) resource.Option

WithInitialOccupancy returns an option that configures the model to initialise with the given occupancy.

func WithOccupancyOption

func WithOccupancyOption(opts ...resource.Option) resource.Option

WithOccupancyOption configures the occupancy resource of the model.

func WithOccupancySensorApiClientFactory

func WithOccupancySensorApiClientFactory(f func(name string) (traits.OccupancySensorApiClient, error)) router.Option

WithOccupancySensorApiClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithOccupancySensorInfoClientFactory

func WithOccupancySensorInfoClientFactory(f func(name string) (traits.OccupancySensorInfoClient, error)) router.Option

WithOccupancySensorInfoClientFactory instructs the router to create a new client the first time Get is called for that name.

Types

type ApiRouter

ApiRouter is a traits.OccupancySensorApiServer that allows routing named requests to specific traits.OccupancySensorApiClient

func NewApiRouter

func NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type traits.OccupancySensorApiClient.

func (*ApiRouter) AddOccupancySensorApiClient

func (r *ApiRouter) AddOccupancySensorApiClient(name string, client traits.OccupancySensorApiClient) traits.OccupancySensorApiClient

func (*ApiRouter) GetOccupancy

func (r *ApiRouter) GetOccupancy(ctx context.Context, request *traits.GetOccupancyRequest) (*traits.Occupancy, error)

func (*ApiRouter) GetOccupancySensorApiClient

func (r *ApiRouter) GetOccupancySensorApiClient(name string) (traits.OccupancySensorApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

func (*ApiRouter) PullOccupancy

func (*ApiRouter) Register

func (r *ApiRouter) Register(server grpc.ServiceRegistrar)

func (*ApiRouter) RemoveOccupancySensorApiClient

func (r *ApiRouter) RemoveOccupancySensorApiClient(name string) traits.OccupancySensorApiClient

type ApiWrapper

type ApiWrapper struct {
	traits.OccupancySensorApiClient
	// contains filtered or unexported fields
}

func WrapApi

WrapApi adapts a traits.OccupancySensorApiServer and presents it as a traits.OccupancySensorApiClient

func (*ApiWrapper) Unwrap

func (w *ApiWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*ApiWrapper) UnwrapServer

func (w *ApiWrapper) UnwrapServer() traits.OccupancySensorApiServer

UnwrapServer returns the underlying server instance.

func (*ApiWrapper) UnwrapService

func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type InfoRouter

InfoRouter is a traits.OccupancySensorInfoServer that allows routing named requests to specific traits.OccupancySensorInfoClient

func NewInfoRouter

func NewInfoRouter(opts ...router.Option) *InfoRouter

func (*InfoRouter) Add

func (r *InfoRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type traits.OccupancySensorInfoClient.

func (*InfoRouter) AddOccupancySensorInfoClient

func (r *InfoRouter) AddOccupancySensorInfoClient(name string, client traits.OccupancySensorInfoClient) traits.OccupancySensorInfoClient

func (*InfoRouter) DescribeOccupancy

func (r *InfoRouter) DescribeOccupancy(ctx context.Context, request *traits.DescribeOccupancyRequest) (*traits.OccupancySupport, error)

func (*InfoRouter) GetOccupancySensorInfoClient

func (r *InfoRouter) GetOccupancySensorInfoClient(name string) (traits.OccupancySensorInfoClient, error)

func (*InfoRouter) HoldsType

func (r *InfoRouter) HoldsType(client any) bool

func (*InfoRouter) Register

func (r *InfoRouter) Register(server grpc.ServiceRegistrar)

func (*InfoRouter) RemoveOccupancySensorInfoClient

func (r *InfoRouter) RemoveOccupancySensorInfoClient(name string) traits.OccupancySensorInfoClient

type InfoWrapper

type InfoWrapper struct {
	traits.OccupancySensorInfoClient
	// contains filtered or unexported fields
}

func WrapInfo

WrapInfo adapts a traits.OccupancySensorInfoServer and presents it as a traits.OccupancySensorInfoClient

func (*InfoWrapper) Unwrap

func (w *InfoWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*InfoWrapper) UnwrapServer

func (w *InfoWrapper) UnwrapServer() traits.OccupancySensorInfoServer

UnwrapServer returns the underlying server instance.

func (*InfoWrapper) UnwrapService

func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type Model

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

func NewModel

func NewModel(opts ...resource.Option) *Model

func (*Model) GetOccupancy

func (m *Model) GetOccupancy(opts ...resource.ReadOption) (*traits.Occupancy, error)

func (*Model) PullOccupancy

func (m *Model) PullOccupancy(ctx context.Context, opts ...resource.ReadOption) <-chan PullOccupancyChange

func (*Model) SetOccupancy

func (m *Model) SetOccupancy(occupancy *traits.Occupancy, opts ...resource.WriteOption) (*traits.Occupancy, error)

SetOccupancy updates the known occupancy state for this device

type ModelOption

type ModelOption interface {
	resource.Option
	// contains filtered or unexported methods
}

ModelOption defined the base type for all options that apply to this traits model.

type ModelServer

type ModelServer struct {
	traits.UnimplementedOccupancySensorApiServer
	// contains filtered or unexported fields
}

func NewModelServer

func NewModelServer(model *Model) *ModelServer

func (*ModelServer) GetOccupancy

func (*ModelServer) PullOccupancy

func (*ModelServer) Register

func (s *ModelServer) Register(server grpc.ServiceRegistrar)

func (*ModelServer) Unwrap

func (s *ModelServer) Unwrap() any

type PullOccupancyChange

type PullOccupancyChange struct {
	Value      *traits.Occupancy
	ChangeTime time.Time
}

Jump to

Keyboard shortcuts

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