addon

package
v0.0.0-...-6312dd6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package plugin @Description:

Index

Constants

View Source
const (
	TypeString  = "string"
	TypeBoolean = "boolean"
	TypeInteger = "integer"
	TypeNumber  = "number"

	UnitHectopascal = "hectopascal"
	UnitKelvin      = "kelvin"
	UnitPercentage  = "percentage"
	UnitArcDegrees  = "arcdegrees"
	UnitCelsius     = "celsius"
	UnitLux         = "lux"
	UnitSeconds     = "seconds"
	UnitPPM         = "ppm"

	AlarmProperty                    = "AlarmProperty"
	BarometricPressureProperty       = "BarometricPressureProperty"
	ColorModeProperty                = "ColorModeProperty"
	ColorProperty                    = "ColorProperty"
	ColorTemperatureProperty         = "ColorTemperatureProperty"
	ConcentrationProperty            = "ConcentrationProperty"
	CurrentProperty                  = "CurrentProperty"
	DensityProperty                  = "DensityProperty"
	FrequencyProperty                = "FrequencyProperty"
	HeatingCoolingProperty           = "HeatingCoolingProperty"
	HumidityProperty                 = "HumidityProperty"
	ImageProperty                    = "ImageProperty"
	InstantaneousPowerFactorProperty = "InstantaneousPowerFactorProperty"
	InstantaneousPowerProperty       = "InstantaneousPowerProperty"
	LeakProperty                     = "LeakProperty"
	LevelProperty                    = "LevelProperty"
	LockedProperty                   = "LockedProperty"
	MotionProperty                   = "MotionProperty"

	OpenProperty              = "OpenProperty"
	PushedProperty            = "PushedProperty"
	SmokeProperty             = "SmokeProperty"
	TargetTemperatureProperty = "TargetTemperatureProperty"
	TemperatureProperty       = "TemperatureProperty"
	ThermostatModeProperty    = "ThermostatModeProperty"
	VideoProperty             = "VideoProperty"
	VoltageProperty           = "VoltageProperty"
)
View Source
const (
	AdapterAddedNotification           = 4096
	AdapterCancelPairingCommand        = 4100
	AdapterCancelRemoveDeviceCommand   = 4105
	AdapterPairingPromptNotification   = 4101
	AdapterRemoveDeviceRequest         = 4103
	AdapterRemoveDeviceResponse        = 4104
	AdapterStartPairingCommand         = 4099
	AdapterUnloadRequest               = 4097
	AdapterUnloadResponse              = 4098
	AdapterUnpairingPromptNotification = 4102
	ApiHandlerAddedNotification        = 20480
	ApiHandlerApiRequest               = 20483
	ApiHandlerApiResponse              = 20484
	ApiHandlerUnloadRequest            = 20481
	ApiHandlerUnloadResponse           = 20482
	DeviceActionStatusNotification     = 8201
	DeviceAddedNotification            = 8192
	DeviceConnectedStateNotification   = 8197
	DeviceDebugCommand                 = 8206
	DeviceEventNotification            = 8200
	DevicePropertyChangedNotification  = 8199
	DeviceRemoveActionRequest          = 8202
	DeviceRemoveActionResponse         = 8203
	DeviceRequestActionRequest         = 8204
	DeviceRequestActionResponse        = 8205
	DeviceSavedNotification            = 8207
	DeviceSetCredentialsRequest        = 8195
	DeviceSetCredentialsResponse       = 8196
	DeviceSetPinRequest                = 8193
	DeviceSetPinResponse               = 8194
	DeviceSetPropertyCommand           = 8198
	MockAdapterAddDeviceRequest        = 61440
	MockAdapterAddDeviceResponse       = 61441
	MockAdapterClearStateRequest       = 61446
	MockAdapterClearStateResponse      = 61447
	MockAdapterPairDeviceCommand       = 61444
	MockAdapterRemoveDeviceRequest     = 61442
	MockAdapterRemoveDeviceResponse    = 61443
	MockAdapterUnpairDeviceCommand     = 61445
	NotifierAddedNotification          = 12288
	NotifierUnloadRequest              = 12289
	NotifierUnloadResponse             = 12290
	OutletAddedNotification            = 16384
	OutletNotifyRequest                = 16386
	OutletNotifyResponse               = 16387
	OutletRemovedNotification          = 16385
	PluginErrorNotification            = 4
	PluginRegisterRequest              = 0
	PluginRegisterResponse             = 1
	PluginUnloadRequest                = 2
	PluginUnloadResponse               = 3
)
View Source
const ManifestVersion = 1

