Documentation ¶
Overview ¶
Package config contains all the structures used to represent the YAML file to load a periph-home node.
The file schema starts with the type Root.
Configuration ¶
The configuration yaml file is expected to look like this:
periphhome: api: binary_sensor: - platform: gpio name: "Motion sensor" device_class: motion pin: number: GPIO17 mode: INPUT_PULLUP sensor: - platform: bme280 address: 0x76 update_interval: 60s temperature: name: "Temperature" pressure: name: "Pressure" humidity: name: "Humidity" - platform: wifi_signal name: "wifi signal"
Example ¶
package main import ( "fmt" "log" "periph.io/x/home/node/config" ) // See https://github.com/periph/home/blob/main/example.yaml // for a full example of a periphhome configuration file. const sampleConf = ` periphhome: name: pi comment: pi device api: binary_sensor: # ... sensor: # ... ` func main() { cfg := config.Root{} if err := cfg.LoadYaml([]byte(sampleConf)); err != nil { log.Fatal(err) } fmt.Printf("Device: %s\n", cfg.PeriphHome.Name) }
Output: Device: pi
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { // Port is the TCP port for the native API. // // Defaults to 6053. Port int // Password provides a very weak protection, since no encryption and no // hashing is used. Password string // IsPresent is set to true if the field was present when the configuration // is deserialized from yaml. IsPresent bool `yaml:"-"` // contains filtered or unexported fields }
API is the "api" section.
func (*API) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
type BinarySensor ¶
type BinarySensor struct { Platform string Name string DeviceClass string `yaml:"device_class"` Pin Pin // contains filtered or unexported fields }
BinarySensor is an element in the "binary_sensor" section.
type Camera ¶
type Camera struct { Platform string Name string Directory string Rotation int // contains filtered or unexported fields }
Camera is an element in the "camera" section.
type Light ¶
type Light struct { Platform string Name string NumLEDs int `yaml:"num_leds"` // contains filtered or unexported fields }
Light is an element in the "light" section.
type PeriphHome ¶
type PeriphHome struct { // Name is the name that will be shown in Home Assistant. // Defaults to the hostname. Name string Comment string // contains filtered or unexported fields }
PeriphHome is the "periphhome" section.
type Pin ¶
type Pin struct { Number string Inverted bool Mode PinMode // contains filtered or unexported fields }
Pin is a "pin" section.
type Root ¶
type Root struct { PeriphHome PeriphHome `yaml:"periphhome"` API API `yaml:"api"` BinarySensors []BinarySensor `yaml:"binary_sensor"` Sensors []Sensor `yaml:"sensor"` Lights []Light `yaml:"light"` Cameras []Camera `yaml:"camera"` // contains filtered or unexported fields }
Root is the configuration file format.
It is designed to look like ESPHome configuration yaml but has differences where appropriate.
type Sensor ¶
type Sensor struct { Platform string Name string Temperature SensorParams Pressure SensorParams Humidity SensorParams Address int UpdateInterval time.Duration `yaml:"update_interval"` // contains filtered or unexported fields }
Sensor is an element in the "sensor" section.
type SensorParams ¶
type SensorParams struct { Name string // contains filtered or unexported fields }
SensorParams defines a sensor parameter.