DimmableDevice.h
Go to the documentation of this file.
1 /****
2  * DimmableDevice.h
3  *
4  * Copyright 2019 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the HueEmulator Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include "OnOffDevice.h"
23 
24 namespace Hue
25 {
26 class DimmableDevice : public OnOffDevice
27 {
28 public:
29  DimmableDevice(ID id, const String& name) : OnOffDevice(id, name)
30  {
31  }
32 
33  bool getAttribute(Attribute attr, unsigned& value) const override
34  {
35  switch(attr) {
36  case Attribute::bri:
37  value = bri;
38  return true;
39  default:
40  return OnOffDevice::getAttribute(attr, value);
41  }
42  }
43 
44  Status setAttribute(Attribute attr, unsigned value, Callback callback) override
45  {
46  switch(attr) {
47  case Attribute::bri:
48  this->bri = value;
49  return Status::success;
50  default:
51  return OnOffDevice::setAttribute(attr, value, callback);
52  }
53  }
54 
55 private:
56  uint8_t bri{1};
57 };
58 
59 } // namespace Hue
Status setAttribute(Attribute attr, unsigned value, Callback callback) override
Set a device attribute.
Definition: OnOffDevice.h:88
The String class.
Definition: WString.h:136
Status setAttribute(Attribute attr, unsigned value, Callback callback) override
Set a device attribute.
Definition: DimmableDevice.h:78
uint32_t ID
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:95
Status
Status of a setAttribute request.
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:60
@ success
The action was performed immediately without error.
bool getAttribute(Attribute attr, unsigned &value) const override
Get the (cached) device attribute value.
Definition: DimmableDevice.h:67
OnOffDevice(ID id, const String &name)
Definition: OnOffDevice.h:63
bool getAttribute(Attribute attr, unsigned &value) const override
Get the (cached) device attribute value.
Definition: OnOffDevice.h:77
DimmableDevice(ID id, const String &name)
Definition: DimmableDevice.h:63
Definition: Bridge.h:29
Attribute
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:97
Definition: Delegate.h:20