Documentation
¶
Overview ¶
homeassistant implements an API client for Home Assistant API https://developers.home-assistant.io/docs/api/rest/
Index ¶
- type CallResponse
- type Client
- func (c *Client) Call(ctx context.Context, domain, service string, serviceData map[string]any) ([]*haschema.State, error)
- func (c *Client) CallWithResponse(ctx context.Context, domain, service string, serviceData map[string]any) (*CallResponse, error)
- func (c *Client) Config(ctx context.Context) (*Config, error)
- func (c *Client) DeleteState(ctx context.Context, entityId string) error
- func (c *Client) Domains(ctx context.Context) ([]*Domain, error)
- func (c *Client) Events(ctx context.Context) ([]Event, error)
- func (c *Client) FireEvent(ctx context.Context, eventType string, eventData map[string]any) (string, error)
- func (c *Client) Health(ctx context.Context) (string, error)
- func (c *Client) Services(ctx context.Context, domain string) ([]*Service, error)
- func (c *Client) SetState(ctx context.Context, entityId, state string, attributes map[string]any) (*schema.State, error)
- func (c *Client) State(ctx context.Context, EntityId string) (*schema.State, error)
- func (c *Client) States(ctx context.Context) ([]*schema.State, error)
- func (c *Client) Template(ctx context.Context, template string) (string, error)
- type Config
- type Domain
- type Event
- type Field
- type Selector
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallResponse ¶
type CallResponse = haschema.CallResponse
type Client ¶
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, domain, service string, serviceData map[string]any) ([]*haschema.State, error)
Call a service for an entity. The serviceData map is sent as the JSON request body and typically includes "entity_id" plus any service-specific fields. Returns a list of states that changed while the service was being executed.
func (*Client) CallWithResponse ¶
func (c *Client) CallWithResponse(ctx context.Context, domain, service string, serviceData map[string]any) (*CallResponse, error)
CallWithResponse calls a service and returns both changed states and service response data. Use this for services that support returning response data (e.g. weather.get_forecasts).
func (*Client) DeleteState ¶
DeleteState removes an entity from Home Assistant.
func (*Client) FireEvent ¶
func (c *Client) FireEvent(ctx context.Context, eventType string, eventData map[string]any) (string, error)
FireEvent fires an event with the given type. Optional event data can be passed as a map. Returns a confirmation message.
func (*Client) SetState ¶
func (c *Client) SetState(ctx context.Context, entityId, state string, attributes map[string]any) (*schema.State, error)
SetState creates or updates the state of an entity. The state string is required; attributes is optional. Returns the resulting state object. Note: This sets the representation within Home Assistant — it does not communicate with the actual device. Use Call() to actuate a device.
type Config ¶
type Config struct {
Components []string `json:"components"`
ConfigDir string `json:"config_dir"`
Elevation float64 `json:"elevation"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
LocationName string `json:"location_name"`
TimeZone string `json:"time_zone"`
UnitSystem map[string]any `json:"unit_system"`
Version string `json:"version"`
ExternalDirs []string `json:"whitelist_external_dirs,omitempty"`
AllowlistDirs []string `json:"allowlist_external_dirs,omitempty"`
AllowlistURLs []string `json:"allowlist_external_urls,omitempty"`
Currency string `json:"currency,omitempty"`
Country string `json:"country,omitempty"`
Language string `json:"language,omitempty"`
SafeMode bool `json:"safe_mode,omitempty"`
State string `json:"state,omitempty"`
InternalURL string `json:"internal_url,omitempty"`
ExternalURL string `json:"external_url,omitempty"`
RecoveryMode bool `json:"recovery_mode,omitempty"`
}
Config represents the Home Assistant server configuration.