hueplusplus 1.2.0
Loading...
Searching...
No Matches
Schedule.h
Go to the documentation of this file.
1
22#ifndef INCLUDE_HUEPLUSPLUS_SCHEDULE_H
23#define INCLUDE_HUEPLUSPLUS_SCHEDULE_H
24
25#include "APICache.h"
26#include "Action.h"
27#include "TimePattern.h"
28
29namespace hueplusplus
30{
35{
36public:
40 Schedule(int id, const std::shared_ptr<APICache>& baseCache);
46 Schedule(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
47
53 void refresh();
54
57 void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
58
60 int getId() const;
61
65 std::string getName() const;
67 std::string getDescription() const;
69 Action getCommand() const;
74 bool isEnabled() const;
79 bool getAutodelete() const;
87
95 void setName(const std::string& name);
102 void setDescription(const std::string& description);
109 void setCommand(const Action& command);
116 void setTime(const time::TimePattern& timePattern);
125 void setEnabled(bool enabled);
132 void setAutodelete(bool autodelete);
133
134private:
140 void sendPutRequest(const nlohmann::json& request, FileInfo fileInfo);
141
142private:
143 int id;
144 APICache state;
145};
146
151{
152public:
155 CreateSchedule& setName(const std::string& name);
158 CreateSchedule& setDescription(const std::string& description);
161 CreateSchedule& setCommand(const Action& command);
167 CreateSchedule& setStatus(bool enabled);
170 CreateSchedule& setAutodelete(bool autodelete);
174 CreateSchedule& setRecycle(bool recycle);
175
178 nlohmann::json getRequest() const;
179
180private:
181 nlohmann::json request;
182};
183
184} // namespace hueplusplus
185
186#endif
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
Action executed by the bridge, e.g. as a Schedule command.
Definition Action.h:36
Parameters for creating a new Schedule.
Definition Schedule.h:151
CreateSchedule & setName(const std::string &name)
Set name.
Definition Schedule.cpp:147
CreateSchedule & setTime(const time::TimePattern &time)
Set time.
Definition Schedule.cpp:165
CreateSchedule & setCommand(const Action &command)
Set command.
Definition Schedule.cpp:159
nlohmann::json getRequest() const
Get request to create the schedule.
Definition Schedule.cpp:189
CreateSchedule & setRecycle(bool recycle)
Set recycle.
Definition Schedule.cpp:183
CreateSchedule & setDescription(const std::string &description)
Set description.
Definition Schedule.cpp:153
CreateSchedule & setStatus(bool enabled)
Set status.
Definition Schedule.cpp:171
CreateSchedule & setAutodelete(bool autodelete)
Set autodelete.
Definition Schedule.cpp:177
Definition HueCommandAPI.h:38
Schedule stored in the bridge.
Definition Schedule.h:35
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this schedule.
Definition Schedule.cpp:42
Action getCommand() const
Get schedule command.
Definition Schedule.cpp:62
void refresh()
Refreshes internal cached state.
Definition Schedule.cpp:37
int getId() const
Get schedule identifier.
Definition Schedule.cpp:47
time::AbsoluteTime getStartTime() const
Get start time for timers.
Definition Schedule.cpp:93
void setEnabled(bool enabled)
Enable or disable schedule.
Definition Schedule.cpp:130
void setAutodelete(bool autodelete)
Set autodelete.
Definition Schedule.cpp:136
void setName(const std::string &name)
Set schedule name.
Definition Schedule.cpp:98
std::string getName() const
Get schedule name.
Definition Schedule.cpp:52
time::AbsoluteTime getCreated() const
Get created time.
Definition Schedule.cpp:88
bool isEnabled() const
Check whether schedule is enabled or disabled.
Definition Schedule.cpp:74
time::TimePattern getTime() const
Get time when the event(s) will occur.
Definition Schedule.cpp:67
void setCommand(const Action &command)
Set schedule command.
Definition Schedule.cpp:110
std::string getDescription() const
Get schedule description.
Definition Schedule.cpp:57
void setTime(const time::TimePattern &timePattern)
Set new time when the event will occur.
Definition Schedule.cpp:116
bool getAutodelete() const
Get autodelete.
Definition Schedule.cpp:83
void setDescription(const std::string &description)
Set schedule description.
Definition Schedule.cpp:104
One-time, absolute time point.
Definition TimePattern.h:73
Holds different time representations.
Definition TimePattern.h:352
Namespace for the hueplusplus library.
Definition Action.h:28
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35