Documentation ¶
Index ¶
- Constants
- func New(ctx context.Context, config *gwTY.Config) (providerTY.Plugin, error)
- type ClientStore
- type Config
- type ESPHomeNode
- type ESPHomeNodeConfig
- type Entity
- type EntityStore
- func (s *EntityStore) AddEntity(nodeID string, key uint32, entity Entity)
- func (s *EntityStore) Close()
- func (s *EntityStore) GetByEntityType(nodeID string, entityType string) *Entity
- func (s *EntityStore) GetByKey(nodeID string, key uint32) *Entity
- func (s *EntityStore) GetBySourceID(nodeID string, sourceID string) *Entity
- type MetricMap
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) ConvertToMessages(rawMsg *msgTY.RawMessage) ([]*msgTY.Message, error)
- func (p *Provider) Name() string
- func (p *Provider) Post(message *msgTY.Message) error
- func (p *Provider) Schedule(scheduleID, interval string, triggerFunc func()) error
- func (p *Provider) Start(rxMessageFunc func(rawMsg *msgTY.RawMessage) error) error
- func (p *Provider) Unschedule(scheduleID string)
Constants ¶
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" )
const (
PluginEspHome = "esphome"
)
default values
Variables ¶
This section is empty.
Functions ¶
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
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 Provider ¶
type Provider struct { Config Config GatewayConfig *gwTY.Config // contains filtered or unexported fields }
Provider data
func (*Provider) ConvertToMessages ¶
ConvertToMessages performs operation on raw message received from esphome node and returns multiple messages
func (*Provider) Start ¶
func (p *Provider) Start(rxMessageFunc func(rawMsg *msgTY.RawMessage) error) error
Start func
func (*Provider) Unschedule ¶
Unschedule removes a schedule