Documentation
¶
Index ¶
- Constants
- func CallActionBind(manager Supervisor) func(entityId, action string, value map[string]interface{})
- func CallActionV2Bind(manager Supervisor) func(params CallActionV2, value map[string]interface{})
- func CallSceneBind(manager Supervisor) func(entityId string, value map[string]interface{})
- func CallScriptBind(manager Supervisor) func(entityId, fn string, arg ...interface{})
- func GetAttributesBind(manager Supervisor) func(entityId string) m.AttributeValue
- func GetDistanceBetweenPointsBind(adaptors *adaptors.Adaptors) func(point1, point2 m.Point) float64
- func GetDistanceToAreaBind(adaptors *adaptors.Adaptors) func(areaId int64, point m.Point) float64
- func GetEntityBind(manager Supervisor) func(entityId string) *EntityBind
- func GetSettingsBind(manager Supervisor) func(entityId string) m.AttributeValue
- func GetStateBind(manager Supervisor) func(entityId string) *m.EntityStateShort
- func NewEntity(a PluginActor) m.EntityShort
- func PointInsideAreaBind(adaptors *adaptors.Adaptors) func(areaId int64, point m.Point) bool
- func PushSystemEvent(manager Supervisor) func(command string, params map[string]interface{})
- func RegisterPlugin(name string, new func() Pluggable)
- func SetAttributesBind(manager Supervisor) func(entityId string, params m.AttributeValue)
- func SetMetricBind(manager Supervisor) func(entityId, name string, value map[string]interface{})
- func SetStateBind(manager Supervisor) func(entityId string, params EntityStateParams)
- func SetStateNameBind(manager Supervisor) func(entityId, stateName string)
- 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) AddMetric(name string, value map[string]interface{})
- func (e *BaseActor) Area() *m.Area
- func (e *BaseActor) Attributes() m.Attributes
- func (e *BaseActor) CallScript(fn string, arg ...interface{})
- func (e *BaseActor) DeserializeAttr(data m.AttributeValue)
- func (e *BaseActor) DeserializeSettings(settings m.AttributeValue)
- func (e *BaseActor) GetCurrentState() *events.EventEntityState
- func (e *BaseActor) GetEventState() (eventState events.EventEntityState)
- func (e *BaseActor) GetOldState() *events.EventEntityState
- func (e *BaseActor) Info() (info ActorInfo)
- func (e *BaseActor) MatchTags(tags []string) bool
- func (e *BaseActor) Metrics() []*m.Metric
- func (e *BaseActor) Now(oldState events.EventEntityState) time.Time
- func (e *BaseActor) RestoreState(entity *m.Entity)
- func (e *BaseActor) SaveState(doNotSaveMetric, storageSave bool)
- func (e *BaseActor) SetActorState(name *string)
- func (e *BaseActor) SetActorStateImage(imageUrl, icon *string)
- func (e *BaseActor) SetCurrentState(state events.EventEntityState)
- func (e *BaseActor) SetState(EntityStateParams) error
- func (e *BaseActor) Settings() m.Attributes
- func (e *BaseActor) Spawn()
- func (e *BaseActor) StopWatchers()
- type CallActionV2
- type EntityBind
- type EntityStateParams
- type Installable
- type MessageStateChanged
- type Pluggable
- type Plugin
- func (p *Plugin) AddActor(pla PluginActor, entity *m.Entity) (err error)
- func (p *Plugin) AddOrUpdateActor(entity *m.Entity) (err error)
- func (p *Plugin) Check(msg events.EventCallEntityAction) (result []interface{}, ok bool)
- func (p *Plugin) Depends() []string
- func (p *Plugin) EntityIsLoaded(id common.EntityId) bool
- func (p *Plugin) GetActor(id common.EntityId) (pla PluginActor, err error)
- func (p *Plugin) Load(ctx context.Context, service Service, actorConstructor ActorConstructor) error
- func (p *Plugin) LoadSettings(pl Pluggable) (settings m.Attributes, err error)
- func (p *Plugin) Name() string
- func (p *Plugin) Options() m.PluginOptions
- func (p *Plugin) Readme(note, lang *string) (result []byte, err error)
- func (p *Plugin) RemoveActor(entityId common.EntityId) (err error)
- func (p *Plugin) Type() PluginType
- func (p *Plugin) Unload(ctx context.Context) error
- func (p *Plugin) Version() string
- type PluginActor
- type PluginInfo
- type PluginType
- type Service
- type Supervisor
Constants ¶
View Source
const ( // StateAwait ... StateAwait = "await" // StateOk ... StateOk = "ok" // StateError ... StateError = "error" // StateInProcess ... StateInProcess = "in process" )
View Source
const ( // PluginBuiltIn ... PluginBuiltIn = PluginType("System") // PluginInstallable ... PluginInstallable = PluginType("Installable") )
Variables ¶
This section is empty.
Functions ¶
func CallActionBind ¶
func CallActionBind(manager Supervisor) func(entityId, action string, value map[string]interface{})
func CallActionV2Bind ¶ added in v0.17.0
func CallActionV2Bind(manager Supervisor) func(params CallActionV2, value map[string]interface{})
func CallSceneBind ¶
func CallSceneBind(manager Supervisor) func(entityId string, value map[string]interface{})
func CallScriptBind ¶ added in v0.19.0
func CallScriptBind(manager Supervisor) func(entityId, fn string, arg ...interface{})
func GetAttributesBind ¶
func GetAttributesBind(manager Supervisor) func(entityId string) m.AttributeValue
func GetDistanceToAreaBind ¶
func GetEntityBind ¶
func GetEntityBind(manager Supervisor) func(entityId string) *EntityBind
func GetSettingsBind ¶
func GetSettingsBind(manager Supervisor) func(entityId string) m.AttributeValue
func GetStateBind ¶
func GetStateBind(manager Supervisor) func(entityId string) *m.EntityStateShort
func PointInsideAreaBind ¶ added in v0.14.0
func PushSystemEvent ¶ added in v0.14.0
func PushSystemEvent(manager Supervisor) func(command string, params map[string]interface{})
func SetAttributesBind ¶
func SetAttributesBind(manager Supervisor) func(entityId string, params m.AttributeValue)
func SetMetricBind ¶
func SetMetricBind(manager Supervisor) func(entityId, name string, value map[string]interface{})
func SetStateBind ¶
func SetStateBind(manager Supervisor) func(entityId string, params EntityStateParams)
func SetStateNameBind ¶
func SetStateNameBind(manager Supervisor) func(entityId, stateName string)
func ToEntityActionShort ¶
func ToEntityActionShort(from map[string]ActorAction) (to map[string]m.EntityActionShort)
ToEntityActionShort ...
func ToEntityStateShort ¶
func ToEntityStateShort(from map[string]ActorState) (to map[string]m.EntityStateShort)
ToEntityStateShort ...
Types ¶
type ActorAction ¶
type ActorAction struct {
Name string `json:"name"`
Description string `json:"description"`
ImageUrl *string `json:"image_url"`
Icon *string `json:"icon"`
ScriptEngine *scripts.EngineWatcher `json:"-"`
}
ActorAction ...
type ActorConstructor ¶
type ActorConstructor func(*m.Entity) (PluginActor, error)
ActorConstructor ...
type ActorInfo ¶
type ActorInfo struct {
Id common.EntityId `json:"id"`
ParentId *common.EntityId `json:"parent_id"`
PluginName string `json:"plugin_name"`
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 *string `json:"icon"`
Area *m.Area `json:"area"`
AutoLoad bool `json:"auto_load"`
RestoreState bool `json:"restoreState"`
Value interface{} `json:"value"`
States map[string]ActorState `json:"states"`
Actions map[string]ActorAction `json:"actions"`
}
ActorInfo ...
type ActorState ¶
type ActorState struct {
Name string `json:"name"`
Description string `json:"description"`
ImageUrl *string `json:"image_url"`
Icon *string `json:"icon"`
}
ActorState ...
type BaseActor ¶
type BaseActor struct {
PluginActor
Id common.EntityId
ParentId *common.EntityId
Name string
Description string
EntityType string
Metric []*m.Metric
Hidden bool
AttrMu *sync.RWMutex
Attrs m.Attributes
Actions map[string]ActorAction
States map[string]ActorState
ScriptsEngine *scripts.EnginesWatcher
Icon *string
ImageUrl *string
UnitOfMeasurement string
Scripts []*m.Script
Value *atomic.String
AutoLoad bool
LastChanged *time.Time
LastUpdated *time.Time
SettingsMu *sync.RWMutex
Setts m.Attributes
Service Service
// contains filtered or unexported fields
}
BaseActor ...
func NewBaseActor ¶
NewBaseActor ...
func (*BaseActor) CallScript ¶ added in v0.19.0
func (*BaseActor) DeserializeAttr ¶
func (e *BaseActor) DeserializeAttr(data m.AttributeValue)
DeserializeAttr ...
func (*BaseActor) DeserializeSettings ¶
func (e *BaseActor) DeserializeSettings(settings m.AttributeValue)
DeserializeSettings ...
func (*BaseActor) GetCurrentState ¶
func (e *BaseActor) GetCurrentState() *events.EventEntityState
func (*BaseActor) GetEventState ¶
func (e *BaseActor) GetEventState() (eventState events.EventEntityState)
func (*BaseActor) GetOldState ¶ added in v0.15.0
func (e *BaseActor) GetOldState() *events.EventEntityState
func (*BaseActor) RestoreState ¶ added in v0.15.0
func (*BaseActor) SetActorState ¶ added in v0.15.0
SetActorState ...
func (*BaseActor) SetActorStateImage ¶ added in v0.15.0
SetActorStateImage ...
func (*BaseActor) SetCurrentState ¶
func (e *BaseActor) SetCurrentState(state events.EventEntityState)
func (*BaseActor) StopWatchers ¶
func (e *BaseActor) StopWatchers()
type CallActionV2 ¶ added in v0.17.0
type EntityBind ¶
type EntityBind struct {
m.EntityShort
// contains filtered or unexported fields
}
EntityBind ...
func NewEntityBind ¶
func NewEntityBind(id common.EntityId, manager Supervisor) *EntityBind
NewEntityBind ...
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 -> supervisor
type MessageStateChanged ¶
type MessageStateChanged struct {
StorageSave bool
OldState events.EventEntityState
NewState events.EventEntityState
}
MessageStateChanged -> supervisor
type Pluggable ¶
type Pluggable interface {
Load(context.Context, Service) error
Unload(context.Context) error
Name() string
Type() PluginType
Depends() []string
Version() string
Options() m.PluginOptions
EntityIsLoaded(id common.EntityId) bool
GetActor(id common.EntityId) (pla PluginActor, err error)
AddOrUpdateActor(*m.Entity) error
RemoveActor(common.EntityId) error
Readme(*string, *string) ([]byte, error)
}
Pluggable ...
type Plugin ¶
type Plugin struct {
Service Service
IsStarted *atomic.Bool
Actors *sync.Map
F embed.FS
// contains filtered or unexported fields
}
Plugin ...
func (*Plugin) Check ¶ added in v0.17.0
func (p *Plugin) Check(msg events.EventCallEntityAction) (result []interface{}, ok bool)
func (*Plugin) GetActor ¶
func (p *Plugin) GetActor(id common.EntityId) (pla PluginActor, err error)
func (*Plugin) Load ¶
func (p *Plugin) Load(ctx context.Context, service Service, actorConstructor ActorConstructor) error
Load ...
func (*Plugin) LoadSettings ¶
func (p *Plugin) LoadSettings(pl Pluggable) (settings m.Attributes, err error)
LoadSettings ...
type PluginActor ¶
type PluginActor interface {
Spawn()
Destroy()
StopWatchers()
Attributes() m.Attributes
Settings() m.Attributes
Metrics() []*m.Metric
SetState(EntityStateParams) error
Info() ActorInfo
GetCurrentState() *events.EventEntityState
GetOldState() *events.EventEntityState
SetCurrentState(events.EventEntityState)
GetEventState() events.EventEntityState
AddMetric(name string, value map[string]interface{})
MatchTags(tags []string) bool
Area() *m.Area
CallScript(fn string, arg ...interface{})
}
PluginActor ...
type PluginInfo ¶
type PluginInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Enabled bool `json:"enabled"`
System bool `json:"system"`
}
PluginInfo ...
type Service ¶
type Service interface {
Plugins() map[string]Pluggable
EventBus() bus.Bus
Adaptors() *adaptors.Adaptors
Supervisor() Supervisor
ScriptService() scripts.ScriptService
MqttServ() mqtt.MqttServ
AppConfig() *m.AppConfig
Scheduler() *scheduler.Scheduler
Crawler() web.Crawler
}
Service ...
type Supervisor ¶
type Supervisor interface {
Start(context.Context) error
Shutdown(context.Context) error
Restart(context.Context) error
GetPlugin(name string) (interface{}, error)
EnablePlugin(context.Context, string) error
DisablePlugin(context.Context, string) error
PluginList() (list []PluginInfo, total int64, err error)
SetMetric(common.EntityId, string, map[string]interface{})
SetState(common.EntityId, EntityStateParams) error
GetActorById(common.EntityId) (PluginActor, error)
CallAction(common.EntityId, string, map[string]interface{})
CallScript(id common.EntityId, fn string, arg ...interface{})
CallActionV2(CallActionV2, map[string]interface{})
CallScene(common.EntityId, map[string]interface{})
AddEntity(*m.Entity) error
GetEntityById(common.EntityId) (m.EntityShort, error)
UpdateEntity(*m.Entity) error
UnloadEntity(common.EntityId)
EntityIsLoaded(id common.EntityId) bool
PluginIsLoaded(string) bool
GetService() Service
GetPluginReadme(context.Context, string, *string, *string) ([]byte, error)
PushSystemEvent(strCommand string, params map[string]interface{})
}
Supervisor ...
Click to show internal directories.
Click to hide internal directories.