config

package
v0.0.0-...-461edb3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BedroomLightStand         = "Bedroom Light Stand"
	BedroomLightMain          = "Bedroom Light Main"
	LivingroomLightStand      = "Living Room Stand"
	LivingroomLightMain       = "Living Room Main"
	LivingroomLightChandelier = "Living Room Chandelier"
	KitchenLights             = "Kitchen"
	SophiaRoomLightStand      = "Sophia Stand"
	SophiaRoomLightMain       = "Sophia Main"
	JenniferRoomLightMain     = "Jennifer"
)
View Source
const (
	KitchenMotionSensor          = "Kitchen Motion"
	LivingroomMotionSensor       = "Livingroom Motion"
	BedroomMotionSensor          = "Bedroom Motion"
	BedroomPowerPlug             = "Bedroom Plug"
	BedroomCeilingLightSwitch    = "Bedroom Ceiling Light-Switch"
	BedroomChandelierLightSwitch = "Bedroom Chandelier Light-Switch"
	BedroomSwitch                = "Bedroom Switch"
	SophiaRoomSwitch             = "Sophia Switch"
	FrontdoorMagnetSensor        = "Front Door Magnet"
)
View Source
const (
	SwitchSingleClick  = "single click"
	SwitchDoubleClick  = "double click"
	SwitchTrippleClick = "tripple click"
	SwitchLongPress    = "long press"
	SwitchLongRelease  = "long release"
)
View Source
const (
	BedroomSamsungTV = "Bedroom Samsung-TV"
)
View Source
const (
	FrontdoorHallLight = "Frontdoor hall light"
)
View Source
const (
	LivingroomBraviaTV = "Livingroom Sony Bravia-TV"
)

Variables

View Source
var InfluxSecrets = InfluxSecretsWork
View Source
var InfluxSecretsHome = map[string]string{
	"host":     "http://10.0.0.22:8086",
	"username": "influxdb",
	"password": "password",
	"database": "gohome",
}
View Source
var InfluxSecretsWork = map[string]string{
	"host":     "http://localhost:8086",
	"username": "influxdb",
	"password": "password",
	"database": "gohome",
}
View Source
var PubSubCfg = PubSubHome

var PubSubCfg = PubSubWork

View Source
var PubSubHome = map[string]string{
	"host":    "tcp://10.0.0.22:8080",
	"license": "c1aVVz_sTmIi_FTcugWsjzTsQ4kJrslAAAAAAAAAAAI",
	"secret":  "1ZPCl42pPIyq6ZsZbaV4OUexWw97cZvf",
}
View Source
var PubSubWork = map[string]string{
	"host":    "tcp://127.0.0.1:8080",
	"license": "6YUwQVizikSOTIMfKtAvrcW5hwFBLFL2AAAAAAAAAAI",
	"secret":  "BQQ1M7WIVGhWzjEilfV5ENHwYekj3T2z",
}

Functions

func BoolAttrAsJSON

func BoolAttrAsJSON(sensorname string, sensortype string, name string, value bool) (string, error)

BoolAttrAsJSON can be called as BoolAttrAsJSON("state.sensor.motion", "motion", "motion_98AE7", true) and you will receive the JSON string or an error.

func CryptKey

func CryptKey() []byte

CryptKey returns a valid Crypt key

func Decrypt

func Decrypt(cryptoText string) (string, error)

Decrypt base64-decode and then AES decrypt string

func Encrypt

func Encrypt(text string) (string, error)

Encrypt AES-encrypt string and then base64-encode

func FloatAttrAsJSON

func FloatAttrAsJSON(sensorname string, sensortype string, name string, value float64) (string, error)

FloatAttrAsJSON can be called as FloatAttrAsJSON("state.sensor.clouds", "cloudcover", "clouds", 0.2) and you will receive the JSON string or an error.

func IntAttrAsJSON

func IntAttrAsJSON(sensorname string, sensortype string, name string, value int64) (string, error)

