controller

package
v0.0.0-...-6c85ac7 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Running bool `json:"running"`
	Heat    `json:"heat"`
	Zones   map[string]*Zone `json:"zones"`

	Events        chan Event     `json:"-"`
	EventHandlers []EventHandler `json:"-"`
	// contains filtered or unexported fields
}

Controller represents a fan in thermostat controller for multiple zones.

func NewController

func NewController(pin uint32) *Controller

NewController returns an initialized controller on the supplied pin.

func (*Controller) AddEventHandler

func (controller *Controller) AddEventHandler(handler EventHandler)

AddEventHandler adds an event handler to the controllers list.

func (*Controller) AddZone

func (controller *Controller) AddZone(zone *Zone)

AddZone adds a zone and starts running it.

func (*Controller) ClearOverride

func (controller *Controller) ClearOverride()

ClearOverride clears an existing override if one exists.

func (*Controller) HandleEvents

func (controller *Controller) HandleEvents()

HandleEvents is a blocking function that pulls events off the event handler channel and pushes them to the various event handlers.

func (*Controller) Run

func (controller *Controller) Run() error

Run starts the controller running and listening for zone changes.

func (*Controller) SetHeaterState

func (controller *Controller) SetHeaterState()

SetHeaterState will adjust the heater pin to the correct high / low value.

func (*Controller) SetOverride

func (controller *Controller) SetOverride(override bool)

SetOverride allows a controller wide override of the target state.

type Event

type Event struct {
	Entity string
	Value  string
}

Event represents a change in state that has occurred.

type EventHandler

type EventHandler interface {
	Push(Event) error
	Name() string
}

EventHandler defines an interface for handling events.

type Heat

type Heat struct {
	Override *bool  `json:"override"`
	Active   bool   `json:"active"`
	Pin      uint32 `json:"pin"`
	// contains filtered or unexported fields
}

Heat represents the current heat state.

type MQTTEventHandler

type MQTTEventHandler struct {
	mqtt.Client
	EntityName string
}

func NewMQTTEventHandler

func NewMQTTEventHandler(name string, client mqtt.Client) *MQTTEventHandler

func (*MQTTEventHandler) Name

func (handler *MQTTEventHandler) Name() string

func (*MQTTEventHandler) Push

func (handler *MQTTEventHandler) Push(event Event) error

type Zone

type Zone struct {
	Name           string        `json:"name"`
	Active         bool          `json:"active"`
	Reading        bool          `json:"reading"`
	Override       *bool         `json:"override"`
	CallForHeatPin uint32        `json:"call_for_heat_pin"`
	DamperOnPin    uint32        `json:"damper_on_pin"`
	DamperOffPin   uint32        `json:"damper_off_pin"`
	Interval       time.Duration `json:"-"`
	// contains filtered or unexported fields
}

Zone represents a single zone that can optionally be turned on or off.

func NewZone

func NewZone(name string, pin uint32) *Zone

NewZone returns an initialized zone.

func (*Zone) ClearOverride

func (zone *Zone) ClearOverride()

ClearOverride clears any override on the zone.

func (*Zone) Run

func (zone *Zone) Run(ch chan<- bool, events chan<- Event) error

Run is a blocking function that starts processing pin readings for a zone.

func (*Zone) SetOverride

func (zone *Zone) SetOverride(override bool)

SetOverride applies an override to the zone.

func (*Zone) Stop

func (zone *Zone) Stop()

Stop will stop a running zone.

func (*Zone) UpdateDamperPins

func (zone *Zone) UpdateDamperPins()

UpdateDamperPins ensure the damper pins represent the current active state.

Jump to

Keyboard shortcuts

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