diff options
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | schedule.go | 21 | ||||
-rw-r--r-- | schedule_test.go | 14 |
3 files changed, 41 insertions, 10 deletions
@@ -33,14 +33,6 @@ Pull requests happily accepted on GitHub - [ ] Search for new lights - [ ] Get all timezones -##### Schedules -- [x] Get all schedules -- [x] Get schedule by ID -- [x] Get schedule attributes -- [ ] Create schedules -- [ ] Set schedule attributes -- [ ] Delete schedule - ##### Groups - [ ] Get all groups - [ ] Create group @@ -49,6 +41,14 @@ Pull requests happily accepted on GitHub - [ ] Set group state - [ ] Delete Group +##### Schedules +- [x] Get all schedules +- [x] Get schedule by ID +- [x] Get schedule attributes +- [ ] Create schedules +- [ ] Set schedule attributes +- [ ] Delete schedule + ##### Scenes - [ ] Get all scenes - [ ] Create scene diff --git a/schedule.go b/schedule.go index f35802d..ce139e8 100644 --- a/schedule.go +++ b/schedule.go @@ -74,10 +74,27 @@ func (bridge *Bridge) GetSchedule(id string) (Schedule, error) { return schedule, nil } -// func (bridge *Bridge) CreateSchedule(schedule interface{}) error { -// return nil +func (bridge *Bridge) CreateSchedule(schedule Schedule) error { + uri := fmt.Sprintf("/api/%s/schedules", bridge.Username) + body, _, err := bridge.Post(uri, schedule) + if err != nil { + return err + } + + fmt.Println("CREATE SCHEDULE BODY: ", string(body)) + // TODO: Not tested or fully implemented + return nil +} + +// func (self *Schedule) Disable() { +// +// } +// +// func (self *Schedule) Enable() { +// // } // +// // func (bridge *Bridge) GetSchedule(index int) (interface{}, error) { // return []interface{}, nil // } diff --git a/schedule_test.go b/schedule_test.go index fdb3df7..4aec8c6 100644 --- a/schedule_test.go +++ b/schedule_test.go @@ -20,3 +20,17 @@ func TestGetSchedule(t *testing.T) { bridge, _ := NewBridge("192.168.1.128", "427de8bd6d49f149c8398e4fc08f") _, _ = bridge.GetSchedule("4673980164949558") } + +// func TestCreateSchedule(t *testing.T) { +// bridge, _ := NewBridge("192.168.1.128", "427de8bd6d49f149c8398e4fc08f") +// schedule := Schedule{ +// Command: interface{ +// Address: "/api/fffffffff6338294fffffffff585692d/groups/0/action", +// Body: { +// Scene: "e5e33fdf2-off-0" // scene id +// } +// Method: "PUT", +// } +// } +// bridge.CreateSchedule() +// } |