homlet

package module
v0.0.0-...-160a739 Latest Latest
Warning

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

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

README

homlet

Build

To build:

$ make

To generate files:

$ make gen

To generate, lint and build:

$ make release

To build a raspberry binary:

$ make rpi

Terminal UI

Display all devices directly on you prefered terminal:

$ homlet term

Server

Install homlet binary:

$ sudo mv homlet /usr/local/bin/

Install homlet conf file:

$ sudo mkdir /etc/homlet
$ sudo cp configs/config.toml /etc/homlet

Install homlet service:

$ sudo cp configs/homlet.service /etc/systemd/system/
$ sudo systemctl enable homlet.service

Start homlet service:

$ sudo systemctl start homlet.service

Tail logs:

$ journalctl -f -u homlet

Documentation

Overview

Package homlet implements a DIY domotic system

Index

Constants

View Source
const (
	BAUD    = 57600
	LF_CHAR = 10
)

Variables

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

func SortPackets

func SortPackets(packets []*Packet)

SortPackets sorts packets by device id

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

func DeviceString(s string) (Device, error)

DeviceString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func DeviceValues

func DeviceValues() []Device

DeviceValues returns all values of the enum

func (Device) IsADevice

func (i Device) IsADevice() bool

IsADevice returns "true" if the value is listed in the enum definition. "false" otherwise

func (Device) String

func (i Device) String() string

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 Open

func Open(path string) (*Hardware, error)

Open instanciates and initializes hardware

func (*Hardware) Close

func (hdw *Hardware) Close()

Close stops hardware

func (*Hardware) Read

func (hdw *Hardware) Read() (*Packet, error)

Read returns a packet

func (*Hardware) ReadPackets

func (hdw *Hardware) ReadPackets() chan *Packet

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

func Parse(line string) (*Packet, error)

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

func (p *Packet) HaveSensor(sensor Sensor) bool

HasSensor returns true if packet have given sensor data

func (*Packet) HumanizeValue

func (p *Packet) HumanizeValue(sensor Sensor) string

Value returns humanized representation of sensor value with unit

func (*Packet) HumanizeValues

func (p *Packet) HumanizeValues() []string

Values returns humanized representations of all sensors values

func (*Packet) HumidityStatus

func (p *Packet) HumidityStatus() HumidityStatus

HumidityStatus returns humidity status

func (*Packet) Sensors

func (p *Packet) Sensors() []Sensor

Sensors returns all packet sensors

func (*Packet) String

func (p *Packet) String() string

String implements stringer

type PacketSorter

type PacketSorter struct {
	// contains filtered or unexported fields
}

PacketSorter implements sort.Interface

func (*PacketSorter) Len

func (s *PacketSorter) Len() int

Len implements sort.Interface

func (*PacketSorter) Less

func (s *PacketSorter) Less(i, j int) bool

Less implements sort.Interface

func (*PacketSorter) Swap

func (s *PacketSorter) Swap(i, j int)

Swap implements sort.Interface

type PacketsBy

type PacketsBy func(a, b *Packet) bool

PacketsBy is a function that sorts a list of Packet

func (PacketsBy) Sort

func (by PacketsBy) Sort(l []*Packet)

Sort sorts Packets

type Sensor

type Sensor int

Sensor represents a sensor kind

const (
	Temperature Sensor = iota + 1
	Humidity
	Light
	Motion
	LowBattery
	VCC // Supply voltage
)

Supported sensors

func SensorString

func SensorString(s string) (Sensor, error)

SensorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SensorValues

func SensorValues() []Sensor

SensorValues returns all values of the enum

func (Sensor) IsASensor

func (i Sensor) IsASensor() bool

IsASensor returns "true" if the value is listed in the enum definition. "false" otherwise

func (Sensor) String

func (i Sensor) String() string

type SensorSettings

type SensorSettings struct {
	Name       string
	Correction float64 // correction to apply to sensor value
	Disable    bool    // disable that sensor
	Domoticz   int     // domoticz idx
}

SensorSettings represents settings for a specific sensor

Directories

Path Synopsis
cmd
pkg
domoticz
Package domoticz outputs packets to a domoticz instance
Package domoticz outputs packets to a domoticz instance
term
Package term implements terminal UI
Package term implements terminal UI

Jump to

Keyboard shortcuts

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