IntAttrAsJSON can be called as IntAttrAsJSON("state.sensor.aqi", "airquality", "aqi", 120) and you will receive the JSON string or an error.

func LoadFile

func LoadFile(path string, v interface{}) error

func SetCryptKey

func SetCryptKey(secretKey []byte) error

SetCryptKey with user input

func StringAttrAsJSON

func StringAttrAsJSON(sensorname string, sensortype string, name string, value string) (string, error)

StringAttrAsJSON can be called as StringAttrAsJSON("state.sensor.motion", "motion", "motion_ba9825ae", "on") and you will receive the JSON string or an error.

func TimeWndAttrAsJSON

func TimeWndAttrAsJSON(sensorname string, sensortype string, name string, begin time.Time, end time.Time) (string, error)

TimeWndAttrAsJSON can be called as TimeWndAttrAsJSON("state.sensor.sun", "sun", "sun.rise", sunrise_begin, sunrise_end) and you will receive the JSON string or an error.

Types

type AddSuncalcMoment

type AddSuncalcMoment struct {
	Name  string `json:"name"`
	Tag   string `json:"tag"`
	Shift int64  `json:"shift"` // Shift in minutes +/-
}

type AhkConfig

type AhkConfig struct {
	Pin         string        `json:"pin"`
	Subscribe   []string      `json:"subscribe"`
	Register    []AhkRegister `json:"register"`
	Lights      []AhkDevice   `json:"lights"`
	Switches    []AhkDevice   `json:"switches"`
	Sensors     []AhkDevice   `json:"sensors"`
	Televisions []AhkDevice   `json:"televisions"`
}

AhkConfig contains information for the Apple Homekit service

func AhkConfigFromJSON

func AhkConfigFromJSON(data []byte) (*AhkConfig, error)

AhkConfigFromJSON parser the incoming JSON string and returns an Config instance for Ahk

func (*AhkConfig) FromJSON

func (r *AhkConfig) FromJSON(data []byte) error

FromJSON converts json data into AhkConfig

func (*AhkConfig) ToJSON

func (r *AhkConfig) ToJSON() ([]byte, error)

ToJSON converts a AhkConfig to a JSON string

type AhkDevice

type AhkDevice struct {
	Name         string       `json:"name"`
	Type         string       `json:"type,omitempty"`
	Channel      *AhkRegister `json:"channel,omitempty"`
	ID           uint64       `json:"id"`
	Manufacturer string       `json:"manufacturer"`
}

type AhkRegister

type AhkRegister string
const (
	StateLightAhk  AhkRegister = "state/light/ahk/"
	StateSwitchAhk AhkRegister = "state/switch/ahk/"
)

type AqiConfig

type AqiConfig struct {
	Token    CryptString `json:"token"`
	City     string      `json:"city"`
	URL      string      `json:"url"`
	Interval int         `json:"interval"`
	Levels   []AqiLevel  `json:"levels"`
}

func AqiConfigFromJSON

func AqiConfigFromJSON(data []byte) (*AqiConfig, error)

AqiConfigFromJSON parser the incoming JSON string and returns an Config instance for Aqi

func (*AqiConfig) FromJSON

func (r *AqiConfig) FromJSON(data []byte) error

FromJSON converts json data into AqiConfig

func (*AqiConfig) ToJSON

func (r *AqiConfig) ToJSON() ([]byte, error)

ToJSON converts a AqiConfig to a JSON string

type AqiLevel

type AqiLevel struct {
	LessThan     float64 `json:"lessthan"`
	Tag          string  `json:"tag"`
	Implications string  `json:"implications"`
	Caution      string  `json:"caution"`
}

type AutomationConfig

type AutomationConfig struct {
	Subscribe   []string                 `json:"subscribe"`
	Register    []string                 `json:"register"`
	DeviceCache map[string]DeviceControl `json:"devices"`
}

AutomationConfig holds the configuration for automation

func AutomationConfigFromJSON

func AutomationConfigFromJSON(data []byte) (*AutomationConfig, error)

