Documentation
¶
Index ¶
- Constants
- Variables
- func Discover(devices chan<- *Device) error
- func DiscoverService(devices chan<- *Device, service, domain string, timeout time.Duration) error
- type BinarySensor
- type Camera
- type Client
- func (c *Client) Camera() (Camera, error)
- func (c *Client) Close() error
- func (c *Client) DeviceInfo() (DeviceInfo, error)
- func (c *Client) Entities() Entities
- func (c *Client) LastMessage() time.Time
- func (c *Client) Login(password string) error
- func (c *Client) Logs(level LogLevel) (chan LogEntry, error)
- func (c *Client) Ping() error
- func (c *Client) PingTimeout(timeout time.Duration) error
- type Climate
- type ClimateCapabilities
- type ClimateFanMode
- type ClimateMode
- type ClimateSwingMode
- type Cover
- type Device
- type DeviceInfo
- type Entities
- type Entity
- type Fan
- type Light
- type LightCapabilities
- type LightState
- type LogEntry
- type LogLevel
- type Sensor
- type Switch
- type TextSensor
Constants ¶
Client defaults.
const ( DefaultMDNSService = "_esphomelib._tcp" DefaultMDNSDomain = "local" DefaultMDNSTimeout = 5 * time.Second )
Discovery defaults.
Variables ¶
var ( ErrPassword = errors.New("esphome: invalid password") ErrTimeout = errors.New("esphome: timeout") ErrObjectID = errors.New("esphome: unknown object identifier") ErrEntity = errors.New("esphome: entity not found") )
Errors.
Functions ¶
Types ¶
type BinarySensor ¶
BinarySensor can be pressed, released and/or clicked.
type Camera ¶
type Camera struct { Entity // contains filtered or unexported fields }
Camera is an ESP32 camera.
func (*Camera) Image ¶
Image grabs one image frame from the camera.
func (*Camera) ImageStream ¶
ImageStream is like Stream, returning decoded frame images.
func (*Camera) LastFrame ¶
LastFrame returns the time of the last camera frame received.
type Client ¶
type Client struct { // Info identifies this device with the ESPHome node. Info string // Timeout for read and write operations. Timeout time.Duration // Clock returns the current time. Clock func() time.Time // contains filtered or unexported fields }
Client for an ESPHome device.
func Dial ¶
Dial connects to ESPHome native API on the supplied TCP address.
func DialTimeout ¶
DialTimeout is like Dial with a custom timeout.
func (*Client) Camera ¶
Camera returns a reference to the camera. It returns an error if no camera is found.
func (*Client) DeviceInfo ¶
func (c *Client) DeviceInfo() (DeviceInfo, error)
DeviceInfo queries the ESPHome device information.
func (*Client) Entities ¶
Entities returns all configured entities on the connected device.
func (*Client) LastMessage ¶
LastMessage returns the time of the last message received.
func (*Client) Login ¶
Login must be called to do the initial handshake. The provided password can be empty.
func (*Client) Logs ¶
Logs streams log entries.
type Climate ¶
type Climate struct { Entity // Capabilities of the entity. Capabilities ClimateCapabilities }
Climate devices can represent different types of hardware, but the defining factor is that climate devices have a settable target temperature and can be put in different modes like HEAT, COOL, AUTO or OFF.
type ClimateCapabilities ¶
type ClimateCapabilities struct { CurrentTemperature bool TwoPointTargetTemperature bool Modes []ClimateMode VisualMinTemperature float32 VisualMaxTemperature float32 VisualTemperatureStep float32 Away bool Action bool FanModes []ClimateFanMode SwingModes []ClimateSwingMode }
ClimateCapabilities represents the capabilities of a climate device.
type ClimateFanMode ¶
type ClimateFanMode int32
ClimateFanMode represents a climate fan speed.
const ( ClimateFanModeOn ClimateFanMode = iota ClimateFanModeOff ClimateFanModeAuto ClimateFanModeLow ClimateFanModeMedium ClimateFanModeHigh ClimateFanModeMiddle ClimateFanModeFocus ClimateFanModeDiffuse )
Climate fan modes.
type ClimateMode ¶
type ClimateMode int32
ClimateMode represents the mode for a climate device.
const ( ClimateModeOff ClimateMode = iota ClimateModeAuto ClimateModeCool ClimateModeHeat ClimateModeFanOnly ClimateModeDry )
Climate modes.
type ClimateSwingMode ¶
type ClimateSwingMode int32
ClimateSwingMode represents a climate (fan) swing mode.
const ( ClimateSwingModeOff ClimateSwingMode = iota ClimateSwingModeBoth ClimateSwingModeVertical ClimateSwingModeHorizontal )
Climate swing modes.
type Device ¶
type Device struct { Name string Host string Port int IP net.IP IP6 net.IP Version string // contains filtered or unexported fields }
Device is an ESPHome device (returned by Discover).
type DeviceInfo ¶
type DeviceInfo struct { UsesPassword bool // The name of the node, given by "App.set_name()" Name string // The mac address of the device. For example "AC:BC:32:89:0E:A9" MacAddress string // A string describing the ESPHome version. For example "1.10.0" EsphomeVersion string // A string describing the date of compilation, this is generated by the compiler // and therefore may not be in the same format all the time. // If the user isn't using ESPHome, this will also not be set. CompilationTime string // The model of the board. For example NodeMCU Model string // HasDeepSleep indicates the device has deep sleep mode enabled when idle. HasDeepSleep bool }
DeviceInfo contains information about the ESPHome node.
type Entities ¶
type Entities struct { BinarySensor map[string]BinarySensor Camera map[string]Camera Climate map[string]Climate Cover map[string]Cover Fan map[string]Fan Light map[string]Light Sensor map[string]Sensor Switch map[string]Switch TextSensor map[string]TextSensor }
Entities is a high level map of a device's entities.
type Entity ¶
type Entity struct { Name string ObjectID string UniqueID string Key uint32 // contains filtered or unexported fields }
Entity is the base struct for all supported entities.
type Light ¶
type Light struct { Entity Capabilities LightCapabilities Effects []string State LightState StateIsValid bool HandleState func(on bool) HandleBrightness func(float32) HandleColor func(r, g, b, w float32) HandleColorTemperature func(float32) HandleEffect func(string) }
Light device.
func (Light) SetBrightness ¶
SetBrightness sets the light's intensity (brightness).
func (Light) SetColor ¶
SetColor sets the light's red, green and blue values.
func (Light) SetEffect ¶
SetEffect selects a preconfigured effect.
func (Light) SetState ¶
SetState turns the light on or off.
type LightCapabilities ¶
type LightCapabilities struct { Brightness bool RGB bool WhiteValue bool ColorTemperature bool MinMired float32 MaxMired float32 }
LightCapabilities represents the capabilities of a Light.
type LightState ¶
type LightState struct { On bool Brightness float32 Red, Green, Blue, White float32 ColorTemperature float32 Effect string }
LightState represents the state of a Light.
type LogEntry ¶
type LogEntry struct { // Level of the message. Level LogLevel // Tag for the message. Tag string // Message is the raw text message. Message string // SendFailed indicates a failure. SendFailed bool }
LogEntry contains a single entry in the ESPHome system log.
type Sensor ¶
type Sensor struct { Entity Icon string UnitOfMeasurement string AccuracyDecimals int32 ForceUpdate bool State float32 StateIsValid bool HandleState func(float32) }
Sensor probes.