models

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessageStatusNew ...
	MessageStatusNew = MessageStatus("new")
	// MessageStatusInProgress ...
	MessageStatusInProgress = MessageStatus("in_progress")
	// MessageStatusSucceed ...
	MessageStatusSucceed = MessageStatus("succeed")
	// MessageStatusError ...
	MessageStatusError = MessageStatus("error")
)
View Source
const (
	// TemplateStatusActive ...
	TemplateStatusActive = TemplateStatus("active")
	// TemplateStatusUnactive ...
	TemplateStatusUnactive = TemplateStatus("inactive")
	// TemplateTypeItem ...
	TemplateTypeItem = TemplateType("item")
	// TemplateTypeTemplate ...
	TemplateTypeTemplate = TemplateType("template")
)
View Source
const HistoryMax = 8

HistoryMax ...

Variables

This section is empty.

Functions

func PreviewTemplate added in v0.0.17

func PreviewTemplate(items []*Template, template *TemplateContent) (data string, err error)

PreviewTemplate ...

func TemplateGetParents added in v0.0.17

func TemplateGetParents(items Templates, result *Templates, s string)

TemplateGetParents ...

Types

type Action added in v0.5.0

type Action struct {
	Id               int64            `json:"id"`
	Name             string           `json:"name" validate:"required,lte=255"`
	Script           *Script          `json:"script"`
	ScriptId         *int64           `json:"script_id"`
	Entity           *Entity          `json:"entity"`
	EntityId         *common.EntityId `json:"entity_id"`
	EntityActionName *string          `json:"entity_action_name"`
	AreaId           *int64           `json:"area_id"`
	Area             *Area            `json:"area"`
	Description      string           `json:"description"`
	CreatedAt        time.Time        `json:"created_at"`
	UpdatedAt        time.Time        `json:"updated_at"`
}

Action ...

type AlexaIntent added in v0.3.0