AutomationConfigFromJSON parser the incoming JSON string and returns an Config instance for Aqi

func (*AutomationConfig) FromJSON

func (r *AutomationConfig) FromJSON(data []byte) error

FromJSON converts a json string to a AutomationConfig instance

func (*AutomationConfig) ToJSON

func (r *AutomationConfig) ToJSON() ([]byte, error)

ToJSON converts a AutomationConfig to a JSON string

type BoolAttr

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

BoolAttr is a sensor holding a boolean as value

type BraviaTV

type BraviaTV struct {
	Name string `json:"name"`
	IP   string `json:"ip"`
	MAC  string `json:"mac"`
}

type BraviaTVConfig

type BraviaTVConfig struct {
	Devices []BraviaTV `json:"devices"`
}

func BraviaTVConfigFromJSON

func BraviaTVConfigFromJSON(data []byte) (*BraviaTVConfig, error)

BraviaTVConfigFromJSON parser the incoming JSON string and returns an Config instance for Bravia.TV

func (*BraviaTVConfig) FromJSON

func (r *BraviaTVConfig) FromJSON(data []byte) error

FromJSON converts a json string to a BraviaTVConfig instance

func (*BraviaTVConfig) ToJSON

func (r *BraviaTVConfig) ToJSON() ([]byte, error)

ToJSON converts a AqiConfig to a JSON string

type CAngles

type CAngles struct {
	Angle float64 `json:"angle"`
	Rise  string  `json:"rise"`
	Set   string  `json:"set"`
}

type CMoment

type CMoment struct {
	Title string `json:"title"`
	Descr string `json:"descr"`
	Begin string `json:"begin"`
	End   string `json:"end"`
}

type CalendarConfig

type CalendarConfig struct {
	Calendars []Ccal    `json:"calendars"`
	Sensors   []Csensor `json:"sensors"`
	Rules     []Crule   `json:"rules"`
}

func CalendarConfigFromJSON

func CalendarConfigFromJSON(data []byte) (*CalendarConfig, error)

func (*CalendarConfig) FromJSON

func (r *CalendarConfig) FromJSON(data []byte) error

FromJSON converts a json string to a CalendarConfig instance

func (*CalendarConfig) Print

func (c *CalendarConfig) Print()

func (*CalendarConfig) ToJSON

func (r *CalendarConfig) ToJSON() ([]byte, error)

ToJSON converts a CalendarConfig to a JSON string

type Ccal

type Ccal struct {
	Name string      `json:"name"`
	URL  CryptString `json:"url"`
}

type ConbeeContact

type ConbeeContact struct {
	ConbeeDevice
	Open  string `json:"open"`
	Close string `json:"close"`
}

ConbeeContact is a structure that references a magnet sensor device at Conbee

type ConbeeDevice

type ConbeeDevice struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	BatteryType string `json:"battery_type"`
}

ConbeeDevice is a structure that references a general device at Conbee

type ConbeeLightGroup

type ConbeeLightGroup struct {
	Name  string   `json:"name"`
	Group int      `json:"group"`
	On    string   `json:"on"`
	Off   string   `json:"off"`
	CT    string   `json:"ct"`
	Alert string   `json:"alert"`
	IDS   []string `json:"ids"`
}

ConbeeLight is a structure that references a light object at Conbee

type ConbeeLightsConfig

type ConbeeLightsConfig struct {
	Host     string             `json:"Host"`
	Port     int                `json:"Port"`
	APIKey   string             `json:"APIKey"`
	LightsIn []string           `json:"lights.in"`
	Lights   []ConbeeLightGroup `json:"lights"`
}

ConbeeLightsConfig contains information to connect to a Conbee-II device

func ConbeeLightsConfigFromJSON

func ConbeeLightsConfigFromJSON(data []byte) (*ConbeeLightsConfig, error)

ConbeeLightsConfigFromJSON parser the incoming JSON string and returns an Config instance for Aqi

func LoadConfig

