Documentation
¶
Index ¶
- Constants
- func GetEventState(actor PluginActor) (eventState event_bus.EventEntityState)
- func NewEntity(a PluginActor) m.EntityShort
- func ToEntityActionShort(from map[string]ActorAction) (to map[string]m.EntityActionShort)
- func ToEntityStateShort(from map[string]ActorState) (to map[string]m.EntityStateShort)
- type ActorAction
- type ActorConstructor
- type ActorInfo
- type ActorState
- type BaseActor
- func (e *BaseActor) Attributes() m.Attributes
- func (e *BaseActor) DeserializeAttr(data m.AttributeValue)
- func (e *BaseActor) DeserializeSettings(settings m.AttributeValue)
- func (b *BaseActor) GetEventState(actor PluginActor) event_bus.EventEntityState
- func (e *BaseActor) Info() (info ActorInfo)
- func (e *BaseActor) Metrics() []m.Metric
- func (e *BaseActor) Now(oldState event_bus.EventEntityState) time.Time
- func (e *BaseActor) SetMetric(id common.EntityId, name string, value map[string]interface{})
- func (e *BaseActor) SetState(EntityStateParams) error
- func (e *BaseActor) Settings() m.Attributes
- type CrudActor
- type EntityBind
- func (e *EntityBind) CallAction(action string, arg map[string]interface{})
- func (e *EntityBind) GetAttributes() m.AttributeValue
- func (e *EntityBind) SetAttributes(params m.AttributeValue)
- func (e *EntityBind) SetMetric(name string, value map[string]interface{})
- func (e *EntityBind) SetState(stateName string)
- type EntityManager
- type EntityManagerBind
- func (e *EntityManagerBind) CallAction(id common.EntityId, action string, arg map[string]interface{})
- func (e *EntityManagerBind) GetEntity(id common.EntityId) *EntityBind
- func (e *EntityManagerBind) SetAttribute(id common.EntityId, params m.AttributeValue)
- func (e *EntityManagerBind) SetMetric(id common.EntityId, name string, value map[string]interface{})
- func (e *EntityManagerBind) SetState(id common.EntityId, stateName string)
- type EntityStateParams
- type Message
- type MessageStateChanged
- type PluginActor
- type ScriptBind
Constants ¶
View Source
const ( StateAwait = "await" StateOk = "ok" StateError = "error" StateInProcess = "in process" )
Variables ¶
This section is empty.
Functions ¶
func GetEventState ¶
func GetEventState(actor PluginActor) (eventState event_bus.EventEntityState)
GetEventState ...
func NewEntity ¶
func NewEntity(a PluginActor) m.EntityShort
func ToEntityActionShort ¶
func ToEntityActionShort(from map[string]ActorAction) (to map[string]m.EntityActionShort)
func ToEntityStateShort ¶
func ToEntityStateShort(from map[string]ActorState) (to map[string]m.EntityStateShort)
Types ¶
type ActorAction ¶
type ActorConstructor ¶
type ActorConstructor func() PluginActor
type ActorInfo ¶
type ActorInfo struct {
Id common.EntityId `json:"id"`
ParentId *common.EntityId `json:"parent_id"`
Type common.EntityType `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Hidde bool `json:"hidde"`
UnitOfMeasurement string `json:"unit_of_measurement"`
LastChanged *time.Time `json:"last_changed"`
LastUpdated *time.Time `json:"last_updated"`
DependsOn []string `json:"depends_on"`
State *ActorState `json:"state"`
ImageUrl *string `json:"image_url"`
Icon *common.Icon `json:"icon"`
Area *m.Area `json:"area"`
AutoLoad bool `json:"auto_load"`
Value interface{} `json:"value"`
States map[string]ActorState `json:"states"`
Actions map[string]ActorAction `json:"actions"`
}
type ActorState ¶
type ActorState struct {
Name string `json:"name"`
Description string `json:"description"`
ImageUrl *string `json:"image_url"`
Icon *string `json:"icon"`
}
func (*ActorState) Copy ¶
func (a *ActorState) Copy() (state *ActorState)
type BaseActor ¶
type BaseActor struct {
PluginActor
Id common.EntityId
ParentId *common.EntityId
Name string
Description string
EntityType common.EntityType
Manager EntityManager
State *ActorState
Area *m.Area
Metric []m.Metric
Hidden bool
AttrMu *sync.RWMutex
Attrs m.Attributes
Actions map[string]ActorAction
States map[string]ActorState
ScriptEngine *scripts.Engine
Icon *common.Icon
ImageUrl *string
UnitOfMeasurement string
Sripts []m.Script
Value *atomic.String
AutoLoad bool
LastChanged *time.Time
LastUpdated *time.Time
SettingsMu *sync.RWMutex
Setts m.Attributes
// contains filtered or unexported fields
}
func NewBaseActor ¶
func (*BaseActor) Attributes ¶
func (e *BaseActor) Attributes() m.Attributes
func (*BaseActor) DeserializeAttr ¶
func (e *BaseActor) DeserializeAttr(data m.AttributeValue)
func (*BaseActor) DeserializeSettings ¶
func (e *BaseActor) DeserializeSettings(settings m.AttributeValue)
func (*BaseActor) GetEventState ¶
func (b *BaseActor) GetEventState(actor PluginActor) event_bus.EventEntityState
func (*BaseActor) SetState ¶
func (e *BaseActor) SetState(EntityStateParams) error
func (*BaseActor) Settings ¶
func (e *BaseActor) Settings() m.Attributes
type EntityBind ¶
type EntityBind struct {
m.EntityShort
// contains filtered or unexported fields
}
Javascript Binding
Entity
.setState(stateName) .setAttributes(attrs) .getAttributes() .setMetric(name, value) .callAction(name, value)
func NewEntityBind ¶
func NewEntityBind(id common.EntityId, manager EntityManager) *EntityBind
NewEntityBind ...
func (*EntityBind) CallAction ¶
func (e *EntityBind) CallAction(action string, arg map[string]interface{})
CallAction ...
func (*EntityBind) GetAttributes ¶
func (e *EntityBind) GetAttributes() m.AttributeValue
GetAttributes ...
func (*EntityBind) SetAttributes ¶
func (e *EntityBind) SetAttributes(params m.AttributeValue)
SetAttributes ...
func (*EntityBind) SetMetric ¶
func (e *EntityBind) SetMetric(name string, value map[string]interface{})
SetMetric ...
type EntityManager ¶
type EntityManager interface {
// SetPluginManager ...
SetPluginManager(pluginManager common.PluginManager)
// LoadEntities ...
LoadEntities()
// Shutdown ...
Shutdown()
// SetMetric ...
SetMetric(common.EntityId, string, map[string]interface{})
// SetState ...
SetState(common.EntityId, EntityStateParams) error
// GetEntityById ...
GetEntityById(common.EntityId) (m.EntityShort, error)
// GetActorById ...
GetActorById(common.EntityId) (PluginActor, error)
// List ...
List() ([]m.EntityShort, error)
// Spawn ...
Spawn(ActorConstructor) PluginActor
// Remove ...
Remove(common.EntityId)
// CallAction ...
CallAction(common.EntityId, string, map[string]interface{})
// CallScene ...
CallScene(common.EntityId, map[string]interface{})
// Add ...
Add(*m.Entity) error
// Update ...
Update(*m.Entity) error
}
func NewEntityManager ¶
func NewEntityManager(lc fx.Lifecycle, eventBus event_bus.EventBus, adaptors *adaptors.Adaptors, scripts scripts.ScriptService) EntityManager
type EntityManagerBind ¶
type EntityManagerBind struct {
// contains filtered or unexported fields
}
Javascript Binding
entityManager
.getEntity(id) -> EntityBind .setState(id, stateName) .setAttributes(id, attrs) .setMetric(id, name, value) .callAction(id, actionName)
func NewEntityManagerBind ¶
func NewEntityManagerBind(manager EntityManager) *EntityManagerBind
NewEntityManagerBind ...
func (*EntityManagerBind) CallAction ¶
func (e *EntityManagerBind) CallAction(id common.EntityId, action string, arg map[string]interface{})
CallAction ...
func (*EntityManagerBind) GetEntity ¶
func (e *EntityManagerBind) GetEntity(id common.EntityId) *EntityBind
GetEntityById ...
func (*EntityManagerBind) SetAttribute ¶
func (e *EntityManagerBind) SetAttribute(id common.EntityId, params m.AttributeValue)
SetAttribute ...
type EntityStateParams ¶
type EntityStateParams struct {
NewState *string `json:"new_state"`
AttributeValues m.AttributeValue `json:"attribute_values"`
SettingsValue m.AttributeValue `json:"settings_value"`
StorageSave bool `json:"storage_save"`
}
EntityStateParams -> entityManager
type MessageStateChanged ¶
type MessageStateChanged struct {
StorageSave bool
OldState event_bus.EventEntityState
NewState event_bus.EventEntityState
}
MessageStateChanged -> entityManager
type PluginActor ¶
type PluginActor interface {
// Spawn ...
Spawn() PluginActor
// Attributes ...
Attributes() m.Attributes
// Settings ...
Settings() m.Attributes
// Metrics ...
Metrics() []m.Metric
// SetState ...
SetState(EntityStateParams) error
// Info ...
Info() ActorInfo
}
type ScriptBind ¶
type ScriptBind struct {
// contains filtered or unexported fields
}
Javascript Binding
Actor
.setState(params)
Click to show internal directories.
Click to hide internal directories.