Documentation ¶
Overview ¶
Package homlet implements a DIY domotic system
Index ¶
- Constants
- Variables
- func DeviceStrings() []string
- func HumidityStatusStrings() []string
- func SensorStrings() []string
- func SortPackets(packets []*Packet)
- type Device
- type DeviceSettings
- type Hardware
- type HumidityStatus
- type Packet
- func (p *Packet) ApplySettings(settings *DeviceSettings) error
- func (p *Packet) HaveSensor(sensor Sensor) bool
- func (p *Packet) HumanizeValue(sensor Sensor) string
- func (p *Packet) HumanizeValues() []string
- func (p *Packet) HumidityStatus() HumidityStatus
- func (p *Packet) Sensors() []Sensor
- func (p *Packet) String() string
- type PacketSorter
- type PacketsBy
- type Sensor
- type SensorSettings
Constants ¶
const ( BAUD = 57600 LF_CHAR = 10 )
Variables ¶
var Sensors = []Sensor{ Temperature, Humidity, Light, Motion, LowBattery, VCC, }
Sensors holds all sensors
Functions ¶
func DeviceStrings ¶
func DeviceStrings() []string
DeviceStrings returns a slice of all String values of the enum
func HumidityStatusStrings ¶
func HumidityStatusStrings() []string
HumidityStatusStrings returns a slice of all String values of the enum
func SensorStrings ¶
func SensorStrings() []string
SensorStrings returns a slice of all String values of the enum
Types ¶
type Device ¶
type Device int
Device represents a device kind
const ( Unknown Device = iota JeenodeTHLM // Jeenode: Temperature Humidity Light Motion JeenodeTHL // Jeenode: Temperature Humidity Light TinytxT // TinyTX: Temperature TinytxTH // TinyTX: Temperature Humidity TinytxTL // TinyTX: Temperature Light )
Supported devices
func DeviceString ¶
DeviceString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
type DeviceSettings ¶
type DeviceSettings struct { ID int // device id Room string // room where device is located Sensors []*SensorSettings }
DeviceSettings represents settings for a specific device
func (*DeviceSettings) Sensor ¶
func (ds *DeviceSettings) Sensor(sensor Sensor) (*SensorSettings, error)
Sensor returns sensor settings
type Hardware ¶
type Hardware struct {
// contains filtered or unexported fields
}
Hardware is the serial connection with homlet device master
func (*Hardware) ReadPackets ¶
ReadPackets read packets and send them to returned channel
type HumidityStatus ¶
type HumidityStatus int
HumidityStatus represents humidity status
const ( HumidityNormal HumidityStatus = iota HumidityComfortable HumidityDry HumidityWet )
Supported humidity statuses
func HumidityStatusString ¶
func HumidityStatusString(s string) (HumidityStatus, error)
HumidityStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func HumidityStatusValues ¶
func HumidityStatusValues() []HumidityStatus
HumidityStatusValues returns all values of the enum
func (HumidityStatus) IsAHumidityStatus ¶
func (i HumidityStatus) IsAHumidityStatus() bool
IsAHumidityStatus returns "true" if the value is listed in the enum definition. "false" otherwise
func (HumidityStatus) String ¶
func (i HumidityStatus) String() string
type Packet ¶
type Packet struct { At time.Time Corrections map[Sensor]float64 Device Device DeviceID int Disabled map[Sensor]bool // sensors Temperature float64 Humidity uint8 Light uint8 Motion bool LowBattery bool VCC uint // contains filtered or unexported fields }
Packet received from a device
func Parse ¶
Parse a line produce by RF12Demo sketch
Example of line generated by RF12Demo sketch that received a packet from a device:
OK 2 3 156 149 213 0 ^ ^ ------------- header | ^ | data bytes | node kind
header:
0 0 0 0 0 0 1 0 ^ ^ ^ ----------------- CTL DST ACK ^ node id => 2
node kind:
0 0 0 0 0 0 1 1 ^ -------------------------
reserved ^
node kind => 3
func (*Packet) ApplySettings ¶
func (p *Packet) ApplySettings(settings *DeviceSettings) error
ApplySettings corrects sensors values and disables sensors
func (*Packet) HaveSensor ¶
HasSensor returns true if packet have given sensor data
func (*Packet) HumanizeValue ¶
Value returns humanized representation of sensor value with unit
func (*Packet) HumanizeValues ¶
Values returns humanized representations of all sensors values
func (*Packet) HumidityStatus ¶
func (p *Packet) HumidityStatus() HumidityStatus
HumidityStatus returns humidity status
type PacketSorter ¶
type PacketSorter struct {
// contains filtered or unexported fields
}
PacketSorter implements sort.Interface
func (*PacketSorter) Less ¶
func (s *PacketSorter) Less(i, j int) bool
Less implements sort.Interface
type Sensor ¶
type Sensor int
Sensor represents a sensor kind
Supported sensors
func SensorString ¶
SensorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.