func LoadConfig(filename string) (*ConbeeLightsConfig, error)

LoadConfig loads a ConbeeLightsConfig from a file

func (*ConbeeLightsConfig) FromJSON

func (r *ConbeeLightsConfig) FromJSON(data []byte) error

FromJSON converts a json string to a ConbeeLightsConfig instance

func (*ConbeeLightsConfig) ToJSON

func (r *ConbeeLightsConfig) ToJSON() ([]byte, error)

ToJSON converts a ConbeeLightsConfig to a JSON string

type ConbeeMotion

type ConbeeMotion struct {
	ConbeeDevice
	On  string `json:"on"`
	Off string `json:"off"`
}

ConbeeMotion is a structure that references a motion sensor device at Conbee

type ConbeeSensorsConfig

type ConbeeSensorsConfig struct {
	Host        string          `json:"Host"`
	Port        int             `json:"Port"`
	APIKey      string          `json:"APIKey"`
	SwitchesOut string          `json:"switches.out"`
	SensorsOut  string          `json:"sensors.out"`
	Switches    []ConbeeSwitch  `json:"switch"`
	Motion      []ConbeeMotion  `json:"motion"`
	Contact     []ConbeeContact `json:"contact"`
}

ConbeeSensorsConfig contains information to connect to a Conbee-II device

func ConbeeSensorsConfigFromJSON

func ConbeeSensorsConfigFromJSON(data []byte) (*ConbeeSensorsConfig, error)

ConbeeConfigFromJSON parser the incoming JSON string and returns an Config instance for Aqi

func LoadConbeeSensorsConfig

func LoadConbeeSensorsConfig(filename string) (*ConbeeSensorsConfig, error)

LoadConbeeSensorsConfig loads a ConbeeSensorsConfig from a file

func (*ConbeeSensorsConfig) FromJSON

func (r *ConbeeSensorsConfig) FromJSON(data []byte) error

FromJSON converts a json string to a ConbeeSensorsConfig instance

func (*ConbeeSensorsConfig) ToJSON

func (r *ConbeeSensorsConfig) ToJSON() ([]byte, error)

ToJSON converts a ConbeeSensorsConfig to a JSON string

type ConbeeSwitch

type ConbeeSwitch struct {
	ConbeeDevice
	SingleClick  string `json:"single_click"`
	DoubleClick  string `json:"double_click"`
	TrippleClick string `json:"tripple_click"`
}

ConbeeContact is a structure that references a switch/button device at Conbee

type Config

type Config interface {
	FromJSON(json []byte) error
	ToJSON() ([]byte, error)
}

type Crule

type Crule struct {
	Key    string   `json:"key"`
	Value  string   `json:"value"`
	IfThen []IfThen `json:"if"`
}

type CryptString

type CryptString struct {
	String string
}

func (*CryptString) MarshalJSON

func (cs *CryptString) MarshalJSON() ([]byte, error)

MarshalJSON encrypts and marshals nested String

func (*CryptString) Scan

func (cs *CryptString) Scan(value interface{}) error

Scan implements sql.Scanner and decryptes incoming sql column data

func (*CryptString) UnmarshalJSON

func (cs *CryptString) UnmarshalJSON(b []byte) error

UnmarshalJSON encrypts and marshals nested String

func (CryptString) Value

func (cs CryptString) Value() (value driver.Value, err error)

Value implements driver.Valuer and encrypts outgoing bind values

type Csensor

type Csensor struct {
	Name      string `json:"name"`
	Type      string `json:"type"`
	AttrType  string `json:"attrtype"`
	AttrValue string `json:"attrvalue"`
}

type Darkorlight

type Darkorlight string
const (
	Dark     Darkorlight = "dark"
	Light    Darkorlight = "light"
	Twilight Darkorlight = "twilight"
)

type DeviceControl

type DeviceControl struct {
	Channel string `json:"channel"`
	On      string `json:"on"`
	Off     string `json:"off"`
	Toggle  string `json:"toggle"`
}

DeviceControl holds the configuration to control a device

type FloatAttr

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

FloatAttr is a sensor holding a float as value

type FluxConfig

type FluxConfig struct {
	Seasons        []Season           `json:"seasons"`
	Weather        []Weather          `json:"weather"`
	SuncalcMoments []AddSuncalcMoment `json:"suncalc_moments"`
	Lighttype      []Lighttype        `json:"lighttype"`
	Lighttime      []Lighttime        `json:"lighttime"`
}

func FluxConfigFromJSON

func FluxConfigFromJSON(data []byte) (*FluxConfig, error)

FluxConfigFromJSON converts a json string to a FluxConfig instance

func (*FluxConfig) FromJSON

func (r *FluxConfig) FromJSON(data []byte) error

FromJSON converts a json string to a FluxConfig instance

func (*FluxConfig) ToJSON

func (r *FluxConfig) ToJSON() ([]byte, error)

ToJSON converts a FluxConfig to a JSON string

type Forecast

type Forecast struct {
	From        time.Time `json:"from"`
	Until       time.Time `json:"until"`
	Rain        float64   `json:"rain"`
	RainDescr   string    `json:"rainDescr"`
	Wind        float64   `json:"wind"`
	WindDescr   string    `json:"windDescr"`
	Clouds      float64   `json:"clouds"`
	CloudDescr  string    `json:"cloudsDescr"`
	Temperature float64   `json:"temperature"`
	TempDescr   string    `json:"temperatureDescr"`
}

func WeatherForecastFromJSON

func WeatherForecastFromJSON(jsonstr string) (*Forecast, error)

func (*Forecast) FromJSON

func (r *Forecast) FromJSON() ([]byte, error)

type FromTo

type FromTo struct {
	From float64 `json:"from"`
	To   float64 `json:"to"`
}

func (FromTo) LinearInterpolated

func (f FromTo) LinearInterpolated(x float64) float64

LinearInterpolated returns interpolated value between From-To

type Geo

type Geo struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type HueBridgeConfig

type HueBridgeConfig struct {
	IPPort            string                    `json:"ip_port"`
	RegisterChannels  []string                  `json:"register_channels"`
	SubscribeChannels []string                  `json:"subscribe_channels"`
	EmulatedDevices   []HueBridgeEmulatedDevice `json:"emulated-devices"`
}

HueBridgeConfig is a struct that holds information for our emulated Hue Bridge

func HueBridgeConfigFromJSON

func HueBridgeConfigFromJSON(data []byte) (*HueBridgeConfig, error)

HueBridgeConfigFromJSON will decode a JSON string to a HueBridgeConfig struct

func (*HueBridgeConfig) FromJSON

func (r *HueBridgeConfig) FromJSON(data []byte) error

FromJSON converts a json string to a HueBridgeConfig instance

func (*HueBridgeConfig) ToJSON

func (r *HueBridgeConfig) ToJSON() (data []byte, err error)

ToJSON will encode a HueBridgeConfig struct to a JSON string

type HueBridgeEmulatedDevice

type HueBridgeEmulatedDevice struct {
	Name    string `json:"name"`
	Channel string `json:"channel"`
	On      string `json:"on"`
	Off     string `json:"off"`
}

HueBridgeEmulatedDevice is a device emulated on the Hue Bridge

type IfThen

type IfThen struct {
	Key   string `json:"key"`
	State string `json:"state"`
}

type IntAttr

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

IntAttr is a sensor holding an integer as value

type Lighttime

type Lighttime struct {
	CT          FromTo         `json:"ct"`
	Bri         FromTo         `json:"bri"`
	Darkorlight Darkorlight    `json:"darkorlight"`
	TimeSlot    TaggedTimeSlot `json:"timeslot"`
}

type Lighttype

type Lighttype struct {
	MetricsName string `json:"metricsname"`
	LightName   string `json:"lightname"`
	LightType   string `json:"lighttype"`
	Channel     string `json:"channel"`
	CT          MinMax `json:"ct"`
	BRI         MinMax `json:"bri"`
}

