Loading...
Searching...
No Matches
StateTransaction.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_STATE_TRANSACTION_H
#define INCLUDE_HUEPLUSPLUS_STATE_TRANSACTION_H
#include <string>
#include "Action.h"
#include "ColorUnits.h"
#include "HueCommandAPI.h"
#include <nlohmann/json.hpp>
namespace hueplusplus
{
class StateTransaction
{
public:
StateTransaction(const HueCommandAPI& commands, const std::string& path, nlohmann::json* currentState);
StateTransaction(const StateTransaction&) = delete;
StateTransaction(StateTransaction&&) = default;
bool commit(bool trimRequest = true);
Action toAction();
StateTransaction& setOn(bool on);
StateTransaction& setBrightness(uint8_t brightness);
StateTransaction& setColorHue(uint16_t hue);
StateTransaction& setColorSaturation(uint8_t saturation);
StateTransaction& setColor(const HueSaturation& hueSat);
StateTransaction& setColor(const XY& xy);
StateTransaction& setColor(const XYBrightness& xy);
StateTransaction& setColorTemperature(unsigned int mired);
StateTransaction& setColorLoop(bool on);
StateTransaction& incrementBrightness(int increment);
StateTransaction& incrementSaturation(int increment);
StateTransaction& incrementHue(int increment);
StateTransaction& incrementColorTemperature(int increment);
StateTransaction& incrementColorXY(float xInc, float yInc);
StateTransaction& setTransition(uint16_t transition);
StateTransaction& alert();
StateTransaction& longAlert();
StateTransaction& stopAlert();
protected:
void trimRequest();
protected:
const HueCommandAPI& commands;
std::string path;
nlohmann::json* state;
nlohmann::json request;
};
} // namespace hueplusplus
#endif
Action.h
ColorUnits.h
HueCommandAPI.h
hueplusplus::Action
Action executed by the bridge, e.g. as a Schedule command.
Definition Action.h:36
hueplusplus::HueCommandAPI
Definition HueCommandAPI.h:38
hueplusplus::StateTransaction::incrementBrightness
StateTransaction & incrementBrightness(int increment)
Increment/Decrement brightness.
Definition StateTransaction.cpp:153
hueplusplus::StateTransaction::state
nlohmann::json * state
Definition StateTransaction.h:197
hueplusplus::StateTransaction::commands
const HueCommandAPI & commands
Definition StateTransaction.h:195
hueplusplus::StateTransaction::request
nlohmann::json request
Definition StateTransaction.h:198
hueplusplus::StateTransaction::setOn
StateTransaction & setOn(bool on)
Turn light on or off.
Definition StateTransaction.cpp:91
hueplusplus::StateTransaction::path
std::string path
Definition StateTransaction.h:196
hueplusplus::StateTransaction::setBrightness
StateTransaction & setBrightness(uint8_t brightness)
Set light brightness.
Definition StateTransaction.cpp:97
hueplusplus::StateTransaction::toAction
Action toAction()
Create an Action from the transaction.
Definition StateTransaction.cpp:85
hueplusplus::StateTransaction::incrementSaturation
StateTransaction & incrementSaturation(int increment)
Increment/Decrement saturaction.
Definition StateTransaction.cpp:159
hueplusplus::StateTransaction::setColorLoop
StateTransaction & setColorLoop(bool on)
Enables or disables color loop.
Definition StateTransaction.cpp:147
hueplusplus::StateTransaction::setColorHue
StateTransaction & setColorHue(uint16_t hue)
Set light hue.
Definition StateTransaction.cpp:111
hueplusplus::StateTransaction::setTransition
StateTransaction & setTransition(uint16_t transition)
Set transition time for the request.
Definition StateTransaction.cpp:183
hueplusplus::StateTransaction::incrementColorXY
StateTransaction & incrementColorXY(float xInc, float yInc)
Increment/Decrement color xy.
Definition StateTransaction.cpp:177
hueplusplus::StateTransaction::longAlert
StateTransaction & longAlert()
Trigger a long alert (15s).
Definition StateTransaction.cpp:196
hueplusplus::StateTransaction::StateTransaction
StateTransaction(StateTransaction &&)=default
hueplusplus::StateTransaction::alert
StateTransaction & alert()
Trigger an alert.
Definition StateTransaction.cpp:191
hueplusplus::StateTransaction::StateTransaction
StateTransaction(const StateTransaction &)=delete
Deleted copy constructor, do not store StateTransaction in a variable.
hueplusplus::StateTransaction::setColorSaturation
StateTransaction & setColorSaturation(uint8_t saturation)
Set light saturation.
Definition StateTransaction.cpp:104
hueplusplus::StateTransaction::setColorTemperature
StateTransaction & setColorTemperature(unsigned int mired)
Set light color temperature.
Definition StateTransaction.cpp:140
hueplusplus::StateTransaction::trimRequest
void trimRequest()
Remove parts from request that are already set in state.
Definition StateTransaction.cpp:207
hueplusplus::StateTransaction::incrementHue
StateTransaction & incrementHue(int increment)
Increment/Decrement hue.
Definition StateTransaction.cpp:165
hueplusplus::StateTransaction::stopAlert
StateTransaction & stopAlert()
Stop an ongoing long alert.
Definition StateTransaction.cpp:201
hueplusplus::StateTransaction::commit
bool commit(bool trimRequest=true)
Commit transaction and make request.
Definition StateTransaction.cpp:36
hueplusplus::StateTransaction::setColor
StateTransaction & setColor(const HueSaturation &hueSat)
Set light color in hue and saturation.
Definition StateTransaction.cpp:117
hueplusplus::StateTransaction::StateTransaction
StateTransaction(const HueCommandAPI &commands, const std::string &path, nlohmann::json *currentState)
Creates a StateTransaction to a group or light state.
Definition StateTransaction.cpp:32
hueplusplus::StateTransaction::incrementColorTemperature
StateTransaction & incrementColorTemperature(int increment)
Increment/Decrement color temperature.
Definition StateTransaction.cpp:171
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28
hueplusplus::HueSaturation
Color in hue and saturation.
Definition ColorUnits.h:32
hueplusplus::XYBrightness
Color and brightness in CIE.
Definition ColorUnits.h:63
hueplusplus::XY
Color in CIE x and y coordinates.
Definition ColorUnits.h:48