type AlexaIntent struct {
	Name         string    `json:"name"`
	AlexaSkillId int64     `json:"alexa_skill_id" validate:"required"`
	Script       *Script   `json:"script"`
	ScriptId     int64     `json:"script_id" validate:"required"`
	Description  string    `json:"description"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

AlexaIntent ...

type AlexaSkill added in v0.3.0

type AlexaSkill struct {
	Id          int64             `json:"id"`
	SkillId     string            `json:"skill_id" validate:"required"`
	Description string            `json:"description"`
	Status      common.StatusType `json:"status" validate:"required"`
	Intents     []*AlexaIntent    `json:"intents"`
	Script      *Script           `json:"script"`
	ScriptId    *int64            `json:"script_id"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

AlexaSkill ...

type AppConfig added in v0.5.0

type AppConfig struct {
	PgUser                         string         `json:"pg_user" env:"PG_USER"`
	PgPass                         string         `json:"pg_pass" env:"PG_PASS"`
	PgHost                         string         `json:"pg_host" env:"PG_HOST"`
	PgName                         string         `json:"pg_name" env:"PG_NAME"`
	PgPort                         string         `json:"pg_port" env:"PG_PORT"`
	SnapshotDir                    string         `json:"snapshot_dir" env:"SNAPSHOT_DIR"`
	Mode                           common.RunMode `json:"mode" env:"MODE"`
	AlexaHost                      string         `json:"alexa_host" env:"ALEXA_HOST"`
	Lang                           string         `json:"lang" env:"LANG"`
	Domain                         string         `json:"domain" env:"DOMAIN"`
	PgMaxIdleConns                 int            `json:"pg_max_idle_conns" env:"PG_MAX_IDLE_CONNS"`
	PgMaxOpenConns                 int            `json:"pg_max_open_conns" env:"PG_MAX_OPEN_CONNS"`
	PgConnMaxLifeTime              int            `json:"pg_conn_max_life_time" env:"PG_CONN_MAX_LIFE_TIME"`
	MqttPort                       int            `json:"mqtt_port" env:"MQTT_PORT"`
	MqttRetryInterval              time.Duration  `json:"mqtt_retry_interval" env:"MQTT_RETRY_INTERVAL"`
	MqttRetryCheckInterval         time.Duration  `json:"mqtt_retry_check_interval" env:"MQTT_RETRY_CHECK_INTERVAL"`
	MqttSessionExpiryInterval      time.Duration  `json:"mqtt_session_expiry_interval" env:"MQTT_SESSION_EXPIRY_INTERVAL"`
	MqttSessionExpireCheckInterval time.Duration  `json:"mqtt_session_expire_check_interval" env:"MQTT_SESSION_EXPIRE_CHECK_INTERVAL"`
	MqttMaxInflight                int            `json:"mqtt_max_inflight" env:"MQTT_MAX_INFLIGHT"`
	MqttMaxAwaitRel                int            `json:"mqtt_max_await_rel" env:"MQTT_MAX_AWAIT_REL"`
	MqttMaxMsgQueue                int            `json:"mqtt_max_msg_queue" env:"MQTT_MAX_MSG_QUEUE"`
	MqttDeliverMode                int            `json:"mqtt_deliver_mode" env:"MQTT_DELIVER_MODE"`
	AlexaPort                      int            `json:"alexa_port" env:"ALEXA_PORT"`
	ApiHttpPort                    int            `json:"api_http_port" env:"API_HTTP_PORT"`
	ApiHttpsPort                   int            `json:"api_https_port" env:"API_HTTPS_PORT"`
	PgDebug                        bool           `json:"pg_debug" env:"PG_DEBUG"`
	AutoMigrate                    bool           `json:"auto_migrate" env:"AUTO_MIGRATE"`
	MqttQueueQos0Messages          bool           `json:"mqtt_queue_qos_0_messages" env:"MQTT_QUEUE_QOS_0_MESSAGES"`
	Logging                        bool           `json:"logging" env:"LOGGING"`
	ColoredLogging                 bool           `json:"colored_logging" env:"COLORED_LOGGING"`
	ApiSwagger                     bool           `json:"api_swagger" env:"API_SWAGGER"`
	ApiDebug                       bool           `json:"api_debug" env:"API_DEBUG"`
	ApiGzip                        bool           `json:"api_gzip" env:"API_GZIP"`
	RootMode                       bool           `json:"root_mode" env:"ROOT_MODE"`
	RootSecret                     string         `json:"root_secret" env:"ROOT_SECRET"`
	Pprof                          bool           `json:"pprof" env:"PPROF"`
	GateClientId                   string         `json:"gate_client_id" env:"GATE_CLIENT_ID"`
	GateClientSecretKey            string         `json:"gate_client_secret_key" env:"GATE_CLIENT_SECRET_KEY"`
	GateClientServerHost           string         `json:"gate_client_server_host" env:"GATE_CLIENT_SERVER_HOST"`
	GateClientServerPort           int            `json:"gate_client_server_port" env:"GATE_CLIENT_SERVER_PORT"`
	GateClientPoolIdleSize         int            `json:"gate_client_pool_idle_size" env:"GATE_CLIENT_POOL_IDLE_SIZE"`
	GateClientPoolMaxSize          int            `json:"gate_client_pool_max_size" env:"GATE_CLIENT_POOL_MAX_SIZE"`
}

AppConfig ...

type Area added in v0.5.0

type Area struct {
	Polygon     []Point   `json:"polygon"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Name        string    `json:"name" validate:"required"`
	Description string    `json:"description"`
	Center      Point     `json:"center"`
	Id          int64     `json:"id"`
	Zoom        float32   `json:"zoom"`
	Resolution  float32   `json:"resolution"`
}

Area ...

type AreaPayload added in v0.12.0

type AreaPayload struct {
	Center     Point   `json:"center"`
	Zoom       float32 `json:"zoom"`
	Resolution float32 `json:"resolution"`
}

type Attribute added in v0.5.0

type Attribute struct {
	Name  string               `json:"name"`
	Type  common.AttributeType `json:"type"`
	Value interface{}          `json:"value,omitempty"`
}

Attribute ...

func (Attribute) ArrayString added in v0.13.0

func (a Attribute) ArrayString() (result []string)

ArrayString ...

func (*Attribute) Bool added in v0.5.0

func (a *Attribute) Bool() bool

Bool ...

func (Attribute) Compare added in v0.6.0

func (a Attribute) Compare(b *Attribute) (ident bool)

Compare ...

func (Attribute) Decrypt added in v0.12.0

func (a Attribute) Decrypt() string

Decrypt ...

func (*Attribute) Float64 added in v0.5.0

func (a *Attribute) Float64() float64

Float64 ...

func (Attribute) Int64 added in v0.5.0

func (a Attribute) Int64() int64

Int64 ...

func (Attribute) Map added in v0.5.0

func (a Attribute) Map() Attributes

Map ...

func (Attribute) Point added in v0.12.0

func (a Attribute) Point() (point Point)

Point ...

func (Attribute) String added in v0.5.0

func (a Attribute) String() string

String ...

func (*Attribute) Time added in v0.5.0

func (a *Attribute) Time() time.Time

Time ...

type AttributeValue added in v0.5.0

type AttributeValue map[string]interface{}

AttributeValue ...

type Attributes added in v0.5.0

type Attributes map[string]*Attribute

Attributes ...

func (Attributes) Copy added in v0.5.0

func (a Attributes) Copy() (copy Attributes)

Copy ...

func (Attributes) Deserialize added in v0.5.0

func (a Attributes) Deserialize(data AttributeValue) (changed bool, err error)

Deserialize ...

func (Attributes) Serialize added in v0.5.0

func (a Attributes) Serialize() (to AttributeValue)

Serialize ...

func (Attributes) Signature added in v0.5.0

func (a Attributes) Signature() (signature Attributes)

Signature ...

type Backup added in v0.12.0

type Backup struct {
	ModTime  time.Time
	Name     string
	MimeType string
	Size     int64
	FileMode fs.FileMode
}

type Backups added in v0.12.0

type Backups []*Backup

func (Backups) Len added in v0.12.0

func (l Backups) Len() int

func (Backups) Less added in v0.12.0

func (l Backups) Less(i, j int) bool

func (Backups) Swap added in v0.12.0

func (l Backups) Swap(i, j int)

type Condition added in v0.5.0

type Condition struct {
	Id          int64     `json:"id"`
	Name        string    `json:"name" validate:"required,lte=255"`
	Script      *Script   `json:"script"`
	ScriptId    *int64    `json:"script_id" validate:"required"`
	AreaId      *int64    `json:"area_id"`
	Area        *Area     `json:"area"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Condition ...

type Dashboard added in v0.6.0

type Dashboard struct {
	Tabs        []*DashboardTab             `json:"tabs"`
	CreatedAt   time.Time                   `json:"created_at"`
	UpdatedAt   time.Time                   `json:"updated_at"`
	Name        string                      `json:"name" validate:"required"`
	Description string                      `json:"description"`
	Id          int64                       `json:"id"`
	AreaId      *int64                      `json:"area_id"`
	Area        *Area                       `json:"area"`
	Entities    map[common.EntityId]*Entity `json:"entities"`
	Enabled     bool                        `json:"enabled"`
}

Dashboard ...

type DashboardCard added in v0.6.0

type DashboardCard struct {
	Payload        json.RawMessage             `json:"payload"`
	Items          []*DashboardCardItem        `json:"items"`
	CreatedAt      time.Time                   `json:"created_at"`
	UpdatedAt      time.Time                   `json:"updated_at"`
	Title          string                      `json:"title" validate:"required"`
	Id             int64                       `json:"id"`
	Height         int                         `json:"height" validate:"required"`
	Width          int                         `json:"width" validate:"required"`
	Background     *string                     `json:"background"`
	Weight         int                         `json:"weight"`
	DashboardTabId int64                       `json:"dashboard_tab_id" validate:"required"`
	DashboardTab   *DashboardTab               `json:"dashboard_tab"`
	Entities       map[common.EntityId]*Entity `json:"entities"`
	EntityId       *common.EntityId            `json:"entity_id"`
	Entity         *Entity                     `json:"entity"`
	Enabled        bool                        `json:"enabled"`
	Hidden         bool                        `json:"hidden"`
}

DashboardCard ...

type DashboardCardItem added in v0.6.0

type DashboardCardItem struct {
	Payload         json.RawMessage  `json:"payload"`
	CreatedAt       time.Time        `json:"created_at"`
	UpdatedAt       time.Time        `json:"updated_at"`
	Title           string           `json:"title" validate:"required"`
	Type            string           `json:"type" validate:"required"`
	Id              int64            `json:"id"`
	Weight          int              `json:"weight"`
	DashboardCardId int64            `json:"dashboard_card_id" validate:"required"`
	DashboardCard   *DashboardCard   `json:"dashboard_card"`
	EntityId        *common.EntityId `json:"entity_id"`
	Entity          *Entity          `json:"entity"`
	Enabled         bool             `json:"enabled"`
	Hidden          bool             `json:"hidden"`
	Frozen          bool             `json:"frozen"`
}

DashboardCardItem ...

type DashboardTab added in v0.6.0

type DashboardTab struct {
	Payload     json.RawMessage             `json:"payload"`
	Cards       []*DashboardCard            `json:"cards"`
	CreatedAt   time.Time                   `json:"created_at"`
	UpdatedAt   time.Time                   `json:"updated_at"`
	Name        string                      `json:"name" validate:"required"`
	Icon        string                      `json:"icon"`
	Id          int64                       `json:"id"`
	ColumnWidth int                         `json:"column_width"`
	Background  *string                     `json:"background"`
	Weight      int                         `json:"weight"`
	DashboardId int64                       `json:"dashboard_id" validate:"required"`
	Dashboard   *Dashboard                  `json:"dashboard"`
	Entities    map[common.EntityId]*Entity `json:"entities"`
	Gap         bool                        `json:"gap"`
	Enabled     bool                        `json:"enabled"`
}

DashboardTab ...

type EntitiesStatistic added in v0.17.0

type EntitiesStatistic struct {
	Total  int32
	Used   int32
	Unused int32
}

type Entity added in v0.5.0

type Entity struct {
	Actions      []*EntityAction  `json:"actions"`
	States       []*EntityState   `json:"states"`
	Metrics      []*Metric        `json:"metrics"`
	Scripts      []*Script        `json:"scripts"`
	CreatedAt    time.Time        `json:"created_at"`
	UpdatedAt    time.Time        `json:"updated_at"`
	Id           common.EntityId  `json:"id"`
	Description  string           `json:"description"`
	PluginName   string           `json:"plugin_name" validate:"required"`
	Icon         *string          `json:"icon"`
	Image        *Image           `json:"image"`
	ImageId      *int64           `json:"image_id"`
	Area         *Area            `json:"area"`
	AreaId       *int64           `json:"area_id"`
	Attributes   Attributes       `json:"attributes"`
	Settings     Attributes       `json:"settings"`
	ParentId     *common.EntityId `json:"parent_id"`
	Storage      []*EntityStorage `json:"storage"`
	Hidden       bool             `json:"hidden"`
	AutoLoad     bool             `json:"auto_load"`
	IsLoaded     bool             `json:"is_loaded"`
	RestoreState bool             `json:"restore_state"`
	Tags         []*Tag           `json:"tags"`
}

Entity ...

type EntityAction added in v0.5.0

type EntityAction struct {
	Id          int64           `json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Icon        *string         `json:"icon"`
	EntityId    common.EntityId `json:"entity_id" validate:"required"`
	Image       *Image          `json:"image"`
	ImageId     *int64          `json:"image_id" validate:"required"`
	Script      *Script         `json:"script"`
	ScriptId    *int64          `json:"script_id" validate:"required"`
	Type        string          `json:"type"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

EntityAction ...

func (*EntityAction) Short added in v0.5.0

func (a *EntityAction) Short() (short EntityActionShort)

Short ...

type EntityActionShort added in v0.5.0

type EntityActionShort struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	ImageUrl    *string `json:"image_url"`
	Icon        *string `json:"icon"`
}

EntityActionShort ...

type EntityPayload added in v0.5.0

type EntityPayload struct {
	AttributeSignature Attributes `json:"attribute_signature"`
}

EntityPayload ...

type EntitySettings added in v0.5.0

type EntitySettings struct {
	Settings Attributes `json:"settings"`
}

EntitySettings ...

type EntityShort added in v0.5.0

type EntityShort struct {
	Id          common.EntityId     `json:"id"`
	Type        string              `json:"type"`
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Icon        *string             `json:"icon"`
	ImageUrl    *string             `json:"image_url"`
	Actions     []EntityActionShort `json:"actions"`
	States      []EntityStateShort  `json:"states"`
	State       *EntityStateShort   `json:"state"`
	Attributes  Attributes          `json:"attributes"`
	Settings    Attributes          `json:"settings"`
	Area        *Area               `json:"area"`
	Metrics     []*Metric           `json:"metrics"`
	Hidden      bool                `json:"hidden"`
}

todo: check EntityShort ...

type EntityState added in v0.5.0

type EntityState struct {
	Id          int64           `json:"id"`
	Name        string          `json:"name" validate:"max=254;required"`
	Description string          `json:"description"`
	Icon        *string         `json:"icon"`
	EntityId    common.EntityId `json:"entity_id" validate:"required"`
	Image       *Image          `json:"image"`
	ImageId     *int64          `json:"image_id" validate:"required"`
	Style       string          `json:"style"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

EntityState ...

func (*EntityState) Short added in v0.5.0

func (m *EntityState) Short() (short EntityStateShort)

Short ...

type EntityStateShort added in v0.5.0

type EntityStateShort struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	ImageUrl    *string `json:"image_url"`
	Icon        *string `json:"icon"`
}

EntityStateShort ...

type EntityStorage added in v0.5.0

type EntityStorage struct {
	Id                int64
	State             string
	StateDescription  string
	EntityId          common.EntityId
	EntityDescription string
	Attributes        AttributeValue
	CreatedAt         time.Time
}

EntityStorage ...

type EntityStorageList added in v0.12.0

type EntityStorageList struct {
	Items      []*EntityStorage
	Attributes map[common.EntityId]Attributes
}

type GateConfig added in v0.13.0

type GateConfig struct {
	ApiHttpPort      int    `json:"api_http_port" env:"API_HTTP_PORT"`
	ApiHttpsPort     int    `json:"api_https_port" env:"API_HTTPS_PORT"`
	ApiDebug         bool   `json:"api_debug" env:"API_DEBUG"`
	ApiGzip          bool   `json:"api_gzip" env:"API_GZIP"`
	Domain           string `json:"domain" env:"DOMAIN"`
	Pprof            bool   `json:"pprof" env:"PPROF"`
	Https            bool   `json:"https" env:"HTTPS"`
	ProxyTimeout     int    `json:"proxy_timeout" env:"PROXY_TIMEOUT"`
	ProxyIdleTimeout int    `json:"proxy_idle_timeout" env:"PROXY_IDLE_TIMEOUT"`
	ProxySecretKey   string `json:"proxy_secret_key" env:"PROXY_SECRET_KEY"`
}

GateConfig ...

func (*GateConfig) ApiFullAddress added in v0.13.0

func (c *GateConfig) ApiFullAddress() (scheme string)

func (*GateConfig) ApiScheme added in v0.13.0

func (c *GateConfig) ApiScheme() (scheme string)

type GeoLocation added in v0.5.0

type GeoLocation struct {
	Status      string  `json:"status"`
	Country     string  `json:"country"`
	CountryCode string  `json:"countryCode"`
	Region      string  `json:"region"`
	RegionName  string  `json:"regionName"`
	City        string  `json:"city"`
	Zip         string  `json:"zip"`
	Lat         float64 `json:"lat"`
	Lon         float64 `json:"lon"`
	Timezone    string  `json:"timezone"`
	Isp         string  `json:"isp"`
	Org         string  `json:"org"`
	As          string  `json:"as"`
	Query       string  `json:"query"`
}

"status": "success", "country": "Russia", "countryCode": "RU", "region": "NVS", "regionName": "Novosibirsk Oblast", "city": "Novosibirsk", "zip": "630008", "lat": 54.9022, "lon": 83.0335, "timezone": "Asia/Novosibirsk", "isp": "Novotelecom Ltd.", "org": "Novotelecom ltd.", "as": "AS31200 Novotelecom Ltd", "query": "xxx.xxx.xxx.xxx"

type Image

type Image struct {
	Id        int64     `json:"id"`
	Thumb     string    `json:"thumb"`
	Url       string    `json:"url"`
	Image     string    `json:"image"`
	MimeType  string    `json:"mime_type"`
	Title     string    `json:"title"`
	Size      int64     `json:"size"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

Image ...

func UploadImage added in v0.12.0

func UploadImage(ctx context.Context, reader *bufio.Reader, fileName string) (newFile *Image, err error)

UploadImage ...

type ImageFilterList

type ImageFilterList struct {
	Date  string `json:"date"`
	Count int    `json:"count"`
}

ImageFilterList ...

type Keys added in v0.9.5

type Keys struct {
	Auth   string `json:"auth"`
	P256dh string `json:"p256dh"`
}

Keys are the base64 encoded values from PushSubscription.getKey()

type Log

type Log struct {
	Id        int64           `json:"id"`
	Body      string          `json:"body" validate:"required"`
	Level     common.LogLevel `json:"level" validate:"required"`
	Owner     string          `json:"owner"`
	CreatedAt time.Time       `json:"created_at"`
}

Log ...

type LogQuery

type LogQuery struct {
	StartDate *time.Time `json:"start_date"`
	EndDate   *time.Time `json:"end_date"`
	Levels    []string   `json:"levels"`
}

LogQuery ...

type Message added in v0.0.17

type Message struct {
	Id         int64          `json:"id"`
	Type       string         `json:"type"`
	Attributes AttributeValue `json:"attributes"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
}

Message ...

type MessageDelivery added in v0.0.17

type MessageDelivery struct {
	Id                 int64            `json:"id"`
	Message            *Message         `json:"message"`
	MessageId          int64            `json:"message_id"`
	Address            string           `json:"address"`
	EntityId           *common.EntityId `json:"entity_id"`
	Status             MessageStatus    `json:"status"`
	ErrorMessageStatus *string          `json:"error_message_status"`
	ErrorMessageBody   *string          `json:"error_message_body"`
	CreatedAt          time.Time        `json:"created_at"`
	UpdatedAt          time.Time        `json:"updated_at"`
}

MessageDelivery ...

type MessageDeliveryQuery added in v0.10.0

type MessageDeliveryQuery struct {
	StartDate *time.Time `json:"start_date"`
	EndDate   *time.Time `json:"end_date"`
	Types     []string   `json:"types"`
}

MessageDeliveryQuery ...

type MessagePayload added in v0.5.0

type MessagePayload struct {
	AttributeSignature Attributes `json:"attribute_signature"`
}

MessagePayload ...

type MessageStatus added in v0.0.17

type MessageStatus string

MessageStatus ...

type MessageType added in v0.0.17

type MessageType string

MessageType ...

type Metric added in v0.5.0

type Metric struct {
	Id          int64             `json:"id"`
	Name        string            `json:"name" validate:"max=254;required"`
	Description string            `json:"description" validate:"max=254"`
	Options     MetricOptions     `json:"options"`
	Data        []*MetricDataItem `json:"data"`
	Type        common.MetricType `json:"type" validate:"required"`
	Ranges      []string          `json:"ranges"`
	UpdatedAt   time.Time         `json:"updated_at"`
	CreatedAt   time.Time         `json:"created_at"`
}

Metric ...

func (*Metric) RangesByType added in v0.5.0

func (d *Metric) RangesByType() []string

RangesByType ...

type MetricDataItem added in v0.5.0

type MetricDataItem struct {
	Value    map[string]interface{} `json:"value"`
	Metric   *Metric                `json:"metric"`
	MetricId int64                  `json:"metric_id"`
	Time     time.Time              `json:"time"`
}

MetricDataItem ...

type MetricOptions added in v0.5.0

type MetricOptions struct {
	Items []MetricOptionsItem `json:"items"`
}

MetricOptions ...

type MetricOptionsItem added in v0.5.0

type MetricOptionsItem struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Color       string `json:"color"`
	Translate   string `json:"translate"`
	Label       string `json:"label"`
}

MetricOptionsItem ...

type NewNotifrMessage added in v0.0.17

type NewNotifrMessage struct {
	Type         string                 `json:"type"`
	BodyType     string                 `json:"body_type"`
	EmailFrom    *string                `json:"email_from"`
	EmailSubject *string                `json:"email_subject"`
	EmailBody    *string                `json:"email_body"`
	Template     *string                `json:"template"`
	SmsText      *string                `json:"sms_text"`
	SlackText    *string                `json:"slack_text"`
	TelegramText *string                `json:"telegram_text"`
	Webpush      *string                `json:"webpush"`
	Params       map[string]interface{} `json:"params"`
	Address      string                 `json:"address"`
	ChatID       int64                  `json:"chat_id"`
}

NewNotifrMessage ...

type NewTask added in v0.12.0

type NewTask struct {
	TriggerIds   []int64              `json:"triggers" validate:"dive"`
	ConditionIds []int64              `json:"conditions" validate:"dive"`
	ActionIds    []int64              `json:"actions" validate:"dive"`
	Name         string               `json:"name" validate:"required,lte=255"`
	Description  string               `json:"description" validate:"lte=255"`
	Condition    common.ConditionType `json:"condition" validate:"required,oneof=or and"`
	Area         *Area                `json:"area"`
	AreaId       *int64               `json:"area_id"`
	Enabled      bool                 `json:"enabled"`
	IsLoaded     bool                 `json:"is_loaded"`
}

NewTask ...

type NewTrigger added in v0.13.2

type NewTrigger struct {
	Name        string     `json:"name" validate:"required,lte=255"`
	PluginName  string     `json:"plugin_name" validate:"required,lte=255"`
	Description string     `json:"description"`
	EntityIds   []string   `json:"entity_ids"`
	ScriptId    *int64     `json:"script_id"`
	Payload     Attributes `json:"payload"`
	AreaId      *int64     `json:"area_id"`
	Enabled     bool       `json:"enabled"`
	IsLoaded    bool       `json:"is_loaded"`
}

NewTrigger ...

type Permission

type Permission struct {
	Id          int64  `json:"id"`
	RoleName    string `json:"role_name"`
	PackageName string `json:"package_name"`
	LevelName   string `json:"level_name"`
}

Permission ...

type Plugin added in v0.5.0

type Plugin struct {
	Name     string         `json:"name"`
	Version  string         `json:"version"`
	Settings AttributeValue `json:"settings"`
	Enabled  bool           `json:"enabled"`
	System   bool           `json:"system"`
	Actor    bool           `json:"actor"`
	IsLoaded bool           `json:"is_loaded"`
}

Plugin ...

type PluginOptions added in v0.5.0

type PluginOptions struct {
	Javascript         PluginOptionsJs              `json:"javascript"`
	ActorAttrs         Attributes                   `json:"actor_attrs"`
	ActorActions       map[string]EntityActionShort `json:"actor_actions"`
	ActorStates        map[string]EntityStateShort  `json:"actor_states"`
	ActorSetts         Attributes                   `json:"actor_setts"`
	Setts              Attributes                   `json:"setts"`
	Triggers           bool                         `json:"triggers"`
	Actors             bool                         `json:"actors"`
	ActorCustomAttrs   bool                         `json:"actor_custom_attrs"`
	ActorCustomActions bool                         `json:"actor_custom_actions"`
	ActorCustomStates  bool                         `json:"actor_custom_states"`
	ActorCustomSetts   bool                         `json:"actor_custom_setts"`
}

PluginOptions ...

type PluginOptionsJs added in v0.12.0

type PluginOptionsJs struct {
	Methods   map[string]string `json:"methods"`
	Objects   map[string]string `json:"objects"`
	Variables map[string]string `json:"variables"`
}

type PluginSettings added in v0.5.0

type PluginSettings struct {
	Settings Attributes `json:"settings"`
}

PluginSettings ...

type Plugins added in v0.5.2

type Plugins []*Plugin

Plugins ...

func (Plugins) Len added in v0.5.2

func (i Plugins) Len() int

Len ...

func (Plugins) Less added in v0.5.2

func (i Plugins) Less(a, b int) bool

Less ...

func (Plugins) Swap added in v0.5.2

func (i Plugins) Swap(a, b int)

Swap ...

type Point added in v0.12.0

type Point struct {
	Lon float64 `json:"lon"`
	Lat float64 `json:"lat"`
}

type RegionInfo added in v0.5.0

type RegionInfo struct {
	Ip                 string  `json:"ip"`
	Version            string  `json:"version"`
	City               string  `json:"city"`
	Region             string  `json:"region"`
	RegionCode         string  `json:"region_code"`
	Country            string  `json:"country"`
	CountryName        string  `json:"country_name"`
	CountryCode        string  `json:"country_code"`
	CountryCodeIso3    string  `json:"country_code_iso3"`
	CountryCapital     string  `json:"country_capital"`
	CountryTld         string  `json:"country_tld"`
	ContinentCode      string  `json:"continent_code"`
	Postal             string  `json:"postal"`
	Timezone           string  `json:"timezone"`
	UtcOffset          string  `json:"utc_offset"`
	CountryCallingCode string  `json:"country_calling_code"`
	Currency           string  `json:"currency"`
	CurrencyName       string  `json:"currency_name"`
	Languages          string  `json:"languages"`
	Asn                string  `json:"asn"`
	Org                string  `json:"org"`
	Latitude           float64 `json:"latitude"`
	Longitude          float64 `json:"longitude"`
	CountryArea        float64 `json:"country_area"`
	CountryPopulation  float64 `json:"country_population"`
	InEu               bool    `json:"in_eu"`
}

"ip": "xxx.xxx.xxx.xxx", "version": "IPv4", "city": "Novosibirsk", "region": "Novosibirsk Oblast", "region_code": "NVS", "country": "RU", "country_name": "Russia", "country_code": "RU", "country_code_iso3": "RUS", "country_capital": "Moscow", "country_tld": ".ru", "continent_code": "EU", "in_eu": false, "postal": "630009", "latitude": 54.9022, "longitude": 83.0335, "timezone": "Asia/Novosibirsk", "utc_offset": "+0700", "country_calling_code": "+7", "currency": "RUB", "currency_name": "Ruble", "languages": "ru,tt,xal,cau,ady,kv,ce,tyv,cv,udm,tut,mns,bua,myv,mdf,chm,ba,inh,tut,kbd,krc,av,sah,nog", "country_area": 17100000.0, "country_population": 144478050.0, "asn": "AS31200", "org": "Novotelecom Ltd"

type Role

type Role struct {
	Name        string              `json:"name" validate:"max=254,required"`
	Description string              `json:"description"`
	Parent      *Role               `json:"parent"`
	Children    []*Role             `json:"children"`
	AccessList  map[string][]string `json:"access_list"`
	CreatedAt   time.Time           `json:"created_at"`
	UpdatedAt   time.Time           `json:"updated_at"`
}

Role ...

type RunHistory added in v0.5.0

type RunHistory []RunStory

RunHistory ...

type RunStory added in v0.5.0

type RunStory struct {
	Id    int64      `json:"id"`
	Start time.Time  `json:"start"`
	End   *time.Time `json:"end"`
}

RunStory ...

type Script

type Script struct {
	Id          int64          `json:"id"`
	Lang        ScriptLang     `json:"lang" validate:"required"`
	Name        string         `json:"name" validate:"max=254,required"`
	Source      string         `json:"source"`
	Description string         `json:"description"`
	Compiled    string         `json:"-"`
	Versions    ScriptVersions `json:"versions"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Info        *ScriptInfo    `json:"info"`
}

Script ...

type ScriptInfo added in v0.11.0

type ScriptInfo struct {
	AlexaIntents         int `json:"alexa_intents"`
	EntityActions        int `json:"entity_actions"`
	EntityScripts        int `json:"entity_scripts"`
	AutomationTriggers   int `json:"automation_triggers"`
	AutomationConditions int `json:"automation_conditions"`
	AutomationActions    int `json:"automation_actions"`
}

type ScriptVersion added in v0.12.0

type ScriptVersion struct {
	Id        int64      `json:"id"`
	Lang      ScriptLang `json:"lang" validate:"required"`
	Source    string     `json:"source"`
	CreatedAt time.Time  `json:"created_at"`
}

type ScriptVersions added in v0.12.0

type ScriptVersions []*ScriptVersion

func (ScriptVersions) Len added in v0.12.0

func (l ScriptVersions) Len() int

func (ScriptVersions) Less added in v0.12.0

func (l ScriptVersions) Less(i, j int) bool

func (ScriptVersions) Swap added in v0.12.0

func (l ScriptVersions) Swap(i, j int)

type ScriptsStatistic added in v0.12.0

type ScriptsStatistic struct {
	Total        int32
	Used         int32
	Unused       int32
	CoffeeScript int32
	TypeScript   int32
	JavaScript   int32
}

type Statistic added in v0.12.0

type Statistic struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Value       int32  `json:"value"`
	Diff        int32  `json:"diff"`
}

type Subscription added in v0.9.5

type Subscription struct {
	Endpoint string `json:"endpoint"`
	Keys     Keys   `json:"keys"`
}

Subscription represents a PushSubscription object from the Push API

type Tag added in v0.17.0

type Tag struct {
	Id   int64
	Name string `validate:"required"`
}

type Task added in v0.5.0

type Task struct {
	Triggers    []*Trigger           `json:"triggers" validate:"dive"`
	Conditions  []*Condition         `json:"conditions" validate:"dive"`
	Actions     []*Action            `json:"actions" validate:"dive"`
	Telemetry   telemetry.Telemetry  `json:"telemetry"`
	CreatedAt   time.Time            `json:"created_at"`
	UpdatedAt   time.Time            `json:"updated_at"`
	Name        string               `json:"name" validate:"required,lte=255"`
	Description string               `json:"description" validate:"lte=255"`
	Condition   common.ConditionType `json:"condition" validate:"required,oneof=or and"`
	Id          int64                `json:"id"`
	Area        *Area                `json:"area"`
	AreaId      *int64               `json:"area_id"`
	Enabled     bool                 `json:"enabled"`
	IsLoaded    bool                 `json:"is_loaded"`
}

Task ...

func (*Task) AddAction added in v0.5.0

func (t *Task) AddAction(a *Action)

AddAction ...

func (*Task) AddCondition added in v0.5.0

func (t *Task) AddCondition(c *Condition)

AddCondition ...

func (*Task) AddTrigger added in v0.5.0

func (t *Task) AddTrigger(tr *Trigger)

AddTrigger ...

type TelegramChat added in v0.5.0

type TelegramChat struct {
	EntityId  common.EntityId
	ChatId    int64
	Username  string
	CreatedAt time.Time
}

TelegramChat ...

type Template added in v0.0.17

type Template struct {
	Validity
	Name         string         `json:"name" validate:"required,max=64" `
	Description  string         `json:"description"`
	Content      string         `json:"content"`
	Status       TemplateStatus `json:"status" validate:"required,max=64"`
	Type         TemplateType   `json:"type" validate:"required,max=64"`
	ParentsCount int            `json:"parents_count"`
	ParentName   *string        `json:"parent"`
	Markers      []string       `json:"markers"`
	CreatedAt    time.Time      `json:"created_at"`
	UpdatedAt    time.Time      `json:"updated_at"`
}

Template ...

func (*Template) GetMarkers added in v0.0.17

func (i *Template) GetMarkers(items []*Template, template *TemplateContent) (markers []string, err error)

GetMarkers ...

func (*Template) GetTemplate added in v0.0.17

func (i *Template) GetTemplate() (tpl *TemplateContent, err error)

GetTemplate ...

type TemplateContent added in v0.0.17

type TemplateContent struct {
	Items  []string         `json:"items"`
	Title  string           `json:"title"`
	Fields []*TemplateField `json:"fields"`
}

TemplateContent ...

type TemplateField added in v0.0.17

type TemplateField struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

TemplateField ...

type TemplateRender added in v0.0.17

type TemplateRender struct {
	Subject string `json:"subject"`
	Body    string `json:"body"`
}

TemplateRender ...

func RenderTemplate added in v0.0.17

func RenderTemplate(items []*Template, template *TemplateContent, params map[string]interface{}) (render *TemplateRender, err error)

RenderTemplate ...

type TemplateStatus added in v0.0.17

type TemplateStatus string

TemplateStatus ...

func (TemplateStatus) String added in v0.0.17

func (s TemplateStatus) String() string

String ...

type TemplateTree added in v0.0.17

type TemplateTree struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Status      string          `json:"status"`
	Nodes       []*TemplateTree `json:"nodes"`
}

TemplateTree ...

type TemplateType added in v0.0.17

type TemplateType string

TemplateType ...

func (TemplateType) String added in v0.0.17

func (t TemplateType) String() string

String ...

type Templates added in v0.0.17

type Templates []*Template

Templates ...

func (Templates) Len added in v0.0.17

func (i Templates) Len() int

Len ...

func (Templates) Less added in v0.0.17

func (i Templates) Less(a, b int) bool

Less ...

func (Templates) Swap added in v0.0.17

func (i Templates) Swap(a, b int)

Swap ...

type Trigger added in v0.5.0

type Trigger struct {
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	Name        string     `json:"name" validate:"required,lte=255"`
	PluginName  string     `json:"plugin_name" validate:"required,lte=255"`
	Description string     `json:"description"`
	Id          int64      `json:"id"`
	Entities    []*Entity  `json:"entities" validate:"dive"`
	Script      *Script    `json:"script"`
	ScriptId    *int64     `json:"script_id"`
	Payload     Attributes `json:"payload"`
	AreaId      *int64     `json:"area_id"`
	Area        *Area      `json:"area"`
	Enabled     bool       `json:"enabled"`
	IsLoaded    bool       `json:"is_loaded"`
}

Trigger ...

type TriggerPayload added in v0.5.0

type TriggerPayload struct {
	Obj Attributes `json:"obj"`
}

TriggerPayload ...

type UpdateTask added in v0.12.0

type UpdateTask struct {
	TriggerIds   []int64 `json:"triggers" validate:"dive"`
	ConditionIds []int64 `json:"conditions" validate:"dive"`
	ActionIds    []int64 `json:"actions" validate:"dive"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
	Name         string               `json:"name" validate:"required,lte=255"`
	Description  string               `json:"description" validate:"lte=255"`
	Condition    common.ConditionType `json:"condition" validate:"required,oneof=or and"`
	Id           int64                `json:"id"`
	Area         *Area                `json:"area"`
	AreaId       *int64               `json:"area_id"`
	Enabled      bool                 `json:"enabled"`
	IsLoaded     bool                 `json:"is_loaded"`
}

UpdateTask ...

type UpdateTrigger added in v0.13.2

type UpdateTrigger struct {
	Name        string     `json:"name" validate:"required,lte=255"`
	PluginName  string     `json:"plugin_name" validate:"required,lte=255"`
	Description string     `json:"description"`
	Id          int64      `json:"id"`
	EntityIds   []string   `json:"entity_ids" validate:"dive"`
	ScriptId    *int64     `json:"script_id"`
	Payload     Attributes `json:"payload"`
	AreaId      *int64     `json:"area_id"`
	Enabled     bool       `json:"enabled"`
	IsLoaded    bool       `json:"is_loaded"`
}

UpdateTrigger ...

type User

type User struct {
	Id                  int64          `json:"id"`
	Nickname            string         `json:"nickname" validate:"required,min=3,max=255"`
	FirstName           string         `json:"first_name" validate:"max=255"`
	LastName            string         `json:"last_name" validate:"max=255"`
	EncryptedPassword   string         `json:"encrypted_password,omitempty"`
	Email               string         `json:"email" validate:"required,email"`
	Status              string         `json:"status" validate:"max=255"`
	ResetPasswordToken  string         `json:"-,omitempty"`
	AuthenticationToken *string        `json:"authentication_token,omitempty"`
	Image               *Image         `json:"image,omitempty"`
	ImageId             sql.NullInt64  `json:"image_id"`
	SignInCount         int64          `json:"sign_in_count,omitempty"`
	CurrentSignInIp     string         `json:"current_sign_in_ip,omitempty"`
	LastSignInIp        string         `json:"last_sign_in_ip,omitempty"`
	Lang                string         `json:"lang"`
	User                *User          `json:"user,omitempty"`
	UserId              sql.NullInt64  `json:"user_id"`
	Role                *Role          `json:"role"`
	RoleName            string         `json:"role_name,omitempty"`
	Meta                []*UserMeta    `json:"meta,omitempty"`
	ResetPasswordSentAt *time.Time     `json:"reset_password_sent_at,omitempty"`
	CurrentSignInAt     *time.Time     `json:"current_sign_in_at,omitempty"`
	LastSignInAt        *time.Time     `json:"last_sign_in_at,omitempty"`
	CreatedAt           time.Time      `json:"created_at,omitempty"`
	UpdatedAt           time.Time      `json:"updated_at,omitempty"`
	DeletedAt           *time.Time     `json:"deleted_at"`
	History             []*UserHistory `json:"history,omitempty"`
	Devices             []*UserDevice  `json:"devices"`
}

User ...

func (User) CheckPass

func (u User) CheckPass(password string) (ok bool)

CheckPass ...

func (*User) SetPass

func (u *User) SetPass(password string) (err error)

SetPass ...

func (*User) UpdateHistory

func (u *User) UpdateHistory(t time.Time, ipv4 string)

UpdateHistory ...

type UserDevice added in v0.9.5

type UserDevice struct {
	Id           int64
	UserId       int64
	Subscription *Subscription
	CreatedAt    time.Time
}

UserDevice ...

type UserHistory

type UserHistory struct {
	Ip   string    `json:"ip"`
	Time time.Time `json:"time"`
}

UserHistory ...

type UserMeta

type UserMeta struct {
	Id     int64  `json:"id"`
	User   *User  `json:"user"`
	UserId int64  `json:"user_id"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

UserMeta ...

type Validity added in v0.0.17

type Validity struct {
}

Validity ...

type Variable

type Variable struct {
	CreatedAt time.Time        `json:"created_at"`
	UpdatedAt time.Time        `json:"updated_at"`
	Name      string           `json:"name"`
	Value     string           `json:"value"`
	EntityId  *common.EntityId `json:"entity_id"`
	System    bool             `json:"system"`
	Tags      []*Tag           `json:"tags"`
	Changed   bool
}

Variable ...

func NewVariable added in v0.0.9

func NewVariable(name string) Variable

NewVariable ...

func (*Variable) GetBool added in v0.12.0

func (v *Variable) GetBool() bool

GetBool ...

func (*Variable) GetInt added in v0.13.0

func (v *Variable) GetInt() int

GetInt ...

func (*Variable) GetObj added in v0.0.9

func (v *Variable) GetObj(obj interface{}) (err error)

GetObj ...

func (*Variable) SetObj added in v0.0.9

func (v *Variable) SetObj(obj interface{}) (err error)

SetObj ...

type Version added in v0.0.24

type Version struct {
	Version     string `json:"version"`
	Revision    string `json:"revision"`
	RevisionURL string `json:"revision_url"`
	Generated   string `json:"generated"`
	Developers  string `json:"developers"`
	BuildNum    string `json:"build_num"`
	DockerImage string `json:"docker_image"`
}

Version ...

type Zigbee2mqtt added in v0.1.0

type Zigbee2mqtt struct {
	Devices           []*Zigbee2mqttDevice `json:"devices"`
	CreatedAt         time.Time            `json:"created_at"`
	UpdatedAt         time.Time            `json:"updated_at"`
	Name              string               `json:"name" validate:"required,max=254"`
	Login             string               `json:"login"`
	EncryptedPassword string               `json:"encrypted_password"`
	BaseTopic         string               `json:"base_topic"`
	Id                int64                `json:"id"`
	Password          *string              `json:"password"`
	Info              *Zigbee2mqttInfo     `json:"info"`
	PermitJoin        bool                 `json:"permit_join"`
}

Zigbee2mqtt ...

type Zigbee2mqttDevice added in v0.1.0

type Zigbee2mqttDevice struct {
	Id            string    `json:"id"`
	Zigbee2mqttId int64     `json:"zigbee2mqtt_id" validate:"required"`
	Name          string    `json:"name" validate:"required,max=254"`
	Type          string    `json:"type"`
	Model         string    `json:"model"`
	Description   string    `json:"description"`
	Manufacturer  string    `json:"manufacturer"`
	Functions     []string  `json:"functions"`
	ImageUrl      string    `json:"image_url"`
	Status        string    `json:"status"`
	Payload       []byte    `json:"payload"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

Zigbee2mqttDevice ...

func (*Zigbee2mqttDevice) GetImageUrl added in v0.1.0

func (d *Zigbee2mqttDevice) GetImageUrl()

GetImageUrl ...

type Zigbee2mqttInfo added in v0.12.0

type Zigbee2mqttInfo struct {
	Networkmap    string     `json:"networkmap"`
	Status        string     `json:"status"`
	LastScan      *time.Time `json:"last_scan"`
	ScanInProcess bool       `json:"scan_in_process"`
}

Jump to

Keyboard shortcuts

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