Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ libs:
- location: ./libreset
- location: https://github.com/mongoose-os-libs/core
- location: https://github.com/mongoose-os-libs/file-logger
- location: https://github.com/mongoose-os-libs/homekit-adk
- location: https://github.com/markirb/homekit-adk
- location: https://github.com/mongoose-os-libs/http-server
- location: https://github.com/mongoose-os-libs/ota-http-server
- location: https://github.com/mongoose-os-libs/rpc-service-config
Expand Down Expand Up @@ -187,6 +187,7 @@ conds:
# XXX: fix size calculation with and without BLE
XHAP_ACCESSORY_SERVER_SIZE: 1680
HAP_LOG_LEVEL: 0 # This saves 36K on esp8266.
HAP_TLV_NO_LOG: 1 # Saves us stack
HAP_DISABLE_ASSERTS: 1 # 32K
HAP_DISABLE_PRECONDITIONS: 1 # 40K

Expand Down
8 changes: 8 additions & 0 deletions src/ShellyDuo/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
return;
}

// Use adaptive lightning when possible (CCT)
std::unique_ptr<hap::AdaptiveLighting> adaptive_light;
adaptive_light.reset(new hap::AdaptiveLighting(hap_light.get(), lb_cfg));
auto st = adaptive_light->Init();
if (st.ok()) {
hap_light->SetAdaptiveLight(std::move(adaptive_light));
}

Comment on lines +52 to +59
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be integrated in the CCTController? Because it's the only light which supports it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could. But on the other hand: the controller should not need to know about adaptive lights existing. And the Adaptive Lightning Protocol of Apple is generic in the way that it could support autotuning other characteristics, not limited to only color temperature, so I actually think it would make more sense this way

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good argument. My main point is that I don't like ot have redundant code in the device specific files. You follow the current pattern, so it's ok. That problem should be solved, but not in this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

mgos::hap::Accessory *pri_acc = accs->front().get();
shelly::hap::LightBulb *light_ref = hap_light.get();
hap_light->set_primary(true);
Expand Down
9 changes: 9 additions & 0 deletions src/ShellyRGBW2/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "shelly_cct_controller.hpp"
#include "shelly_hap_adaptive_lighting.hpp"
#include "shelly_hap_input.hpp"
#include "shelly_hap_light_bulb.hpp"
#include "shelly_input_pin.hpp"
Expand Down Expand Up @@ -114,6 +115,14 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
return;
}

// Use adaptive lightning when possible (CCT)
std::unique_ptr<hap::AdaptiveLighting> adaptive_light;
adaptive_light.reset(new hap::AdaptiveLighting(hap_light.get(), lb_cfg));
st = adaptive_light->Init();
if (st.ok()) {
hap_light->SetAdaptiveLight(std::move(adaptive_light));
}

bool to_pri_acc = (ndev == 1); // only device will become primary accessory
// regardless of sw_hidden status
bool sw_hidden = is_optional && lb_cfg->svc_hidden;
Expand Down
5 changes: 5 additions & 0 deletions src/shelly_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
#define SHELLY_HAP_IID_BASE_TEMPERATURE_SENSOR 0xd00
#define SHELLY_HAP_IID_BASE_LEAK_SENSOR 0xe00
#define SHELLY_HAP_IID_BASE_SMOKE_SENSOR 0xf00
#define SHELLY_HAP_IID_BASE_ADAPTIVE_LIGHTING 0x1000

#define kChangeReasonAuto "AUTO"
#define kChangeReasonAutoWithNotification "AUTO_NOTIFICATION"
#define kCHangeReasonHAP "HAP"

namespace shelly {

Expand Down
Loading