Documentation
¶
Index ¶
- Constants
- func GetMQTTChan() chan MQTTRequest
- func StopAll()
- type Blower
- type BlowerID
- type Chiller
- type ChillerID
- type Command
- type Config
- func (c *Config) GetChillerFromLoop(id LoopID) ChillerID
- func (c *Config) GetOccupancySchedule() (*OccupancySchedule, error)
- func (c *Config) GetSchedule() (*ScheduleList, error)
- func (c *Config) SetControlMode(cm ControlModeT) error
- func (c *Config) SetSystemMode(sm SystemModeT) error
- func (c *Config) WriteToStore() error
- type ControlMode
- type ControlModeT
- type Damper
- type DegF
- type DeviceID
- type Loop
- type LoopID
- type MQTTConfig
- type MQTTRequest
- type OccupancyNextRunReport
- type OccupancyOneTimeEntry
- type OccupancyOneTimeID
- type OccupancyRecurringEntry
- type OccupancyRecurringID
- type OccupancySchedule
- func (s *OccupancySchedule) AddOneTimeEntry(e *OccupancyOneTimeEntry) error
- func (s *OccupancySchedule) AddRecurringEntry(e *OccupancyRecurringEntry) error
- func (s *OccupancySchedule) EditOneTimeEntry(e *OccupancyOneTimeEntry) error
- func (s *OccupancySchedule) EditRecurringEntry(e *OccupancyRecurringEntry) error
- func (s *OccupancySchedule) GetOneTimeEntry(id OccupancyOneTimeID) *OccupancyOneTimeEntry
- func (s *OccupancySchedule) GetRecurringEntry(id OccupancyRecurringID) *OccupancyRecurringEntry
- func (s *OccupancySchedule) RemoveOneTimeEntry(id OccupancyOneTimeID)
- func (s *OccupancySchedule) RemoveRecurringEntry(id OccupancyRecurringID)
- type Pump
- type PumpID
- type Relay
- type Response
- type Room
- type RoomID
- type ScheduleEntry
- type ScheduleList
- type SystemMode
- type SystemModeT
- type Valve
- type ValveID
- type Zone
- type ZoneID
- type ZoneTargets
Constants ¶
const ( MaxPumpRunTime time.Duration = (14 * time.Hour) MinPumpRunTime time.Duration = (30 * time.Minute) MaxBlowerRunTime time.Duration = (14 * time.Hour) MinBlowerRunTime time.Duration = (30 * time.Minute) MaxChillerRunTime time.Duration = (14 * time.Hour) MinChillerRunTime time.Duration = (30 * time.Minute) )
min/max durations for user-scheduled run-times, does not affect temp based
const ( BlowersTopic string = "blowers" ChillersTopic string = "chillers" PumpsTopic string = "pumps" RoomsTopic string = "rooms" CurrentStateEndpoint string = "currentstate" TargetStateEndpoint string = "targetstate" TempEndpoint string = "temp" // Shellies use their own topic, this is for other (potential) sensors HumidityEndpoint string = "humidity" // Shellies use their own topic, this is for other (potential) sensors )
MQTT topic strings
const QoS byte = 0
QoS is the MQTT Quality of Service value only 0 has been tested
const ShellyExternalPowerBattLevel = 101
Variables ¶
This section is empty.
Functions ¶
func GetMQTTChan ¶
func GetMQTTChan() chan MQTTRequest
GetMQTTChan returns the command channel to the MQTT subsystem
Types ¶
type Blower ¶
type Blower struct { CurrentStartTime time.Time LastStartTime time.Time LastStopTime time.Time Name string Runtime time.Duration FilterTime uint64 ID BlowerID HotLoop LoopID ColdLoop LoopID Zone ZoneID Running bool }
A blower is a device that blows air over a coil to cool/heat the air blowers are connected to loops, which are driven by pumps a zone is the region of the building serviced by one or more blowers
type BlowerID ¶
type BlowerID uint8
BlowerID a the unique identifier of each individual blower
type Command ¶
type Command struct { Source string // a string describing the reasonx:, manual, schedule, auto RunTime time.Duration // the time to run the device/zone TargetState bool }
Command is what the MQTT server sends to the relay controllers
type Config ¶
type Config struct { StateStore string // the directory in which to store running state SystemMode SystemModeT // heating/cooling ControlMode ControlModeT // off/manual/schedule/temp MQTT *MQTTConfig // config for the mqtt server HTTPaddr string // the address on which to listen :8080 HTTPStaticDir string // the directory that contains the built webui HTTPAuthData string // the file that contains the HTTP authentication creds DataLogFile string // the name of the datalog files OpenWeatherMapKey string // API key from OpenWeatherMap OpenWeatherMapID int // locaiton ID in OpenWeatherMap ChillerLockout bool // is the chiller locked-out due to being too cold? // BoilerLockout bool // is the boiler locked-out due to being to warm? // move to per-zone check Blowers []*Blower Chillers []*Chiller Dampers []*Damper Loops []*Loop Pumps []*Pump Rooms []*Room Valves []*Valve Zones []*Zone TimeZoneLocation string }
Config is the system configuration and run-time data a subset of Config is used for the startup configuration
func GetConfig ¶
func GetConfig() *Config
GetConfig returns the global running config, used by various sub-modules
func LoadConfig ¶
LoadConfig is called from main() to set up the running configuration
func (*Config) GetChillerFromLoop ¶
func (*Config) GetOccupancySchedule ¶
func (c *Config) GetOccupancySchedule() (*OccupancySchedule, error)
GetOccupancySchedule returns the live schedule
func (*Config) GetSchedule ¶
func (c *Config) GetSchedule() (*ScheduleList, error)
GetSchedule returns the live schedule
func (*Config) SetControlMode ¶
func (c *Config) SetControlMode(cm ControlModeT) error
SetControlMode is called from LoadConfig at startup and when the mode is changed manually
func (*Config) SetSystemMode ¶
func (c *Config) SetSystemMode(sm SystemModeT) error
SetSystemMode sets the system into the requested mode
func (*Config) WriteToStore ¶
type ControlMode ¶
type ControlMode struct {
ControlMode ControlModeT
}
ControlMode is the JSON wireformat for the REST request, dumbly named, probably unnecessary
type ControlModeT ¶
type ControlModeT uint8
ControlModeT is the real ControlMode type, used everywhere except the REST request; just simplify the REST...
const ( ControlManual ControlModeT = iota // Manual Mode ControlSchedule // Schedule Individual devices ControlTemp // Thermostatic mode ControlOff // Everything off )
func (ControlModeT) ToString ¶
func (t ControlModeT) ToString() string
ToString returns a friendly name for the ControlModeT
type DeviceID ¶
type DeviceID interface { Start(time.Duration, string) error Stop(string) // contains filtered or unexported methods }
DeviceID is a generic interface for all devices (pumps, blowers, etc)
type Loop ¶
A loop is a physical pipe that moves heated or cooled water to blowers or radiant devices around the campus. Loops connect blowers and pumps; some zones are radiant only and do not have blowers.
type MQTTConfig ¶
type MQTTConfig struct { ID string // something randomish (fumcg-hvac-server) Auth string // filename (/etc/hvac-mqtt-auth.json) Root string // base mqtt path component(s) (fumcg) ListenAddr string // (":1883") }
MQTTConfig is the configuration of the MQTT subsystem
type MQTTRequest ¶
The MQTTRequest is a wrapper type which contains both the command and the ID of the device being controlled
type OccupancyNextRunReport ¶
func NextRunReport ¶
func NextRunReport() []OccupancyNextRunReport
type OccupancyOneTimeEntry ¶
type OccupancyOneTimeEntry struct { Start time.Time End time.Time Name string Rooms []RoomID ID OccupancyOneTimeID }
ScheduleEntry is the definition of a job to be run at specified times
type OccupancyRecurringEntry ¶
type OccupancyRecurringEntry struct { Name string StartTime string // "6:30" EndTime string // "15:30" Weekdays []time.Weekday Rooms []RoomID ID OccupancyRecurringID }
ScheduleEntry is the definition of a job to be run at specified times
type OccupancyRecurringID ¶
type OccupancyRecurringID uint8
type OccupancySchedule ¶
type OccupancySchedule struct { Recurring []*OccupancyRecurringEntry OneTime []*OccupancyOneTimeEntry }
The occupancy scheduler tracks when people are expected to be in a room. If a room is marked as occupied it adjusts the heating/cooling target temp
func (*OccupancySchedule) AddOneTimeEntry ¶
func (s *OccupancySchedule) AddOneTimeEntry(e *OccupancyOneTimeEntry) error
AddOneTimeEntry adds a new entry to the one-time scheduler
func (*OccupancySchedule) AddRecurringEntry ¶
func (s *OccupancySchedule) AddRecurringEntry(e *OccupancyRecurringEntry) error
func (*OccupancySchedule) EditOneTimeEntry ¶
func (s *OccupancySchedule) EditOneTimeEntry(e *OccupancyOneTimeEntry) error
EditEntry updates an entry in the OccupancySchedule, keyed based on e.ID
func (*OccupancySchedule) EditRecurringEntry ¶
func (s *OccupancySchedule) EditRecurringEntry(e *OccupancyRecurringEntry) error
EditEntry updates an entry in the OccupancySchedule, keyed based on e.ID
func (*OccupancySchedule) GetOneTimeEntry ¶
func (s *OccupancySchedule) GetOneTimeEntry(id OccupancyOneTimeID) *OccupancyOneTimeEntry
GetOneTimeEntry returns an entry based on ID
func (*OccupancySchedule) GetRecurringEntry ¶
func (s *OccupancySchedule) GetRecurringEntry(id OccupancyRecurringID) *OccupancyRecurringEntry
func (*OccupancySchedule) RemoveOneTimeEntry ¶
func (s *OccupancySchedule) RemoveOneTimeEntry(id OccupancyOneTimeID)
RemoveOneTimeEntry remove an entry from the running scheduler and the configuration
func (*OccupancySchedule) RemoveRecurringEntry ¶
func (s *OccupancySchedule) RemoveRecurringEntry(id OccupancyRecurringID)
type PumpID ¶
type PumpID uint8
type Relay ¶
type Relay struct { StartTime time.Time // time of current start StopTime time.Time // time to stop running RunTime time.Duration // total run-time of the device Pin uint8 // gpio pin on relay control board PumpID PumpID // non-zero if devices is a pump BlowerID BlowerID // non-zero if device is a blower ChillerID ChillerID // non-zero if the device is a chiller Running bool // is the device currently running }
Relay is the primary config type for the relay-module process, set ONE of PumpID, BlowerID or ChillerID the PIN is the GPIO pin which is determined by the device hardware
type Response ¶
type Response struct { CurrentState bool RanTime time.Duration // time actually ran (when task completed) TimeRemaining time.Duration // time left on the clock (for periodic check-ins) }
Response is what the Relay Controller sends to the MQTT server
type Room ¶
type Room struct { LastUpdate time.Time Name string ShellyID string Temperature DegF ID RoomID CoolZone ZoneID HeatZone ZoneID Humidity uint8 Battery uint8 Occupied bool }
Room is the basic data type for a physical space temperature, humidity, and occupancy are tracked per-room device control is per-zone. This will allow us to track how long different rooms take to bring to proper temperature so we can set start-times properly. When we start building controls for the damnpers and valves having per-room data will help with system tuning even more
func (Room) GetZoneIDInMode ¶
func (Room) GetZoneInMode ¶
func (*Room) SetBattery ¶
SetBattery records the battery status as reported by the sensors, called from MQTT subsystem
func (*Room) SetHumidity ¶
SetHumidity records the humidity as reported by the sensors, called from MQTT subsystem
type RoomID ¶
type RoomID uint16
RoomID is the room number or other identifying number uint16 since we've got 3 floors and a uint8 would not be enough
func GetRoomIDFromShelly ¶
GetRoomIDFromShelly returns a RoomID based on an associated (case insensitive) shelly ID
func (RoomID) ToogleOccupancy ¶
func (r RoomID) ToogleOccupancy()
type ScheduleEntry ¶
type ScheduleEntry struct { Name string StartTime string // "10:30" "18:00;22:30;24:00"" Weekdays []time.Weekday Zones []ZoneID RunTime time.Duration ID uint8 Mode SystemModeT }
ScheduleEntry is the definition of a job to be run at specified times
type ScheduleList ¶
type ScheduleList struct {
List []*ScheduleEntry
}
ScheduleList is just a wrapper so we can hang methods on it The scheduler is used in "schedule" control mode (not temp) and starts and stops devices based on the schedule, not room temp/occupancy this is akin to the old mode of operation using the scheduler from the 1980s...
func (*ScheduleList) AddEntry ¶
func (s *ScheduleList) AddEntry(e *ScheduleEntry) error
AddEntry adds a new entry to the list of jobs to run
func (*ScheduleList) EditEntry ¶
func (s *ScheduleList) EditEntry(e *ScheduleEntry) error
EditEntry updates an entry in the ScheduleList, keyed based on e.ID
func (*ScheduleList) GetEntry ¶
func (s *ScheduleList) GetEntry(id uint8) *ScheduleEntry
GetEntry returns an entry in the ScheduleList by ID
func (*ScheduleList) RemoveEntry ¶
func (s *ScheduleList) RemoveEntry(id uint8)
RemoveEntry removes a ScheduleEntry from the list by ID
type SystemMode ¶
type SystemMode struct {
Mode SystemModeT
}
SystemMode is a wrapper type for clean JSON files passed from the REST interface
type SystemModeT ¶
type SystemModeT uint8
SystemModeT is a convenience type to ensure clean code
const ( SystemModeHeat SystemModeT = iota // the system is heating SystemModeCool // the system is cooling SystemModeUnknown // unused )
func (SystemModeT) ToString ¶
func (t SystemModeT) ToString() string
ToString returns a friendly string for a SystemModeT
type Valve ¶
Valve is a type for future use when we build controllers to adjust the flow on the loops
type Zone ¶
type Zone struct { Name string OneDegreeAdjTime time.Duration // how long does it take the zone to move by 1 degF Targets ZoneTargets AverageTemp DegF ID ZoneID }
A zone is a collection of rooms which are controlled together, either by radiant heat or blowers
func (*Zone) SetTargets ¶
func (z *Zone) SetTargets(c *Config, zt *ZoneTargets) error
SetTargets sets a zone's target tempratures, called from the REST interface
func (*Zone) UpdateTemp ¶
func (z *Zone) UpdateTemp()
type ZoneID ¶
type ZoneID uint8
ZoneID is a unique identifier for a zone
func (ZoneID) IsRunning ¶
A zone is runing of all devices in the zone are running, no matter how they were started XXX TODO this is not complete for radiant heating zones
func (ZoneID) Start ¶
Start starts up all devices in a zone if the zone is running, it extends the time the zone is running if the new duration is longer than the current duration e.g. 55 minutes left, called for 60 minutes, extends to 60 minutes. e.g. 120 minutes left, called for 60 minutes, does nothing
type ZoneTargets ¶
type ZoneTargets struct { HeatingOccupiedTemp DegF // 68 -- heat to 68 if someone is schedule to be in the zone HeatingUnoccupiedTemp DegF // 60 -- let it get down to 60 if no one is schedule to be in the zone CoolingOccupiedTemp DegF // 74 -- cool to 74 if someone is sheduled to be in the zone CoolingUnoccupiedTemp DegF // 80 -- let it get up to 80 if no one is scheduled to be in the zone }
Each zone has four target temps, based on systemMode and room occupancy