internal

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.9.0"

Version is the go-ha release this build corresponds to.

Variables

View Source
var (
	// ErrUnauthorized reports a token Home Assistant refused.
	ErrUnauthorized = errors.New("unauthorized")
	// ErrEntityNotFound reports an entity Home Assistant does not know about.
	ErrEntityNotFound = errors.New("entity not found")
	// ErrHttpStatus reports any other non-success response.
	ErrHttpStatus = errors.New("unexpected http status")
)

Functions

func GetEquivalentWebsocketScheme added in v0.7.1

func GetEquivalentWebsocketScheme(scheme string) (string, error)

GetEquivalentWebsocketScheme returns the equivalent WebSocket scheme for the given scheme. If the scheme is http or https, it returns ws or wss respectively. If the scheme is ws or wss, it returns the same scheme. If the scheme is not any of the above, it returns an error.

func GetFunctionName

func GetFunctionName(i interface{}) string

GetFunctionName returns the name of the function that the interface is a pointer to.

func ParseDuration added in v0.7.1

func ParseDuration(s string) time.Duration

func ParseTime added in v0.7.1

func ParseTime(clock Clock, s string) *carbon.Carbon

ParseTime parses a HH:MM string into an instant on the clock's current day.

func Ptr added in v0.8.0

func Ptr[T any](v T) *T

Types

type Clock added in v0.8.0

type Clock interface {
	Now() time.Time
	Carbon() *carbon.Carbon
}

Clock reports the current time. Production code uses RealClock; tests pin an instant with FakeClock and step it forward deliberately.

type EnabledDisabledInfo

type EnabledDisabledInfo struct {
	Entity     string
	State      string
	RunOnError bool
}

type FakeClock added in v0.8.0

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

FakeClock reports a fixed instant until moved by Set or Advance. Callbacks run on their own goroutines and read the clock freely, so access is guarded.

func NewFakeClock added in v0.8.0

func NewFakeClock(now time.Time) *FakeClock

NewFakeClock returns a FakeClock pinned to the given instant.

func (*FakeClock) Advance added in v0.8.0

func (c *FakeClock) Advance(d time.Duration)

Advance moves the clock forward by d. Negative durations move it back.

func (*FakeClock) Carbon added in v0.8.0

func (c *FakeClock) Carbon() *carbon.Carbon

func (*FakeClock) Now added in v0.8.0

func (c *FakeClock) Now() time.Time

func (*FakeClock) Set added in v0.8.0

func (c *FakeClock) Set(now time.Time)

Set replaces the current instant.

type HttpClient

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

func NewHttpClient

func NewHttpClient(ctx context.Context, baseUrl *url.URL, token string) *HttpClient

func (*HttpClient) GetState

func (c *HttpClient) GetState(entityId string) ([]byte, error)

func (*HttpClient) GetStates added in v0.7.1

func (c *HttpClient) GetStates() ([]byte, error)

GetStates returns the states of all entities.

type RealClock added in v0.8.0

type RealClock struct{}

RealClock reads the system clock.

func (RealClock) Carbon added in v0.8.0

func (RealClock) Carbon() *carbon.Carbon

func (RealClock) Now added in v0.8.0

func (RealClock) Now() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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