type MinMax

type MinMax struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

func (MinMax) LinearInterpolated

func (m MinMax) LinearInterpolated(x float64) float64

LinearInterpolated returns interpolated value between Min-Max

type Notify

type Notify struct {
	Type    string `json:"type"`
	Warning MinMax `json:"warning"`
	Alert   MinMax `json:"alert"`
}

type PresenceConfig

type PresenceConfig struct {
	Name              string      `json:"name"`
	Host              string      `json:"host"`
	Port              int         `json:"port"`
	User              CryptString `json:"user"`
	Password          CryptString `json:"password"`
	UpdateHistory     int         `json:"update_history"`
	UpdateIntervalSec int         `json:"update_interval_sec"`
	Devices           []struct {
		Name string        `json:"name"`
		Mac  []CryptString `json:"macs"`
	} `json:"devices"`
}

func PresenceConfigFromJSON

func PresenceConfigFromJSON(data []byte) (*PresenceConfig, error)

func (*PresenceConfig) FromJSON

func (r *PresenceConfig) FromJSON(data []byte) error

func (*PresenceConfig) ToJSON

func (r *PresenceConfig) ToJSON() ([]byte, error)

type SamsungTV

type SamsungTV struct {
	Name string `json:"name"`
	IP   string `json:"ip"`
	ID   string `json:"id"`
}

type SamsungTVConfig

type SamsungTVConfig struct {
	Devices []SamsungTV `json:"devices"`
}

func SamsungTVConfigFromJSON

func SamsungTVConfigFromJSON(data []byte) (*SamsungTVConfig, error)

SamsungTVConfigFromJSON parser the incoming JSON string and returns an Config instance for Samsung.TV

func (*SamsungTVConfig) FromJSON

func (r *SamsungTVConfig) FromJSON(data []byte) error

FromJSON converts a json string to a SamsungTVConfig instance

func (*SamsungTVConfig) ToJSON

func (r *SamsungTVConfig) ToJSON() ([]byte, error)

ToJSON converts a AqiConfig to a JSON string

type Season

type Season struct {
	Name string `json:"name"`
	CT   MinMax `json:"ct"`
	BRI  MinMax `json:"bri"`
}

type SensorState

type SensorState struct {
	Name         string        `json:"name"`
	Type         string        `json:"type"`
	Time         time.Time     `json:"time"`
	BoolAttrs    []BoolAttr    `json:"boolattrs,omitempty"`
	IntAttrs     []IntAttr     `json:"intattrs,omitempty"`
	FloatAttrs   []FloatAttr   `json:"floatattrs,omitempty"`
	StringAttrs  []StringAttr  `json:"stringattrs,omitempty"`
	TimeWndAttrs []TimeWndAttr `json:"timeslotattrs,omitempty"`
}

SensorState holds all information of a sensor e.g. { "Name": "aqi", "Type": "AirQuality", "IntAttr": { "Name": "PM2.5", "Value": 54 } }

func NewSensorState

func NewSensorState(sensorName string, sensorType string) *SensorState

NewSensorState returns a SensorState object initialized with 'name', 'type' and 'time.Now()'

func SensorStateFromJSON

func SensorStateFromJSON(data []byte) (*SensorState, error)

SensorStateFromJSON deserializes a JSON string and returns a SensorState object

func (*SensorState) AddBoolAttr

func (s *SensorState) AddBoolAttr(name string, value bool)

AddBoolAttr adds an BoolAttr to SensorState

func (*SensorState) AddFloatAttr

func (s *SensorState) AddFloatAttr(name string, value float64)

AddFloatAttr adds a TimeWndAttr to SensorState

func (SensorState) AddIntAttr

func (s SensorState) AddIntAttr(name string, value int64)

AddIntAttr adds an IntAttr to SensorState

func (*SensorState) AddStringAttr

func (s *SensorState) AddStringAttr(name string, value string)

AddStringAttr adds a TimeWndAttr to SensorState

