Documentation ¶
Index ¶
Constants ¶
const ( ActionOpen = "open" ActionClose = "close" )
Variables ¶
var ( GarageDoors []*GarageDoor InitializeGdoFunc = gdo.Initialize // abstract gdo.Initialize function call to allow mocking )
Functions ¶
func CheckGeofence ¶
func CheckGeofence(car *Car)
check if outside close geo or inside open geo and set garage door state accordingly
func ParseGarageDoorConfig ¶
func ParseGarageDoorConfig()
Types ¶
type Car ¶
type Car struct { ID int `yaml:"teslamate_car_id"` // mqtt identifier for vehicle GarageDoor *GarageDoor // bidirectional pointer to GarageDoor containing car CurrentLocation Point // current vehicle location LocationUpdate chan Point // channel to receive location updates CurDistance float64 // current distance from garagedoor location PrevGeofence string // geofence previously ascribed to car CurGeofence string // updated geofence ascribed to car when published to mqtt InsidePolyOpenGeo bool // indicates if car is currently inside the polygon_open_geofence InsidePolyCloseGeo bool // indicates if car is currently inside the polygon_close_geofence }
type CircularGeofence ¶
type CircularGeofence struct { Center Point `yaml:"center"` CloseDistance float64 `yaml:"close_distance"` // defines a radius from the center point; when vehicle moves from < distance to > distance, garage will close OpenDistance float64 `yaml:"open_distance"` // defines a radius from the center point; when vehicle moves from > distance to < distance, garage will open }
defines a center point and two radii (distances) to define open and close geofences
func (*CircularGeofence) GetMqttTopics ¶
func (c *CircularGeofence) GetMqttTopics() []string
type GarageDoor ¶
type GarageDoor struct { Geofence GeofenceInterface `yaml:"-"` // geofence; don't parse this from the geofence yaml Opener gdo.GDO `yaml:"-"` // garage door opener; don't parse this from the garage door yaml GeofenceConfig map[string]interface{} `yaml:"geofence"` OpenerConfig map[string]interface{} `yaml:"opener"` // holds gdo config that is parsed on gdo.Initialize Cars []*Car `yaml:"cars"` // cars housed within this garage OpLock bool // controls if garagedoor has been operated recently to prevent flapping }
defines a garage door with one unique geofence type: circular, teslamate, or polygon only one geofence type may be defined per garage door if more than one defined, priority will be polygon > circular > teslamate
type GeofenceInterface ¶
type GeofenceInterface interface { // get teslamate mqtt topics relevant to the implemented geofence type GetMqttTopics() []string // contains filtered or unexported methods }
interface to represent geofence object
type KML ¶
type KML struct { Document struct { Placemarks []struct { Name string `xml:"name"` Polygon struct { OuterBoundary struct { LinearRing struct { Coordinates string `xml:"coordinates"` } `xml:"linearring"` } `xml:"outerboundaryis"` } `xml:"polygon"` } `xml:"placemark"` } `xml:"document"` }
kml schema to parse coordinates from kml file for polygon geofences
type Point ¶
func (Point) IsPointDefined ¶
type PolygonGeofence ¶
type PolygonGeofence struct { Close []Point `yaml:"close"` // list of points defining a polygon; when vehicle moves from inside this geofence to outside, garage will close Open []Point `yaml:"open"` // list of points defining a polygon; when vehicle moves from outside this geofence to inside, garage will open KMLFile string `yaml:"kml_file"` }
contains 2 geofences, open and close, each of which are a list of lat/long points defining the polygon
func (*PolygonGeofence) GetMqttTopics ¶
func (p *PolygonGeofence) GetMqttTopics() []string
type TeslamateGeofence ¶
type TeslamateGeofence struct { Close TeslamateGeofenceTrigger `yaml:"close_trigger"` // garage will close when vehicle moves from `from` to `to` Open TeslamateGeofenceTrigger `yaml:"open_trigger"` // garage will open when vehicle moves from `from` to `to` }
defines triggers for open and close action for teslamate geofences
func (*TeslamateGeofence) GetMqttTopics ¶
func (t *TeslamateGeofence) GetMqttTopics() []string
type TeslamateGeofenceTrigger ¶
defines which teslamate defined geofence change will trigger an event, e.g. "home" to "not_home"
func (TeslamateGeofenceTrigger) IsTriggerDefined ¶
func (t TeslamateGeofenceTrigger) IsTriggerDefined() bool