model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Type         string         `json:"type" yaml:"type"`
	DeviceKey    string         `json:"device_key" yaml:"device_key"`
	Caption      string         `json:"caption" yaml:"caption"`
	Confirm      bool           `json:"confirm" yaml:"confirm"`
	Mqtt         DeviceMqtt     `json:"mqtt" yaml:"mqtt"`
	Rest         DeviceRest     `json:"rest" yaml:"rest"`
	Optimistic   bool           `json:"optimistic" yaml:"optimistic"`
	Timeout      int64          `json:"timeout" yaml:"timeout"`
	Invert       Dictionary     `json:"invert" yaml:"invert"`
	Room         string         `json:"room" yaml:"room"`
	Supplemental []Supplemental `json:"supplemental" yaml:"supplemental"`
	Groups       []string       `json:"groups" yaml:"groups"`
	Authorities  []string       `json:"authorities" yaml:"authorities"`
	Expanded     bool           `json:"expanded" yaml:"expanded"`
	Icon         string         `json:"icon" yaml:"icon"`
}

type DeviceDto

type DeviceDto struct {
	Type         string         `json:"type"`
	DeviceKey    string         `json:"deviceKey"`
	Caption      string         `json:"caption"`
	Confirm      bool           `json:"confirm"`
	Optimistic   bool           `json:"optimistic"`
	Url          string         `json:"url"`
	Timeout      int64          `json:"timeout"`
	Invert       Dictionary     `json:"invert"`
	Room         string         `json:"room"`
	Groups       []string       `json:"groups"`
	Supplemental []Supplemental `json:"supplemental"`
	Expanded     bool           `json:"expanded"`
	Icon         string         `json:"icon"`
}

type DeviceFilter

type DeviceFilter func(device *Device) bool

type DeviceMqtt

type DeviceMqtt struct {
	Template      DeviceMqttTemplate `json:"template" yaml:"template"`
	ListenTopics  []DeviceTopic      `json:"listen_topics" yaml:"listen_topics"`
	CommandTopics Dictionary         `json:"command_topics" yaml:"command_topics"`
}

type DeviceMqttTemplate

type DeviceMqttTemplate struct {
	Name     string `json:"name" yaml:"name"`
	DeviceID string `json:"device_id" yaml:"device_id"`
}

type DeviceRest

type DeviceRest struct {
	Url             string             `json:"url" yaml:"url"`
	Template        DeviceRestTemplate `json:"template" yaml:"template"`
	CommandPaths    Dictionary         `json:"command_paths" yaml:"command_paths"`
	HandlerTemplate string             `json:"handler_template" yaml:"handler_template"`
}

type DeviceRestTemplate

type DeviceRestTemplate struct {
	Name     string `json:"name" yaml:"name"`
	DeviceID string `json:"device_id" yaml:"device_id"`
	Url      string `json:"url" yaml:"url"`
	Template string `json:"template" yaml:"template"`
}

type DeviceTopic

type DeviceTopic struct {
	Topic           string `json:"topic" yaml:"topic"`
	HandlerTemplate string `json:"handler_template" yaml:"handler_template"`
	// contains filtered or unexported fields
}

func (*DeviceTopic) Matches

func (t *DeviceTopic) Matches(topic string) bool

func (*DeviceTopic) Prepare

func (t *DeviceTopic) Prepare()

type Devices

type Devices struct {
	Devices []Device `json:"devices" yaml:"devices"`
}

type DevicesDto

type DevicesDto struct {
	Devices []DeviceDto `json:"devices"`
}

type Dictionary

type Dictionary = map[string]interface{}

type FWebSocketBroadcast

type FWebSocketBroadcast = func(dev *Device, devState interface{})

type IConfigService

type IConfigService interface {
	GetServerStatus() (*ServerStatus, error)
	GetRoomsConfig() (Dictionary, error)
	SetWebsocketStatus(connected bool)
	SetMqttStatus(connectionStatus int)
}

type IDatabaseService

type IDatabaseService interface {
	Persist()
	GetUserSettings(userName string) (*UserSettings, error)
	SaveUserSettings(name string, settings *UserSettings) error
}

type IDeviceRepo

type IDeviceRepo interface {
	ReloadDevices() error
	GetDevice(deviceKey string) (*Device, error)
	GetDevices() (*Devices, error)
}

type IDeviceService

type IDeviceService interface {
	DeviceCommand(deviceKey string, params Dictionary) bool
	DeviceGroupCommand(groupKey string, params Dictionary) bool
	DeviceStates() Dictionary
	DeviceState(deviceKey string) interface{}
	GetDevice(deviceKey string) (*Device, error)
	GetDevices() (*Devices, error)
	GetDevicesDto(filter DeviceFilter) (*DevicesDto, error)
	DeviceUpdate(dev *Device, oldState string)
	ReloadDevices() error
}