Variables

This section is empty.

Functions

func NewIpcServer

func NewIpcServer(addr string) chan *wsConnection

Types

type Adapter

type Adapter struct {
	*adapter.Adapter
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(adapterId string, name string, packageName string, plugin *Plugin) *Adapter

func (*Adapter) Send

func (adapter *Adapter) Send(messageType messages.MessageType, data any)

func (*Adapter) SendPropertyChangedNotification

func (adapter *Adapter) SendPropertyChangedNotification(deviceId string, p properties.PropertyDescription)

type Addon

type Addon struct {
	ID                      string `json:"id"`
	Name                    string `json:"name"`
	ShortName               string `json:"short_name"`
	Author                  string `json:"author"`
	Description             string `json:"description,omitempty"`
	License                 string `json:"license,omitempty"`
	HomepageUrl             string `json:"homepage_url"`
	Version                 string `json:"version"`
	Schema                  Schema `json:"schema,omitempty"`
	Exec                    string `json:"exec"`
	Enabled                 bool   `json:"enabled"`
	PrimaryType             string `json:"primary_type"`
	ContentScripts          any    `json:"content_scripts,omitempty"`
	WSebAccessibleResources any    `json:"web_accessible_resources,omitempty"`
	// contains filtered or unexported fields
}

func LoadManifest

func LoadManifest(destPath, packetId string, store AddonsStore) (*Addon, any, error)

LoadManifest

@Description:
@param destPath
@param packetId
@param store
@return *Addon
@return interface{}:addon default config
@return error

func NewAddonSettingFromManifest

func NewAddonSettingFromManifest(manifest *ManifestJson, store AddonsStore) *Addon

func NewAddonSettingFromString

func NewAddonSettingFromString(str string, store AddonsStore) *Addon

func (*Addon) DeleteSettingAndConfig

func (a *Addon) DeleteSettingAndConfig() error

func (*Addon) SetEnabled

func (a *Addon) SetEnabled(disabled bool) error

type AddonsStore

type AddonsStore interface {
	LoadAddonSetting(key string) (string, error)
	StoreAddonSetting(key, value string) error
	LoadAddonConfig(key string) (string, error)
	StoreAddonsConfig(key string, value any) error
	RemoveAddonSettingAndConfig(key string) error
	UpdateAddonSetting(id, value string) error
}

type ApiHandler

type ApiHandler struct {
	ID string
}

type Config

type Config struct {
	AddonsDir       string
	AttachAddonsDir string
	IPCPort         string
	RPCPort         string
	UserProfile     *messages.PluginRegisterResponseJsonDataUserProfile
}

type Extension

type Extension struct {
	Extensions any
	Resources  any
}

type Manager

type Manager struct {
	*manager.Manager
	*bus.EventBus
	// contains filtered or unexported fields
}

func NewAddonsManager

func NewAddonsManager(ctx context.Context, conf Config, s managerStore) *Manager

func (*Manager) AddNewThings

func (m *Manager) AddNewThings(timeout int) error

func (*Manager) AddonEnabled

func (m *Manager) AddonEnabled(addonId string) bool

func (*Manager) CancelAddNewThing

func (m *Manager) CancelAddNewThing()

func (*Manager) CancelRemoveThing

func (m *Manager) CancelRemoveThing(deviceId string)

func (*Manager) DisableAddon

func (m *Manager) DisableAddon(packageId string) error

func (*Manager) EnableAddon

func (m *Manager) EnableAddon(packageId string) error

func (*Manager) GetAddonLicense

func (m *Manager) GetAddonLicense(addonId string) (string, error)

func (*Manager) GetDevices

func (m *Manager) GetDevices() (devices []*device)

func (*Manager) GetInstallAddons

func (m *Manager) GetInstallAddons() any

GetInstallAddons 获取已安装的add-on

func (*Manager) GetLanguage

func (m *Manager) GetLanguage() string

func (*Manager) GetMapOfDevices

func (m *Manager) GetMapOfDevices() map[string]*devices.Device

func (*Manager) GetPreferences

func (*Manager) GetPropertiesValue

func (m *Manager) GetPropertiesValue(thingId string) (map[string]any, error)

func (*Manager) GetPropertyValue

func (m *Manager) GetPropertyValue(thingId, propName string) (any, error)

func (*Manager) GetUserProfile

func (*Manager) InstallAddonFromUrl

func (m *Manager) InstallAddonFromUrl(id, url, checksum string) error

func (*Manager) LoadAddon

func (m *Manager) LoadAddon(packageId string) error

func (*Manager) RemoveAction

func (m *Manager) RemoveAction(deviceId, actionId, actionName string) error

func (*Manager) RemoveThing

func (m *Manager) RemoveThing(deviceId string) error

func (*Manager) RequestAction

func (m *Manager) RequestAction(ctx context.Context, thingId, actionName string, input map[string]any) error

func (*Manager) SetCredentials

func (m *Manager) SetCredentials(ctx context.Context, thingId, username, password string) (*messages.Device, error)

func (*Manager) SetPIN

func (m *Manager) SetPIN(ctx context.Context, thingId string, pin string) (*messages.Device, error)

func (*Manager) SetPropertyValue

func (m *Manager) SetPropertyValue(ctx context.Context, thingId, propName string, newValue any) (any, error)

SetPropertyValue 返回Fiber.NewError

func (*Manager) SetThingsContainer

func (m *Manager) SetThingsContainer(thingContainer ThingsContainer)

func (*Manager) UninstallAddon

func (m *Manager) UninstallAddon(packetId string, disable bool) error

func (*Manager) UnloadAddon

func (m *Manager) UnloadAddon(packageId string) error

func (*Manager) UpdatePreferences

func (m *Manager) UpdatePreferences()

type ManifestJson

type ManifestJson struct {
	ID                      string `json:"id"`
	Name                    string `json:"name"`
	ShortName               string `json:"short_name,omitempty"`
	Author                  string `json:"author"`
	Description             string `json:"description,omitempty"`
	License                 string `json:"license"`
	HomepageUrl             string `json:"homepage_url,omitempty"`
	ManifestVersion         int    `json:"manifest_version"`
	Version                 string `json:"version"`
	ContentScripts          any    `json:"content_Scripts"`
	WSebAccessibleResources any    `json:"web_accessible_resources"`
	Options                 struct {
		Default any    `json:"default"`
		Schema  Schema `json:"schema"`
	}
	GatewaySpecificSettings struct {
		WebThings struct {
			Exec             string `json:"exec"`
			PrimaryType      string `json:"primary_type"`
			StrictMaxVersion string `json:"strict_max_version"`
			StrictMinVersion string `json:"strict_min_version"`
			Enable           bool   `json:"enable,omitempty"`
		} `json:"webthings"`
	} `json:"gateway_specific_settings"`
	Enable bool `json:"setEnabled"`
}

type Notifier

type Notifier struct {
	ID string
	// contains filtered or unexported fields
}

type Outlet

type Outlet struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type Plugin

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

func NewPlugin

func NewPlugin(pluginId string, manager *Manager) (plugin *Plugin)

func (*Plugin) OnMsg

func (plugin *Plugin) OnMsg(bt []byte)

type PluginsServer

type PluginsServer struct {
	Plugins sync.Map
	// contains filtered or unexported fields
}

func NewPluginServer

func NewPluginServer(manager *Manager) *PluginsServer

type Schema

type Schema struct {
	Type       string   `json:"type,omitempty"`
	Required   []string `json:"required,omitempty"`
	Properties any      `json:"properties,omitempty"`
}

type ThingsContainer

type ThingsContainer interface {
	Subscribe(topic topic.Topic, fn any) error
	Unsubscribe(topic topic.Topic, fn any)
	GetThings() []*things.Thing
}

Jump to

Keyboard shortcuts

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