func (*SensorState) AddTimeWndAttr

func (s *SensorState) AddTimeWndAttr(name string, begin time.Time, end time.Time)

AddTimeWndAttr adds a TimeWndAttr to SensorState

func (*SensorState) ExecFloatAttr

func (s *SensorState) ExecFloatAttr(name string, action func(float64)) bool

ExecFloatAttr will execute 'action' when an attribute with name 'name' is found

func (*SensorState) ExecValueAttr

func (s *SensorState) ExecValueAttr(name string, action func(string)) bool

ExecValueAttr will execute 'action' when an attribute with name 'name' is found

func (*SensorState) FromJSON

func (s *SensorState) FromJSON(data []byte) error

FromJSON converts a json string to a SensorState instance

func (*SensorState) GetBoolAttr

func (s *SensorState) GetBoolAttr(name string, defaultvalue bool) bool

GetBoolAttr returns the value of a FloatAttr with name 'name'

func (*SensorState) GetFloatAttr

func (s *SensorState) GetFloatAttr(name string, defaultvalue float64) float64

GetFloatAttr returns the value of a FloatAttr with name 'name'

func (*SensorState) GetIntAttr

func (s *SensorState) GetIntAttr(name string, defaultvalue int64) int64

GetIntAttr returns the value of a FloatAttr with name 'name'

func (*SensorState) GetValueAttr

func (s *SensorState) GetValueAttr(name string, defaultvalue string) string

GetValueAttr returns the value of a FloatAttr with name 'name'

func (*SensorState) ToJSON

func (s *SensorState) ToJSON() ([]byte, error)

ToJSON serializes a SensorState object into a JSON string

type ShoutConfig

type ShoutConfig struct {
	UserToken CryptString `json:"usertoken"`
	AppToken  CryptString `json:"apptoken"`
	Channel   string      `json:"channel"`
}

func ShoutConfigFromJSON

func ShoutConfigFromJSON(data []byte) (*ShoutConfig, error)

ShoutConfigFromJSON converts a json string to a ShoutConfig instance

func (*ShoutConfig) FromJSON

func (m *ShoutConfig) FromJSON(data []byte) error

FromJSON converts a json string to a ShoutConfig instance

func (*ShoutConfig) ToJSON

func (m *ShoutConfig) ToJSON() (data []byte, err error)

ToJSON converts a ShoutConfig to a JSON string

type ShoutMsg

type ShoutMsg struct {
	Channel  string `json:"channel"`
	Username string `json:"username"`
	Message  string `json:"message"`
	Pretext  string `json:"pretext"`
	Prebody  string `json:"prebody"`
}

func ShoutMsgFromJSON

func ShoutMsgFromJSON(jsondata []byte) (ShoutMsg, error)

func (*ShoutMsg) FromJSON

func (m *ShoutMsg) FromJSON(data []byte) error

func (*ShoutMsg) ToJSON

func (m *ShoutMsg) ToJSON() []byte

type StringAttr

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

StringAttr is a sensor holding a string as value

type SuncalcConfig

type SuncalcConfig struct {
	Geo      Geo       `json:"config"`
	Anglecfg []CAngles `json:"anglecfg"`
	Moments  []CMoment `json:"moments"`
}

func SuncalcConfigFromJSON

func SuncalcConfigFromJSON(data []byte) (*SuncalcConfig, error)

func (*SuncalcConfig) FromJSON

func (r *SuncalcConfig) FromJSON(data []byte) error

FromJSON converts a json string to a SuncalcConfig instance

func (*SuncalcConfig) ToJSON

func (r *SuncalcConfig) ToJSON() ([]byte, error)

type TaggedTimeSlot

type TaggedTimeSlot struct {
	StartMoment string `json:"start"`
	StartTime   time.Time
	EndMoment   string `json:"end"`
	EndTime     time.Time
}

type TimeWndAttr

type TimeWndAttr struct {
	Name  string    `json:"name"`
	Begin time.Time `json:"begin"`
	End   time.Time `json:"end"`
}

