Documentation
¶
Index ¶
- Constants
- func ToEntityActionShort(from map[string]ActorAction) (to map[string]models.EntityActionShort)
- func ToEntityStateShort(from map[string]ActorState) (to map[string]models.EntityStateShort)
- type ActorAction
- type ActorConstructor
- type ActorInfo
- type ActorState
- type Authorization
- type CallActionV2
- type EntityStateParams
- type HttpAccessFilter
- type Installable
- type Pluggable
- type Plugin
- func (p *Plugin) AddActor(pla PluginActor, entity *models.Entity) (err error)
- func (p *Plugin) AddOrUpdateActor(entity *models.Entity) (err error)
- func (p *Plugin) Check(msg events.EventCallEntityAction) (result []interface{}, ok bool)
- func (p *Plugin) Depends() []string
- func (p *Plugin) EntityIsLoaded(id pkgCommon.EntityId) bool
- func (p *Plugin) GetActor(id pkgCommon.EntityId) (pla PluginActor, err error)
- func (p *Plugin) Load(ctx context.Context, service Service, actorConstructor ActorConstructor) error
- func (p *Plugin) LoadSettings(pl Pluggable) (settings models.Attributes, err error)
- func (p *Plugin) Name() string
- func (p *Plugin) Options() models.PluginOptions
- func (p *Plugin) Readme(note, lang *string) (result []byte, err error)
- func (p *Plugin) RemoveActor(entityId pkgCommon.EntityId) (err error)
- func (p *Plugin) Unload(ctx context.Context) error
- func (p *Plugin) Version() string
- type PluginActor
- type PluginFileInfo
- type PluginFileInfos
- type PluginInfo
- type PluginManifest
- type Service
- type Supervisor
Constants ¶
View Source
const ( // StateAwait ... StateAwait = "await" // StateOk ... StateOk = "ok" // StateError ... StateError = "error" // StateInProcess ... StateInProcess = "in process" )
Variables ¶
This section is empty.
Functions ¶
func ToEntityActionShort ¶
func ToEntityActionShort(from map[string]ActorAction) (to map[string]models.EntityActionShort)
ToEntityActionShort ...
func ToEntityStateShort ¶
func ToEntityStateShort(from map[string]ActorState) (to map[string]models.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(*models.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 *models.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 Authorization ¶ added in v0.21.1
type CallActionV2 ¶
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 HttpAccessFilter ¶ added in v0.21.1
type Pluggable ¶
type Pluggable interface {
Load(context.Context, Service) error
Unload(context.Context) error
Name() string
Depends() []string
Version() string
Options() models.PluginOptions
EntityIsLoaded(id common.EntityId) bool
GetActor(id common.EntityId) (pla PluginActor, err error)
AddOrUpdateActor(*models.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) AddActor ¶
func (p *Plugin) AddActor(pla PluginActor, entity *models.Entity) (err error)
func (*Plugin) AddOrUpdateActor ¶
func (*Plugin) Check ¶
func (p *Plugin) Check(msg events.EventCallEntityAction) (result []interface{}, ok bool)
func (*Plugin) GetActor ¶
func (p *Plugin) GetActor(id pkgCommon.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 models.Attributes, err error)
LoadSettings ...
type PluginActor ¶
type PluginActor interface {
Spawn()
Destroy()
StopWatchers()
Attributes() models.Attributes
Settings() models.Attributes
Metrics() []*models.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() *models.Area
CallScript(fn string, arg ...interface{})
}
PluginActor ...
type PluginFileInfo ¶
type PluginFileInfos ¶
type PluginFileInfos []*PluginFileInfo
func (PluginFileInfos) Len ¶
func (l PluginFileInfos) Len() int
func (PluginFileInfos) Less ¶
func (l PluginFileInfos) Less(i, j int) bool
func (PluginFileInfos) Swap ¶
func (l PluginFileInfos) Swap(i, j int)
type PluginInfo ¶
type PluginInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Enabled bool `json:"enabled"`
System bool `json:"system"`
}
PluginInfo ...
type PluginManifest ¶
type PluginManifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Repository string `json:"repository"`
Plugin string `json:"plugin"`
Libs []string `json:"libs"`
Assets []string `json:"assets"`
Settings map[string]interface{} `json:"settings"`
Actor bool `json:"actor"`
Triggers bool `json:"triggers"`
OS string `json:"os"`
Arch string `json:"arch"`
}
type Service ¶
type Service interface {
Plugins() map[string]Pluggable
EventBus() bus.Bus
Adaptors() *adaptors.Adaptors
Supervisor() Supervisor
ScriptService() scripts.ScriptService
MqttServ() mqtt.MqttServ
AppConfig() *models.AppConfig
Scheduler() scheduler.Scheduler
Crawler() web.Crawler
Authorization() Authorization
HttpAccessFilter() HttpAccessFilter
}
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
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(*models.Entity) error
GetEntityById(common.EntityId) (models.EntityShort, error)
UpdateEntity(*models.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{})
UploadPlugin(ctx context.Context, reader *bufio.Reader) (newFile *models.Plugin, err error)
RemovePlugin(ctx context.Context, pluginName string) error
}
Supervisor ...
Click to show internal directories.
Click to hide internal directories.