internal

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PhosconUrl       = "https://phoscon.de/discover"
	DatabasePath     = "./goconz-sensors"
	DelayInSecond    = 30
	TraceHttp        = true
	HttpPort         = ":9000"
	ConfigFileName   = "./go-conz-config"
	PathToConfigFile = "."
	EnvPrefix        = "GOCONZ"
	ReadOnly         = false
)
View Source
const (
	SensorsUrl = "http://%s:%d/api/%s/sensors"
	ApiKeyUrl  = "http://%s:%d/api"
)
View Source
const (
	DbApiKey   = "apiKey"
	CountRetry = 10
)
View Source
const (
	PressureType    = "ZHAPressure"
	TemperatureType = "ZHATemperature"
	HumidityType    = "ZHAHumidity"
)

Variables

This section is empty.

Functions

func Contains

func Contains(s []string, str string) bool

Contains Check value existence in a slice

func GetConcreteKey

func GetConcreteKey(dbKey []byte) string

GetConcreteKey TODO voir si on peu virer ca pour rester encapsulé

func InitConfig

func InitConfig()

func NewApiKeyConfig

func NewApiKeyConfig(database Operable) *apiKeyConfig

func NewHttpClient

func NewHttpClient() *httpClient

func Parallelize

func Parallelize(functions ...func())

Parallelize parallelize the function calls

func RunNewPoller

func RunNewPoller(timeInterval time.Duration, function func()) *poller

RunNewPoller Run a new Poller around a lambda function, that tick every time.Duration

func Serve

func Serve(repo SensorRepository) error

func Trace

func Trace(resp *resty.Response, err error)

Types

type APIKey

type APIKey struct {
	Success struct {
		Username string `json:"username"`
	} `json:"success"`
}

func GetApiKey

func GetApiKey(parsedKey []interface{}) (*APIKey, error)

type Configuration

type Configuration struct {
	ApiKey        string
	PhosconUrl    string
	DatabasePath  string
	DelayInSecond time.Duration
	TraceHttp     bool
	HttpPort      string
	ReadOnly      bool
}
var Config *Configuration

type Gateway

type Gateway []struct {
	Internalipaddress string `json:"internalipaddress"`
	Internalport      int    `json:"internalport"`
}

type InputSensor

type InputSensor struct {
	Uniqueid    string
	Etag        string
	Name        string
	Lastupdated string
	Type        string
	Temperature int
	Humidity    int
	Pressure    int
}

type InputSensors

type InputSensors struct {
	Etag    string
	Sensors []*InputSensor
}

func GetInputSensors

func GetInputSensors(parsedSensors map[string]interface{}) ([]*InputSensors, error)

GetInputSensors TODO peut être simplifié ?

type Operable

type Operable interface {
	InsertOrUpdate(value interface{}, key string) error
	GetAll() ([]*badger.Item, error)
	Get(key string) ([]byte, error)
}

func NewDB

func NewDB() Operable

type OutputSensors

type OutputSensors struct {
	Uniqueid string         `json:"uniqueId"`
	Name     string         `json:"name"`
	Type     string         `json:"type"`
	Events   []*SensorEvent `json:"events"`
}

func GetOutputSensors

func GetOutputSensors(listSensorsList []*InputSensors) []*OutputSensors

GetOutputSensors TODO peut être simplifié ?

type PhosconSensor

type PhosconSensor struct {
	Config struct {
		On        bool
		Battery   int
		Reachable bool
	}
	Ep               int
	Etag             string
	Lastseen         string
	Manufacturername string
	Modelid          string
	Name             string
	State            struct {
		Lastupdated string
		Temperature int
		Humidity    int
		Pressure    int
	}
	Swversion string
	Type      string
	Uniqueid  string
}

func (*PhosconSensor) IsSensor

func (sensor *PhosconSensor) IsSensor() bool

func (*PhosconSensor) ToInputSensor

func (sensor *PhosconSensor) ToInputSensor() *InputSensor

type SensorEvent

type SensorEvent struct {
	Etag        string `json:"etag"`
	Lastupdated string `json:"lastUpdated"`
	Temperature int    `json:"temperature"`
	Humidity    int    `json:"humidity"`
	Pressure    int    `json:"pressure"`
}

type SensorRepository

type SensorRepository interface {
	GetAll() ([]*InputSensors, error)
	SaveAll([]*InputSensors) error
	Save(sensor *InputSensors) error
}

func NewSensorRepository

func NewSensorRepository(operation Operable) SensorRepository

Jump to

Keyboard shortcuts

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