Loading...
Searching...
No Matches
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

  id | Schedule id in the bridge
  baseCache | Cache 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

  id | Schedule ID
  commands | HueCommandAPI for requests
  refreshDuration | Time between refreshing the cached state
  currentState | The 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_range | when 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_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setAutodelete()

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

Set autodelete.

Parameters

  autodelete | Whether to delete the schedule after it expires

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setCommand()

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

Set schedule command.

Parameters

  command | New action that is executed when the time event occurs.

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setDescription()

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

Set schedule description.

Parameters

  description | New description, may be empty. Max size is 64.

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setEnabled()

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

Enable or disable schedule.

Parameters

  enabled | true to enable, false to disable.

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

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setName()

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

Set schedule name.

Parameters

  name | New name for the schedule. Max size is 32. Must be unique for all schedules, otherwise a number is added.

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

## setRefreshDuration()

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

Sets custom refresh interval for this schedule.

Parameters

  refreshDuration | The 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

  timePattern | Any possible value of TimePattern

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

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

- include/hueplusplus/Schedule.h
- src/Schedule.cpp