Loading...
Searching...
No Matches
Group.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_GROUP_H
#define INCLUDE_HUEPLUSPLUS_GROUP_H
#include <string>
#include <vector>
#include "APICache.h"
#include "Action.h"
#include "HueCommandAPI.h"
#include "StateTransaction.h"
#include <nlohmann/json.hpp>
namespace hueplusplus
{
class Group
{
public:
Group(int id, const std::shared_ptr<APICache>& baseCache);
Group(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
void refresh(bool force = false);
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
int getId() const;
std::string getName() const;
std::string getType() const;
std::vector<int> getLightIds() const;
void setName(const std::string& name);
void setLights(const std::vector<int>& ids);
std::string getRoomType() const;
void setRoomType(const std::string& type);
std::string getModelId() const;
std::string getUniqueId() const;
bool getAllOn();
bool getAllOn() const;
bool getAnyOn();
bool getAnyOn() const;
bool getActionOn();
bool getActionOn() const;
std::pair<uint16_t, uint8_t> getActionHueSaturation();
std::pair<uint16_t, uint8_t> getActionHueSaturation() const;
unsigned int getActionBrightness();
unsigned int getActionBrightness() const;
unsigned int getActionColorTemperature();
unsigned int getActionColorTemperature() const;
std::pair<float, float> getActionColorXY();
std::pair<float, float> getActionColorXY() const;
std::string getActionColorMode();
std::string getActionColorMode() const;
StateTransaction transaction();
void setOn(bool on, uint8_t transition = 4);
void setBrightness(uint8_t brightness, uint8_t transition = 4);
void setColor(const HueSaturation& hueSat, uint8_t transition = 4);
void setColor(const XYBrightness& xy, uint8_t transition = 4);
void setColorTemperature(unsigned int mired, uint8_t transition = 4);
void setColorLoop(bool on, uint8_t transition = 4);
void setScene(const std::string& scene);
Action createSceneAction(const std::string& scene) const;
protected:
nlohmann::json sendPutRequest(const std::string& subPath, const nlohmann::json& request, FileInfo fileInfo);
protected:
int id;
APICache state;
};
class CreateGroup
{
public:
static CreateGroup LightGroup(const std::vector<int>& lights, const std::string& name = "");
static CreateGroup Room(
const std::vector<int>& lights, const std::string& name = "", const std::string& roomType = "");
static CreateGroup Entertainment(const std::vector<int>& lights, const std::string& name = "");
static CreateGroup Zone(const std::vector<int>& lights, const std::string& name = "");
nlohmann::json getRequest() const;
protected:
CreateGroup(
const std::vector<int>& lights, const std::string& name, const std::string& type, const std::string& roomType);
private:
std::vector<int> lights;
std::string name;
std::string type;
std::string roomType;
};
} // namespace hueplusplus
#endif
APICache.h
Action.h
HueCommandAPI.h
StateTransaction.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::CreateGroup::LightGroup
static CreateGroup LightGroup(const std::vector< int > &lights, const std::string &name="")
Create a LightGroup.
Definition Group.cpp:238
hueplusplus::CreateGroup::Entertainment
static CreateGroup Entertainment(const std::vector< int > &lights, const std::string &name="")
Create an Entertainment group.
Definition Group.cpp:248
hueplusplus::CreateGroup::Zone
static CreateGroup Zone(const std::vector< int > &lights, const std::string &name="")
Create a Zone.
Definition Group.cpp:253
hueplusplus::CreateGroup::getRequest
nlohmann::json getRequest() const
Get request to create the group.
Definition Group.cpp:258
hueplusplus::CreateGroup::CreateGroup
CreateGroup(const std::vector< int > &lights, const std::string &name, const std::string &type, const std::string &roomType)
Protected constructor, should not be called directly.
Definition Group.cpp:274
hueplusplus::CreateGroup::Room
static CreateGroup Room(const std::vector< int > &lights, const std::string &name="", const std::string &roomType="")
Create a Room group.
Definition Group.cpp:243
hueplusplus::Group::transaction
StateTransaction transaction()
Create a transaction for this group.
Definition Group.cpp:163
hueplusplus::Group::setColor
void setColor(const HueSaturation &hueSat, uint8_t transition=4)
Convenience function to set hue and saturation.
Definition Group.cpp:179
hueplusplus::Group::state
APICache state
Definition Group.h:302
hueplusplus::Group::getAllOn
bool getAllOn()
Get whether all lights are on.
Definition Group.cpp:85
hueplusplus::Group::getActionColorXY
std::pair< float, float > getActionColorXY()
Get color coordinates of one light in the group.
Definition Group.cpp:143
hueplusplus::Group::id
int id
Definition Group.h:301
hueplusplus::Group::Group
Group(int id, const std::shared_ptr< APICache > &baseCache)
Creates group with shared cache.
Definition Group.cpp:7
hueplusplus::Group::getActionBrightness
unsigned int getActionBrightness()
Get brightness of one light in the group.
Definition Group.cpp:125
hueplusplus::Group::setColorLoop
void setColorLoop(bool on, uint8_t transition=4)
Convenience function to set color loop.
Definition Group.cpp:194
hueplusplus::Group::setLights
void setLights(const std::vector< int > &ids)
Set group lights.
Definition Group.cpp:74
hueplusplus::Group::createSceneAction
Action createSceneAction(const std::string &scene) const
Get Action to set scene.
Definition Group.cpp:204
hueplusplus::Group::getId
int getId() const
Get the group id.
Definition Group.cpp:36
hueplusplus::Group::setRefreshDuration
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this group.
Definition Group.cpp:30
hueplusplus::Group::getType
std::string getType() const
Get the group type.
Definition Group.cpp:46
hueplusplus::Group::getAnyOn
bool getAnyOn()
Get whether any light is on.
Definition Group.cpp:94
hueplusplus::Group::sendPutRequest
nlohmann::json sendPutRequest(const std::string &subPath, const nlohmann::json &request, FileInfo fileInfo)
Utility function to send a put request to the group.
Definition Group.cpp:212
hueplusplus::Group::getActionColorTemperature
unsigned int getActionColorTemperature()
Get color temperature of one light in the group.
Definition Group.cpp:134
hueplusplus::Group::getUniqueId
std::string getUniqueId() const
Get luminaire model id, only for type luminaire or lightsource.
Definition Group.cpp:233
hueplusplus::Group::getModelId
std::string getModelId() const
Get luminaire model id, only for type luminaire.
Definition Group.cpp:228
hueplusplus::Group::getActionOn
bool getActionOn()
Get on state of one light in the group.
Definition Group.cpp:103
hueplusplus::Group::getRoomType
std::string getRoomType() const
Get room type, only for type room.
Definition Group.cpp:217
hueplusplus::Group::refresh
void refresh(bool force=false)
Refreshes internal cached state.
Definition Group.cpp:18
hueplusplus::Group::setScene
void setScene(const std::string &scene)
Recall scene for the group.
Definition Group.cpp:199
hueplusplus::Group::setName
void setName(const std::string &name)
Set group name.
Definition Group.cpp:67
hueplusplus::Group::setColorTemperature
void setColorTemperature(unsigned int mired, uint8_t transition=4)
Convenience function to set color temperature.
Definition Group.cpp:189
hueplusplus::Group::setOn
void setOn(bool on, uint8_t transition=4)
Convenience function to turn lights on.
Definition Group.cpp:169
hueplusplus::Group::getLightIds
std::vector< int > getLightIds() const
Get lights in the group.
Definition Group.cpp:51
hueplusplus::Group::getActionHueSaturation
std::pair< uint16_t, uint8_t > getActionHueSaturation()
Get hue and saturation of one light in the group.
Definition Group.cpp:112
hueplusplus::Group::setBrightness
void setBrightness(uint8_t brightness, uint8_t transition=4)
Convenience function to set brightness.
Definition Group.cpp:174
hueplusplus::Group::getName
std::string getName() const
Get the group name.
Definition Group.cpp:41
hueplusplus::Group::setRoomType
void setRoomType(const std::string &type)
Set room type, only for type room.
Definition Group.cpp:222
hueplusplus::Group::getActionColorMode
std::string getActionColorMode()
Get color mode of one light in the group.
Definition Group.cpp:154
hueplusplus::HueCommandAPI
Definition HueCommandAPI.h:38
hueplusplus::StateTransaction
Transaction class which can be used for either light or group state.
Definition StateTransaction.h:62
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
hueplusplus::HueSaturation
Color in hue and saturation.
Definition ColorUnits.h:32
hueplusplus::XYBrightness
Color and brightness in CIE.
Definition ColorUnits.h:63