Implement alarm sound
This commit is contained in:
parent
b7dbc597d8
commit
df31c4dcd1
15 changed files with 531 additions and 50 deletions
|
|
@ -250,6 +250,25 @@ func DeleteAlarmSingle(db *LevelDBStorage, alarm *AlarmSingle) (err error) {
|
|||
return db.delete(fmt.Sprintf("alarm-single-%s", alarm.Id.ToString()))
|
||||
}
|
||||
|
||||
func RemoveOldAlarmsSingle(db *LevelDBStorage) error {
|
||||
alarms, err := GetAlarmsSingle(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
for _, alarm := range alarms {
|
||||
if now.After(time.Time(alarm.Time)) {
|
||||
err = DeleteAlarmSingle(db, alarm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type AlarmException struct {
|
||||
Id Identifier `json:"id"`
|
||||
Start *Date `json:"start"`
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ type Gong struct {
|
|||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func currentGongPath(cfg *config.Config) string {
|
||||
func CurrentGongPath(cfg *config.Config) string {
|
||||
return filepath.Join(cfg.GongsDir, CURRENT_GONG)
|
||||
}
|
||||
|
||||
func LoadGongs(cfg *config.Config) (gongs []*Gong, err error) {
|
||||
// Retrieve the path of the current gong
|
||||
current_gong, err := os.Readlink(currentGongPath(cfg))
|
||||
current_gong, err := os.Readlink(CurrentGongPath(cfg))
|
||||
if err == nil {
|
||||
current_gong, _ = filepath.Abs(filepath.Join(cfg.GongsDir, current_gong))
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func (g *Gong) Rename(newName string) error {
|
|||
}
|
||||
|
||||
func (g *Gong) SetDefault(cfg *config.Config) error {
|
||||
linkpath := currentGongPath(cfg)
|
||||
linkpath := CurrentGongPath(cfg)
|
||||
os.Remove(linkpath)
|
||||
|
||||
pabs, err := filepath.Abs(g.Path)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ type Settings struct {
|
|||
GongInterval time.Duration `json:"gong_interval"`
|
||||
WeatherDelay time.Duration `json:"weather_delay"`
|
||||
WeatherAction string `json:"weather_action"`
|
||||
MaxRunTime time.Duration `json:"max_run_time"`
|
||||
}
|
||||
|
||||
// ExistsSettings checks if the settings file can by found at the given path.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue