OnOffDevice.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include "Device.h"
23 
24 namespace Hue
25 {
26 class OnOffDevice : public Device
27 {
28 public:
29  OnOffDevice(ID id, const String& name) : id(id), name(name)
30  {
31  }
32 
33  ID getId() const override
34  {
35  return id;
36  }
37 
38  String getName() const override
39  {
40  return name;
41  }
42 
43  bool getAttribute(Attribute attr, unsigned& value) const override
44  {
45  switch(attr) {
46  case Attribute::on:
47  value = on;
48  return true;
49  default:
50  return false;
51  }
52  }
53 
54  Status setAttribute(Attribute attr, unsigned value, Callback callback) override
55  {
56  switch(attr) {
57  case Attribute::on:
58  this->on = value;
59  return Status::success;
60  default:
61  return Status::error;
62  }
63  }
64 
65 private:
66  ID id;
67  String name;
68  bool on{false};
69 };
70 
71 } // namespace Hue
Definition: Bridge.h:29
String getName() const override
Definition: OnOffDevice.h:38
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:92
The String class.
Definition: WString.h:136
Status
Status of a setAttribute request.
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:60
Definition: Delegate.h:20
The action was performed immediately without error.
ID getId() const override
Definition: OnOffDevice.h:33
bool getAttribute(Attribute attr, unsigned &value) const override
Get the (cached) device attribute value.
Definition: OnOffDevice.h:43
Action could not be completed.
Attribute
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:97
OnOffDevice(ID id, const String &name)
Definition: OnOffDevice.h:29
Definition: OnOffDevice.h:26
uint32_t ID
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:95
Status setAttribute(Attribute attr, unsigned value, Callback callback) override
Set a device attribute.
Definition: OnOffDevice.h:54