esphome

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// internal references
	MessageTypeID = "message_type_id"
	NodeID        = "node_id"
	LabelKey      = "key"
	LabelType     = "type"

	// camera image codec details
	CameraImagePrefix = "data:image/jpeg;base64,"

	// internal actions
	ActionTimeRequest = "time_request"
	ActionPingRequest = "ping_request"

	// entity types
	EntityTypeBinarySensor = "binary_sensor"
	EntityTypeCamera       = "camera"
	EntityTypeClimate      = "climate"
	EntityTypeCover        = "cover"
	EntityTypeFan          = "fan"
	EntityTypeLight        = "light"
	EntityTypeSensor       = "sensor"
	EntityTypeSwitch       = "switch"
	EntityTypeTextSensor   = "text_sensor"

	// source id for restart
	SourceIDRestart = "restart"

	// response message common fields
	FieldKey      = "key"
	FieldObjectID = "object_id"
	FieldName     = "name"
	FieldUniqueID = "unique_id"

	// response message fields
	FieldState                 = "state"
	FieldBrightness            = "brightness"
	FieldRGB                   = "rgb"
	FieldRed                   = "red"
	FieldGreen                 = "green"
	FieldBlue                  = "blue"
	FieldWhite                 = "white"
	FieldColorTemperature      = "color_temperature"
	FieldEffect                = "effect"
	FieldStream                = "stream"
	FieldData                  = "data"
	FieldMode                  = "mode"
	FieldTargetTemperature     = "target_temperature"
	FieldTargetTemperatureLow  = "target_temperature_low"
	FieldTargetTemperatureHigh = "target_temperature_high"
	FieldAway                  = "away"
	FieldCurrentTemperature    = "current_temperature"
	FieldOscillating           = "oscillating"
	FieldFanMode               = "fan_mode"
	FieldSwingMode             = "swing_mode"
	FieldPosition              = "position"
	FieldTilt                  = "tilt"
	FieldStop                  = "stop"
	FieldSpeed                 = "speed"
	FieldDirection             = "direction"
	FieldSpeedLevel            = "speed_level"
)
View Source
const (
	PluginEspHome = "esphome"
)

default values

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, config *gwTY.Config) (providerTY.Plugin, error)

esphome provider

Types

type ClientStore

type ClientStore struct {
	GatewayID string
	// contains filtered or unexported fields
}

ClientStore holds esphome node instances

func (*ClientStore) AddNode

func (s *ClientStore) AddNode(nodeID string, client *ESPHomeNode)

AddNode adds a esphome node to the store

func (*ClientStore) Close

func (s *ClientStore) Close()

Close disconnects all the available esphome nodes and removes from the store

func (*ClientStore) Get

func (s *ClientStore) Get(nodeID string) *ESPHomeNode

Get returns a esphome node from the store

type Config

type Config struct {
	Password           string
	EncryptionKey      string
	Timeout            string
	AliveCheckInterval string
	Nodes              map[string]ESPHomeNodeConfig
}

Config data for this gateway

type ESPHomeNode

type ESPHomeNode struct {
	GatewayID string
	NodeID    string
	Config    ESPHomeNodeConfig
	Client    *esphomeClient.Client
	// contains filtered or unexported fields
}

ESPHomeNode is a esphome node instance

func NewESPHomeNode

func NewESPHomeNode(logger *zap.Logger, gatewayID, nodeID string, config ESPHomeNodeConfig, entityStore *EntityStore, rxMessageFunc func(rawMsg *msgTY.RawMessage) error, scheduler schedulerTY.CoreScheduler, bus busTY.Plugin) *ESPHomeNode

NewESPHomeNode creates a esphome node instance

func (*ESPHomeNode) Connect

func (en *ESPHomeNode) Connect() error

Connect establish a connection to a esphome node performs: login, subscribe states, list available entities and updates node details

func (*ESPHomeNode) Disconnect

func (en *ESPHomeNode) Disconnect() error

Disconnect performs logout from esphome node

func (*ESPHomeNode) Post

func (en *ESPHomeNode) Post(msg proto.Message) error

Post sends message to a esphome node

func (*ESPHomeNode) ScheduleReconnect

func (en *ESPHomeNode) ScheduleReconnect()

ScheduleReconnect adds a schedule for a reconnect

type ESPHomeNodeConfig

type ESPHomeNodeConfig struct {
	Disabled               bool
	Address                string
	Password               string
	EncryptionKey          string
	UseGlobalPassword      bool
	UseGlobalEncryptionKey bool
	Timeout                string
	AliveCheckInterval     string
	ReconnectDelay         string
}

ESPHomeNodeConfig holds esphome node configuration details

type Entity

type Entity struct {
	Key         uint32
	Type        string
	SourceID    string
	SourceName  string
	DeviceClass string
	Unit        string
}

Entity holds key sourceId details of a entity

func (*Entity) Clone

func (en *Entity) Clone() *Entity

Clone produces a cloned version of entity

type EntityStore

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

EntityStore keeps all the esphome node available entities with key and sourceID

func (*EntityStore) AddEntity

func (s *EntityStore) AddEntity(nodeID string, key uint32, entity Entity)

AddEntity adds a entity to the store

func (*EntityStore) Close

func (s *EntityStore) Close()

func (*EntityStore) GetByEntityType

func (s *EntityStore) GetByEntityType(nodeID string, entityType string) *Entity

GetByEntityType returns a entity by entity type

func (*EntityStore) GetByKey

func (s *EntityStore) GetByKey(nodeID string, key uint32) *Entity

GetByKey returns a entity by a key

func (*EntityStore) GetBySourceID

func (s *EntityStore) GetBySourceID(nodeID string, sourceID string) *Entity

GetBySourceID returns a entity by sourceID

type MetricMap

type MetricMap struct {
	MetricType string
	Unit       string
	ReadOnly   string
}

MetricMap holds metric details

type Provider

type Provider struct {
	Config        Config
	GatewayConfig *gwTY.Config
	// contains filtered or unexported fields
}

Provider data

func (*Provider) Close

func (p *Provider) Close() error

Close func

func (*Provider) ConvertToMessages

func (p *Provider) ConvertToMessages(rawMsg *msgTY.RawMessage) ([]*msgTY.Message, error)

ConvertToMessages performs operation on raw message received from esphome node and returns multiple messages

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) Post

func (p *Provider) Post(message *msgTY.Message) error

Post sends a command to esphome node

func (*Provider) Schedule

func (p *Provider) Schedule(scheduleID, interval string, triggerFunc func()) error

Schedule adds a schedule

func (*Provider) Start

func (p *Provider) Start(rxMessageFunc func(rawMsg *msgTY.RawMessage) error) error

Start func

func (*Provider) Unschedule

func (p *Provider) Unschedule(scheduleID string)

Unschedule removes a schedule

Jump to

Keyboard shortcuts

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