Documentation
¶
Overview ¶
Package manifest enables declarative configuration of AHA devices.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
Perform(a aha) error
}
Action is one operation on the home automation system.
type Applier ¶
type Applier interface {
// Apply performs the changes necessary to transition from src to target configuration. If the target plan
// could be realized, it returns an error. If the plan was applied successfully, it returns null.
Apply(src, target *Plan) error
}
Applier defines the interface to apply a plan to the AHA system.
func DryRunner ¶
func DryRunner() Applier
DryRunner is an Applier that only plans changes to the AHA system.
func NewApplier ¶ added in v1.4.17
func NewApplier(f aha) Applier
NewApplier is an Applier that performs changes to the AHA system via the HTTP API.
Example ¶
Using an Applier, one can change the config of devices in one run.
package main
import (
"net/url"
"github.com/bpicode/fritzctl/fritz"
"github.com/bpicode/fritzctl/manifest"
)
func main() {
h := fritz.NewHomeAuto(fritz.URL(&url.URL{
Host: "fritz-box.home",
Scheme: "https",
}))
a := manifest.NewApplier(h)
a.Apply(&manifest.Plan{
Switches: []manifest.Switch{{Name: "Switch1", State: false}, {Name: "Switch2", State: false}},
}, &manifest.Plan{
Switches: []manifest.Switch{{Name: "Switch1", State: false}, {Name: "Switch2", State: false}},
})
}
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter allows exporting of a Plan.
func ExporterTo ¶
ExporterTo creates an Exporter, which writes to the given io.Writer.
type Plan ¶
type Plan struct {
Switches []Switch // The power switches.
Thermostats []Thermostat // The HKR devices.
}
Plan represents the data model of an absolute state of the fritz smart home.
func ConvertDevicelist ¶
func ConvertDevicelist(l *fritz.Devicelist) *Plan
ConvertDevicelist converts a fritz.Devicelist to a Plan.
type Planner ¶
Planner represents an execution planner, returning actions to transition from a src to a target state.
func TargetBasedPlanner ¶
func TargetBasedPlanner(scf switchCommandFactory, tcf thermostatCommandFactory) Planner
TargetBasedPlanner creates a Planner that only focuses on target state. Devices in the source state that are not referenced in the target will be left untouched.
type Thermostat ¶
type Thermostat struct {
Name string // Name of the device.
Temperature float64 // The temperature in °C.
}
Thermostat represents the state of a HKR device.