homeassistant

package
v0.0.0-...-bd23ae7 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHomeAssistant

func NewHomeAssistant(uri string) (oauth2.TokenSource, error)

func NewHomeAssistantFromConfig

func NewHomeAssistantFromConfig(other map[string]any) (oauth2.TokenSource, error)

func ValidatePhaseEntities

func ValidatePhaseEntities(phases []string) ([]string, error)

ValidatePhaseEntities validates that phase entity arrays contain 1 or 3 entities

Types

type Connection

type Connection struct {
	*request.Helper
	// contains filtered or unexported fields
}

Connection represents a Home Assistant API connection

func NewConnection

func NewConnection(log *util.Logger, uri, home string) (*Connection, error)

NewConnection creates a new Home Assistant connection

func (*Connection) CallNumberService

func (c *Connection) CallNumberService(entity string, value float64) error

CallNumberService is a convenience method for setting number entity values

func (*Connection) CallService

func (c *Connection) CallService(domain, service string, data map[string]any) error

CallService calls a Home Assistant service

func (*Connection) CallSwitchService

func (c *Connection) CallSwitchService(entity string, turnOn bool) error

CallSwitchService is a convenience method for switch services

func (*Connection) GetBoolState

func (c *Connection) GetBoolState(entity string) (bool, error)

GetBoolState retrieves the state of an entity as boolean

func (*Connection) GetChargeStatus

func (c *Connection) GetChargeStatus(entity string) (api.ChargeStatus, error)

GetChargeStatus maps Home Assistant states to api.ChargeStatus

func (*Connection) GetFloatState

func (c *Connection) GetFloatState(entity string) (float64, error)

GetFloatState retrieves the state of an entity as float64

func (*Connection) GetIntState

func (c *Connection) GetIntState(entity string) (int64, error)

GetIntState retrieves the state of an entity as int64

func (*Connection) GetPhaseFloatStates

func (c *Connection) GetPhaseFloatStates(entities []string) (float64, float64, float64, error)

GetPhaseFloatStates retrieves three phase values (currents, voltages, etc.)

func (*Connection) GetState

func (c *Connection) GetState(entity string) (StateResponse, error)

GetState retrieves the state of an entity

func (*Connection) GetStates

func (c *Connection) GetStates() ([]StateResponse, error)

GetStates retrieves the list of entities

func (*Connection) GetTimeState

func (c *Connection) GetTimeState(entity string) (time.Time, error)

GetTimeState retrieves the state of an entity as time

type StateResponse

type StateResponse struct {
	EntityId   string `json:"entity_id"`
	State      string `json:"state"`
	Attributes struct {
		UnitOfMeasurement string `json:"unit_of_measurement"`
		DeviceClass       string `json:"device_class"`
		FriendlyName      string `json:"friendly_name"`
	} `json:"attributes"`
}

Jump to

Keyboard shortcuts

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