tracker

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalSensorRegistration

func MarshalSensorRegistration(s Sensor) *sensorRegistrationInfo

func MarshalSensorUpdate

func MarshalSensorUpdate(s Sensor) *sensorUpdateInfo

func NewNutsDB

func NewNutsDB(ctx context.Context, path string) (*nutsdbRegistry, error)

Types

type ComparableStringer

type ComparableStringer interface {
	comparable
	String() string
}

type Registry

type Registry interface {
	Open(context.Context, string) error
	Close() error
	SetDisabled(string, bool) error
	SetRegistered(string, bool) error
	IsDisabled(string) bool
	IsRegistered(string) bool
}

type Sensor

type Sensor interface {
	Name() string
	ID() string
	Icon() string
	SensorType() sensorType.SensorType
	DeviceClass() deviceClass.SensorDeviceClass
	StateClass() stateClass.SensorStateClass
	State() interface{}
	Units() string
	Category() string
	Attributes() interface{}
}

Sensor represents an update for a sensor. It reflects the current state of the sensor at the point in time it is used. It provides a bridge between platform/device and HA implementations of what a sensor is.

type SensorMetadata

type SensorMetadata struct {
	Registered bool `json:"Registered"`
	Disabled   bool `json:"Disabled"`
}

type SensorTracker

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

func NewSensorTracker

func NewSensorTracker(ctx context.Context, path string) *SensorTracker

func (*SensorTracker) Get

func (tracker *SensorTracker) Get(id string) (sensorState, error)

Get fetches a sensors current tracked state

func (*SensorTracker) StartWorkers

func (tracker *SensorTracker) StartWorkers(ctx context.Context, updateCh chan interface{})

StartWorkers will call all the sensor worker functions that have been defined for this device.

func (*SensorTracker) Update

func (tracker *SensorTracker) Update(ctx context.Context, sensorUpdate Sensor)

Update will send a sensor update to HA, checking to ensure the sensor is not disabled. It will also update the local registry state based on the response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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