type IMqttService

type IMqttService interface {
	SetClient(client mqtt.Client)
	Publish(topic string, payload interface{}) bool
	Subscribe(topic string) bool
	SetMessageHandler(handler MqttMessageHandler)
	HandleMessage(topic string, payload []byte)
}

type INotificationRepo

type INotificationRepo interface {
	ReloadNotifications() error
	GetNotifications(deviceKey string, key string) ([]*Notification, error)
	GetAllNotifications() (*Notifications, error)
}

type INotificationService

type INotificationService interface {
	GetNotifications(deviceKey string, key string) ([]*Notification, error)
	ReloadNotifications() error
}

type IRestService

type IRestService interface {
	GetRequest(url string, device *Device) bool
	SetMessageHandler(handler RestMessageHandler)
	HandleMessage(device *Device, payload string)
}

type IServiceFactory

type IServiceFactory interface {
	GetDeviceService() IDeviceService
	GetConfigService() IConfigService
	GetMqttService() IMqttService
	GetTelegramService() ITelegramService
	GetUserService() IUserService
	GetNotificationService() INotificationService
	GetRestService() IRestService
	GetSharedMemory() ISharedMemory
	GetDatabaseService() IDatabaseService
	Finalize()
}

type ISharedMemory

type ISharedMemory interface {
	SetMem(deviceKey string, key string, value interface{})
	MarkAsUpdated(deviceKey string)
	GetLastUpdated(deviceKey string) int64
	GetMem(deviceKey string, key string) interface{}
	GetDeviceMem(deviceKey string) interface{}
	GetMemory() Dictionary
	LoadSharedMem()
	SetNotifyCallback(notifyFunc NotifyFunc)
	Persist()
}

type ITelegramBotAPI

type ITelegramBotAPI interface {
	Send(c tgbotapi.Chattable) (tgbotapi.Message, error)
}

type ITelegramService

type ITelegramService interface {
	SendMessage(message string) bool
}

type IUserRepo

type IUserRepo interface {
	ReloadUsers() error
	FindByUsername(userName string) (*User, error)
	GetUsers() (*Users, error)
}

type IUserService

type IUserService interface {
	FindByUsername(userName string) (*User, error)
	ReloadUsers() error
	SaveSettings(userName string, settings *UserSettings) error
	GetSettings(userName string) (*UserSettings, error)
}

type MqttMessageHandler

type MqttMessageHandler = func(string, []byte)

type Notification

type Notification struct {
	DeviceKey string              `json:"device_key" yaml:"device_key"`
	Trigger   NotificationTrigger `json:"trigger" yaml:"trigger"`
	Keys      []string            `json:"keys" yaml:"keys"`
	Caption   string              `json:"caption" yaml:"caption"`
	Script    string              `json:"script" yaml:"script"`
}

type NotificationTrigger

type NotificationTrigger = string
const (
	TriggerChange NotificationTrigger = "change"
	TriggerEvent  NotificationTrigger = "event"
)

type Notifications

type Notifications struct {
	Notifications []Notification `json:"notifications" yaml:"notifications"`
}

type NotifyFunc

type NotifyFunc func(deviceKey string, key string, newValue interface{}, oldValue interface{})

type RestMessageHandler

type RestMessageHandler = func(device *Device, payload string)

type ServerStatus

type ServerStatus struct {
	Websocket bool `json:"websocket"`
	Mqtt      int  `json:"mqtt"`
}

type Supplemental

type Supplemental struct {
	Field    string `json:"field" yaml:"field"`
	Caption  string `json:"caption" yaml:"caption"`
	Format   string `json:"format" yaml:"format"`
	Renderer string `json:"renderer" yaml:"renderer"`
}

type User

type User struct {
	ID          int32    `json:"id" yaml:"id"`
	Username    string   `json:"username" yaml:"username"`
	Password    string   `json:"password" yaml:"password"`
	Authorities []string `json:"authorities" yaml:"authorities"`
	Enabled     bool     `json:"enabled" yaml:"enabled"`
}

type UserSetting

type UserSetting struct {
	User  string `json:"user"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

type UserSettings

type UserSettings struct {
	Settings []UserSetting `json:"settings"`
}

func NewUserSettings

func NewUserSettings() *UserSettings

type Users

type Users struct {
	Users []User `json:"users" yaml:"users"`
}

Jump to

Keyboard shortcuts

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