hueplusplus 1.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
hueplusplus::Schedule Class Reference

Schedule stored in the bridge. More...

#include <hueplusplus/Schedule.h>

Public Member Functions

 Schedule (int id, const std::shared_ptr< APICache > &baseCache)
 Creates schedule with shared cache.
 
 Schedule (int id, const HueCommandAPI &commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json &currentState)
 Construct Schedule that exists in the bridge.
 
void refresh ()
 Refreshes internal cached state.
 
void setRefreshDuration (std::chrono::steady_clock::duration refreshDuration)
 Sets custom refresh interval for this schedule.
 
int getId () const
 Get schedule identifier.
 
std::string getName () const
 Get schedule name.
 
std::string getDescription () const
 Get schedule description.
 
Action getCommand () const
 Get schedule command.
 
time::TimePattern getTime () const
 Get time when the event(s) will occur.
 
bool isEnabled () const
 Check whether schedule is enabled or disabled.
 
bool getAutodelete () const
 Get autodelete.
 
time::AbsoluteTime getCreated () const
 Get created time.
 
time::AbsoluteTime getStartTime () const
 Get start time for timers.
 
void setName (const std::string &name)
 Set schedule name.
 
void setDescription (const std::string &description)
 Set schedule description.
 
void setCommand (const Action &command)
 Set schedule command.
 
void setTime (const time::TimePattern &timePattern)
 Set new time when the event will occur.
 
void setEnabled (bool enabled)
 Enable or disable schedule.
 
void setAutodelete (bool autodelete)
 Set autodelete.
 

Detailed Description

Schedule stored in the bridge.

A schedule can be created by the user to trigger actions at specific times.

Constructor & Destructor Documentation

◆ Schedule() [1/2]

hueplusplus::Schedule::Schedule ( int  id,
const std::shared_ptr< APICache > &  baseCache 
)

Creates schedule with shared cache.

Parameters
idSchedule id in the bridge
baseCacheCache of the schedule list.

◆ Schedule() [2/2]

hueplusplus::Schedule::Schedule ( int  id,
const HueCommandAPI commands,
std::chrono::steady_clock::duration  refreshDuration,
const nlohmann::json &  currentState 
)

Construct Schedule that exists in the bridge.

Parameters
idSchedule ID
commandsHueCommandAPI for requests
refreshDurationTime between refreshing the cached state
currentStateThe current state, may be null.

Member Function Documentation

◆ getAutodelete()

bool hueplusplus::Schedule::getAutodelete ( ) const

Get autodelete.

When autodelete is set to true, the schedule is removed after it expires. Only for non-recurring schedules.

◆ getCommand()

Action hueplusplus::Schedule::getCommand ( ) const

Get schedule command.

◆ getCreated()

time::AbsoluteTime hueplusplus::Schedule::getCreated ( ) const

Get created time.

Returns
AbsoluteTime without variation

◆ getDescription()

std::string hueplusplus::Schedule::getDescription ( ) const

Get schedule description.

◆ getId()

int hueplusplus::Schedule::getId ( ) const

Get schedule identifier.

◆ getName()

std::string hueplusplus::Schedule::getName ( ) const

Get schedule name.

The schedule name is always unique for the bridge.

◆ getStartTime()

time::AbsoluteTime hueplusplus::Schedule::getStartTime ( ) const

Get start time for timers.

Returns
AbsoluteTime without variation when the timer was started.
Exceptions
nlohmann::json::out_of_rangewhen the schedule does not have a start time

◆ getTime()

time::TimePattern hueplusplus::Schedule::getTime ( ) const

Get time when the event(s) will occur.

Returns
TimePattern in local timezone

◆ isEnabled()

bool hueplusplus::Schedule::isEnabled ( ) const

Check whether schedule is enabled or disabled.

◆ refresh()

void hueplusplus::Schedule::refresh ( )

Refreshes internal cached state.

Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setAutodelete()

void hueplusplus::Schedule::setAutodelete ( bool  autodelete)

Set autodelete.

Parameters
autodeleteWhether to delete the schedule after it expires
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setCommand()

void hueplusplus::Schedule::setCommand ( const Action command)

Set schedule command.

Parameters
commandNew action that is executed when the time event occurs.
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setDescription()

void hueplusplus::Schedule::setDescription ( const std::string &  description)

Set schedule description.

Parameters
descriptionNew description, may be empty. Max size is 64.
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setEnabled()

void hueplusplus::Schedule::setEnabled ( bool  enabled)

Enable or disable schedule.

Parameters
enabledtrue to enable, false to disable.

Can be used to reset a timer by setting to disabled and enabled again.

Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setName()

void hueplusplus::Schedule::setName ( const std::string &  name)

Set schedule name.

Parameters
nameNew name for the schedule. Max size is 32. Must be unique for all schedules, otherwise a number is added.
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setRefreshDuration()

void hueplusplus::Schedule::setRefreshDuration ( std::chrono::steady_clock::duration  refreshDuration)

Sets custom refresh interval for this schedule.

Parameters
refreshDurationThe new minimum duration between refreshes. May be 0 or c_refreshNever.

◆ setTime()

void hueplusplus::Schedule::setTime ( const time::TimePattern timePattern)

Set new time when the event will occur.

Parameters
timePatternAny possible value of TimePattern
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

The documentation for this class was generated from the following files: