hueplusplus 1.2.0
Loading...
Searching...
No Matches
Group.h
Go to the documentation of this file.
1
23#ifndef INCLUDE_HUEPLUSPLUS_GROUP_H
24#define INCLUDE_HUEPLUSPLUS_GROUP_H
25
26#include <string>
27#include <vector>
28
29#include "APICache.h"
30#include "Action.h"
31#include "HueCommandAPI.h"
32#include "StateTransaction.h"
33
34#include <nlohmann/json.hpp>
35
36namespace hueplusplus
37{
41class Group
42{
43public:
47 Group(int id, const std::shared_ptr<APICache>& baseCache);
53 Group(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
54
62 void refresh(bool force = false);
63
66 void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
67
70
72 int getId() const;
73
75 std::string getName() const;
76
88 std::string getType() const;
89
92 std::vector<int> getLightIds() const;
93
97 void setName(const std::string& name);
104 void setLights(const std::vector<int>& ids);
105
108 std::string getRoomType() const;
116 void setRoomType(const std::string& type);
117
120 std::string getModelId() const;
121
125 std::string getUniqueId() const;
126
133 bool getAllOn();
134
138 bool getAllOn() const;
139
146 bool getAnyOn();
147
151 bool getAnyOn() const;
152
158
165 bool getActionOn();
166
170 bool getActionOn() const;
171
178 std::pair<uint16_t, uint8_t> getActionHueSaturation();
179
183 std::pair<uint16_t, uint8_t> getActionHueSaturation() const;
184
191 unsigned int getActionBrightness();
192
196 unsigned int getActionBrightness() const;
197
204 unsigned int getActionColorTemperature();
205
209 unsigned int getActionColorTemperature() const;
210
217 std::pair<float, float> getActionColorXY();
218
222 std::pair<float, float> getActionColorXY() const;
223
231 std::string getActionColorMode();
232
237 std::string getActionColorMode() const;
238
240
243
252
255 void setOn(bool on, uint8_t transition = 4);
258 void setBrightness(uint8_t brightness, uint8_t transition = 4);
261 void setColor(const HueSaturation& hueSat, uint8_t transition = 4);
264 void setColor(const XYBrightness& xy, uint8_t transition = 4);
267 void setColorTemperature(unsigned int mired, uint8_t transition = 4);
270 void setColorLoop(bool on, uint8_t transition = 4);
271
276 void setScene(const std::string& scene);
277
283 Action createSceneAction(const std::string& scene) const;
284
286
287protected:
298 nlohmann::json sendPutRequest(const std::string& subPath, const nlohmann::json& request, FileInfo fileInfo);
299
300protected:
301 int id;
303};
304
311{
312public:
318 static CreateGroup LightGroup(const std::vector<int>& lights, const std::string& name = "");
326 static CreateGroup Room(
327 const std::vector<int>& lights, const std::string& name = "", const std::string& roomType = "");
334 static CreateGroup Entertainment(const std::vector<int>& lights, const std::string& name = "");
335
341 static CreateGroup Zone(const std::vector<int>& lights, const std::string& name = "");
342
345 nlohmann::json getRequest() const;
346
347protected:
354 const std::vector<int>& lights, const std::string& name, const std::string& type, const std::string& roomType);
355
356private:
357 std::vector<int> lights;
358 std::string name;
359 std::string type;
360 std::string roomType;
361};
362} // namespace hueplusplus
363
364#endif
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
Action executed by the bridge, e.g. as a Schedule command.
Definition Action.h:36
Parameters necessary for creating a new Group.
Definition Group.h:311
static CreateGroup LightGroup(const std::vector< int > &lights, const std::string &name="")
Create a LightGroup.
Definition Group.cpp:238
static CreateGroup Entertainment(const std::vector< int > &lights, const std::string &name="")
Create an Entertainment group.
Definition Group.cpp:248
static CreateGroup Zone(const std::vector< int > &lights, const std::string &name="")
Create a Zone.
Definition Group.cpp:253
nlohmann::json getRequest() const
Get request to create the group.
Definition Group.cpp:258
static CreateGroup Room(const std::vector< int > &lights, const std::string &name="", const std::string &roomType="")
Create a Room group.
Definition Group.cpp:243
Class for Groups of lights.
Definition Group.h:42
StateTransaction transaction()
Create a transaction for this group.
Definition Group.cpp:163
void setColor(const HueSaturation &hueSat, uint8_t transition=4)
Convenience function to set hue and saturation.
Definition Group.cpp:179
APICache state
Definition Group.h:302
bool getAllOn()
Get whether all lights are on.
Definition Group.cpp:85
std::pair< float, float > getActionColorXY()
Get color coordinates of one light in the group.
Definition Group.cpp:143
int id
Definition Group.h:301
unsigned int getActionBrightness()
Get brightness of one light in the group.
Definition Group.cpp:125
void setColorLoop(bool on, uint8_t transition=4)
Convenience function to set color loop.
Definition Group.cpp:194
void setLights(const std::vector< int > &ids)
Set group lights.
Definition Group.cpp:74
Action createSceneAction(const std::string &scene) const
Get Action to set scene.
Definition Group.cpp:204
int getId() const
Get the group id.
Definition Group.cpp:36
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this group.
Definition Group.cpp:30
std::string getType() const
Get the group type.
Definition Group.cpp:46
bool getAnyOn()
Get whether any light is on.
Definition Group.cpp:94
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
unsigned int getActionColorTemperature()
Get color temperature of one light in the group.
Definition Group.cpp:134
std::string getUniqueId() const
Get luminaire model id, only for type luminaire or lightsource.
Definition Group.cpp:233
std::string getModelId() const
Get luminaire model id, only for type luminaire.
Definition Group.cpp:228
bool getActionOn()
Get on state of one light in the group.
Definition Group.cpp:103
std::string getRoomType() const
Get room type, only for type room.
Definition Group.cpp:217
void refresh(bool force=false)
Refreshes internal cached state.
Definition Group.cpp:18
void setScene(const std::string &scene)
Recall scene for the group.
Definition Group.cpp:199
void setName(const std::string &name)
Set group name.
Definition Group.cpp:67
void setColorTemperature(unsigned int mired, uint8_t transition=4)
Convenience function to set color temperature.
Definition Group.cpp:189
void setOn(bool on, uint8_t transition=4)
Convenience function to turn lights on.
Definition Group.cpp:169
std::vector< int > getLightIds() const
Get lights in the group.
Definition Group.cpp:51
std::pair< uint16_t, uint8_t > getActionHueSaturation()
Get hue and saturation of one light in the group.
Definition Group.cpp:112
void setBrightness(uint8_t brightness, uint8_t transition=4)
Convenience function to set brightness.
Definition Group.cpp:174
std::string getName() const
Get the group name.
Definition Group.cpp:41
void setRoomType(const std::string &type)
Set room type, only for type room.
Definition Group.cpp:222
std::string getActionColorMode()
Get color mode of one light in the group.
Definition Group.cpp:154
Definition HueCommandAPI.h:38
Transaction class which can be used for either light or group state.
Definition StateTransaction.h:62
Namespace for the hueplusplus library.
Definition Action.h:28
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35
Color in hue and saturation.
Definition ColorUnits.h:32
Color and brightness in CIE.
Definition ColorUnits.h:63