Loading...
Searching...
No Matches
Schedule.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_SCHEDULE_H
#define INCLUDE_HUEPLUSPLUS_SCHEDULE_H
#include "APICache.h"
#include "Action.h"
#include "TimePattern.h"
namespace hueplusplus
{
class Schedule
{
public:
Schedule(int id, const std::shared_ptr<APICache>& baseCache);
Schedule(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
void refresh();
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
int getId() const;
std::string getName() const;
std::string getDescription() const;
Action getCommand() const;
time::TimePattern getTime() const;
bool isEnabled() const;
bool getAutodelete() const;
time::AbsoluteTime getCreated() const;
time::AbsoluteTime getStartTime() const;
void setName(const std::string& name);
void setDescription(const std::string& description);
void setCommand(const Action& command);
void setTime(const time::TimePattern& timePattern);
void setEnabled(bool enabled);
void setAutodelete(bool autodelete);
private:
void sendPutRequest(const nlohmann::json& request, FileInfo fileInfo);
private:
int id;
APICache state;
};
class CreateSchedule
{
public:
CreateSchedule& setName(const std::string& name);
CreateSchedule& setDescription(const std::string& description);
CreateSchedule& setCommand(const Action& command);
CreateSchedule& setTime(const time::TimePattern& time);
CreateSchedule& setStatus(bool enabled);
CreateSchedule& setAutodelete(bool autodelete);
CreateSchedule& setRecycle(bool recycle);
nlohmann::json getRequest() const;
private:
nlohmann::json request;
};
} // namespace hueplusplus
#endif
APICache.h
Action.h
TimePattern.h
hueplusplus::APICache
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
hueplusplus::Action
Action executed by the bridge, e.g. as a Schedule command.
Definition Action.h:36
hueplusplus::CreateSchedule
Parameters for creating a new Schedule.
Definition Schedule.h:151
hueplusplus::CreateSchedule::setName
CreateSchedule & setName(const std::string &name)
Set name.
Definition Schedule.cpp:147
hueplusplus::CreateSchedule::setTime
CreateSchedule & setTime(const time::TimePattern &time)
Set time.
Definition Schedule.cpp:165
hueplusplus::CreateSchedule::setCommand
CreateSchedule & setCommand(const Action &command)
Set command.
Definition Schedule.cpp:159
hueplusplus::CreateSchedule::getRequest
nlohmann::json getRequest() const
Get request to create the schedule.
Definition Schedule.cpp:189
hueplusplus::CreateSchedule::setRecycle
CreateSchedule & setRecycle(bool recycle)
Set recycle.
Definition Schedule.cpp:183
hueplusplus::CreateSchedule::setDescription
CreateSchedule & setDescription(const std::string &description)
Set description.
Definition Schedule.cpp:153
hueplusplus::CreateSchedule::setStatus
CreateSchedule & setStatus(bool enabled)
Set status.
Definition Schedule.cpp:171
hueplusplus::CreateSchedule::setAutodelete
CreateSchedule & setAutodelete(bool autodelete)
Set autodelete.
Definition Schedule.cpp:177
hueplusplus::HueCommandAPI
Definition HueCommandAPI.h:38
hueplusplus::Schedule
Schedule stored in the bridge.
Definition Schedule.h:35
hueplusplus::Schedule::setRefreshDuration
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this schedule.
Definition Schedule.cpp:42
hueplusplus::Schedule::getCommand
Action getCommand() const
Get schedule command.
Definition Schedule.cpp:62
hueplusplus::Schedule::refresh
void refresh()
Refreshes internal cached state.
Definition Schedule.cpp:37
hueplusplus::Schedule::getId
int getId() const
Get schedule identifier.
Definition Schedule.cpp:47
hueplusplus::Schedule::getStartTime
time::AbsoluteTime getStartTime() const
Get start time for timers.
Definition Schedule.cpp:93
hueplusplus::Schedule::setEnabled
void setEnabled(bool enabled)
Enable or disable schedule.
Definition Schedule.cpp:130
hueplusplus::Schedule::setAutodelete
void setAutodelete(bool autodelete)
Set autodelete.
Definition Schedule.cpp:136
hueplusplus::Schedule::setName
void setName(const std::string &name)
Set schedule name.
Definition Schedule.cpp:98
hueplusplus::Schedule::getName
std::string getName() const
Get schedule name.
Definition Schedule.cpp:52
hueplusplus::Schedule::getCreated
time::AbsoluteTime getCreated() const
Get created time.
Definition Schedule.cpp:88
hueplusplus::Schedule::isEnabled
bool isEnabled() const
Check whether schedule is enabled or disabled.
Definition Schedule.cpp:74
hueplusplus::Schedule::getTime
time::TimePattern getTime() const
Get time when the event(s) will occur.
Definition Schedule.cpp:67
hueplusplus::Schedule::setCommand
void setCommand(const Action &command)
Set schedule command.
Definition Schedule.cpp:110
hueplusplus::Schedule::getDescription
std::string getDescription() const
Get schedule description.
Definition Schedule.cpp:57
hueplusplus::Schedule::setTime
void setTime(const time::TimePattern &timePattern)
Set new time when the event will occur.
Definition Schedule.cpp:116
hueplusplus::Schedule::getAutodelete
bool getAutodelete() const
Get autodelete.
Definition Schedule.cpp:83
hueplusplus::Schedule::setDescription
void setDescription(const std::string &description)
Set schedule description.
Definition Schedule.cpp:104
hueplusplus::time::AbsoluteTime
One-time, absolute time point.
Definition TimePattern.h:73
hueplusplus::time::TimePattern
Holds different time representations.
Definition TimePattern.h:352
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28
hueplusplus::FileInfo
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35