TimeWndAttr is a sensor holding a TimeWnd as value e.g. TimeWndAttrAsJSON("sun.rise", sunrise_begin, sunrise_end) or adding multiple sensors:

sensor := NewSensorState("suncalc")
sensor.AddTimeWndAttr("night.dawn", nightdawn, nightdawn_end)
sensor.AddTimeWndAttr("astronomical.dawn", astronomicaldawn, astronomicaldawn_end)
...
jsonstr, err := sensor.ToJSON()
...

type Unit

type Unit string
const (
	Celcius Unit = "Celcius"
	Empty   Unit = "%"
	KMH     Unit = "km/h"
)

type WItem

type WItem struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Unit        Unit   `json:"unit"`
	Range       MinMax `json:"range"`
}

type Weather

type Weather struct {
	Clouds MinMax  `json:"clouds"`
	CTPct  float64 `json:"ct_pct"`
	BriPct float64 `json:"bri_pct"`
}

type WeatherConfig

type WeatherConfig struct {
	Location    Geo         `json:"location"`
	Key         CryptString `json:"key"`
	Notify      []Notify    `json:"notify"`
	Clouds      []WItem     `json:"clouds"`
	Rain        []WItem     `json:"rain"`
	Wind        []WItem     `json:"wind"`
	Temperature []WItem     `json:"temperature"`
}

func WeatherConfigFromJSON

func WeatherConfigFromJSON(data []byte) (*WeatherConfig, error)

func (*WeatherConfig) FromJSON

func (r *WeatherConfig) FromJSON(data []byte) error

FromJSON converts a json string to a WeatherConfig instance

func (*WeatherConfig) ToJSON

func (r *WeatherConfig) ToJSON() (data []byte, err error)

type WemoConfig

type WemoConfig struct {
	Name    string `json:"name"`
	Devices []struct {
		Name string `json:"name"`
		IP   string `json:"ip"`
		Port string `json:"port"`
	} `json:"devices"`
}

func WemoConfigFromJSON

func WemoConfigFromJSON(data []byte) (*WemoConfig, error)

func (*WemoConfig) FromJSON

func (r *WemoConfig) FromJSON(data []byte) error

FromJSON converts a json string to a WemoConfig instance

func (*WemoConfig) ToJSON

func (m *WemoConfig) ToJSON() (data []byte, err error)

type XiaomiConfig

type XiaomiConfig struct {
	Name   string      `json:"name"`
	IP     string      `json:"ip"`
	MAC    string      `json:"mac"`
	Key    CryptString `json:"key"`
	Motion []struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		BType string `json:"battery_type"`
	} `json:"motion"`
	Plug []struct {
		Name string `json:"name"`
		ID   string `json:"id"`
	} `json:"plug"`
	Switch []struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		BType string `json:"battery_type"`
	} `json:"switch"`
	Magnet []struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		BType string `json:"battery_type"`
	} `json:"magnet"`
}

func XiaomiConfigFromJSON

func XiaomiConfigFromJSON(data []byte) (*XiaomiConfig, error)

func (*XiaomiConfig) FromJSON

func (r *XiaomiConfig) FromJSON(data []byte) error

FromJSON converts a json string to a XiaomiConfig instance

func (*XiaomiConfig) ToJSON

func (m *XiaomiConfig) ToJSON() (data []byte, err error)

type YeeConfig

type YeeConfig struct {
	Name   string `json:"name"`
	Lights []struct {
		Name string `json:"name"`
		IP   string `json:"ip"`
		Port string `json:"port"`
	} `json:"lights"`
}

func YeeConfigFromJSON

func YeeConfigFromJSON(data []byte) (*YeeConfig, error)

func (*YeeConfig) FromJSON

func (r *YeeConfig) FromJSON(data []byte) error

FromJSON converts a json string to a YeeConfig instance

func (*YeeConfig) ToJSON

func (m *YeeConfig) ToJSON() (data []byte, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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