Documentation ¶
Index ¶
- func ActivateAutomationSystem() error
- func CalculateSunRiseSet(lat float32, lon float32) (SunTime, SunTime)
- func CreateNewAutomation(name string, description string, hour uint8, minute uint8, days []uint8, ...) (uint, error)
- func DeactivateAutomationSystem() error
- func GenerateCronExpression(hour uint8, minute uint8, days []uint8) (string, error)
- func GetDaysFromCronExpression(expr string) ([]uint8, error)
- func Init() error
- func InitLogger(logger *logrus.Logger)
- func IsValidCronExpression(expr string) bool
- func ModifyAutomationById(automationId uint, newAutomation database.AutomationWithoutIdAndUsername) error
- func RemoveAutomation(automationId uint) error
- type Automation
- type SunTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivateAutomationSystem ¶
func ActivateAutomationSystem() error
Activates all jobs saved in the database, will be used when the server was restarted If a non-critical error occurs, for example the failure to setup a job, it will be returned This function will not cancel directly if an error occurs in order to preserve the automation system's uptime
func CalculateSunRiseSet ¶
Returns (sunrise, sunset) based on the provided coordinates which are stored in the server configuration
func CreateNewAutomation ¶
func CreateNewAutomation( name string, description string, hour uint8, minute uint8, days []uint8, homescriptId string, owner string, enabled bool, timingMode database.TimingMode, ) (uint, error)
Creates a new automation which an according database entry Sets up the scheduler based on the provided hour, minute, and days of the week on which the automation should run
func DeactivateAutomationSystem ¶
func DeactivateAutomationSystem() error
Stops all jobs in the automation scheduler
func GenerateCronExpression ¶
Generates a cron-expression based on the hour, minute, and days on which the automation should run Is used for sending the owner of an automation a notification or for listing a users automations
func GetDaysFromCronExpression ¶
Returns a slice which contains the days on which a given cron-expression will run Used for generating a new cron-expression when the timing function is set to either `sunrise` or `sunset`
func InitLogger ¶
func IsValidCronExpression ¶
Validates a given cron-expression, returns false if the given cron-expression is invalid
func ModifyAutomationById ¶
func ModifyAutomationById(automationId uint, newAutomation database.AutomationWithoutIdAndUsername) error
Changes the metadata of a given automation, then restarts it so it uses the updated values such as execution time Is also used after an automation with non-normal timing has been added
func RemoveAutomation ¶
Removes an automation from the database and prevents its further execution
Types ¶
type Automation ¶
type Automation struct { Id uint Name string Description string CronExpression string CronDescription string HomescriptId string Owner string Enabled bool TimingMode database.TimingMode }
func GetUserAutomationById ¶
func GetUserAutomationById(username string, automationId uint) (Automation, bool, error)
Given an username and id, it returns a matching automation, whether it exists and an error
func GetUserAutomations ¶
func GetUserAutomations(username string) ([]Automation, error)
Returns a slice of automations which a given user has set up Does not check the validity of the user