Skip to content

Commit

Permalink
Merge branch 'master' into ui-polish
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Feb 15, 2023
2 parents fc8d256 + 1e24766 commit d6cefae
Show file tree
Hide file tree
Showing 24 changed files with 1,559 additions and 53 deletions.
4 changes: 3 additions & 1 deletion mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ config_schema:
- ["sw.in_inverted", "b", false, {title: "Invert input, set to true for normally closed input"}]
- ["sw.state", "b", false, {title: "State of the switch"}]
- ["sw.svc_type", "i", 0, {title: "HAP service type, -1 = disable, 0 = switch, 1 = outlet, 2 = lock, 3 = valve"}]
- ["sw.hk_state_inverted", "b", false, {title: "Invert switch state in HomeKit, for switch and outlet only"}]
- ["sw.valve_type", "i", 1, {title: "HAP valve type (if svc is 3), -1 = disable, 0 = GenericValve, 1 = Irrigation"}] # see for details about non supported types https://github.com/mongoose-os-apps/shelly-homekit/issues/510
- ["sw.initial_state", "i", 3, {title: "Initial state on power-on: 0 - off, 1 - on, 2 - restore last state, 3 - matches input if in toggle mode, otherwise off"}]
- ["sw.auto_off", "b", false, {title: "Whether the switch should automatically turn OFF after turning ON"}]
Expand Down Expand Up @@ -88,7 +89,7 @@ config_schema:
- ["gdo.name", "s", "Garage Door", {title: "Accessory name"}]
- ["gdo.close_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open"}]
- ["gdo.open_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open, 2 - disabled"}]
- ["gdo.out_mode", "i", 0, {title: "Output mode: 0 - single (open=close=1), 1 - dual (1=open, 2=close)"}]
- ["gdo.out_mode", "i", 0, {title: "Output mode: 0 - single (open=close=1), 1 - dual (1=open, 2=close), 2 - single inverted (open=close=1)"}]
- ["gdo.move_time_ms", "i", 30000, {title: "Movement time, ms"}]
- ["gdo.begin_move_time_ms", "i", 7000, {title: "Time allowed for movement to begin, ms"}]
- ["gdo.pulse_time_ms", "i", 300, {title: "Output active time, ms"}]
Expand Down Expand Up @@ -187,6 +188,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));
}

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
9 changes: 9 additions & 0 deletions src/shelly_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#define SHELLY_HAP_AID_BASE_TEMPERATURE_SENSOR 0xc00
#define SHELLY_HAP_AID_BASE_LEAK_SENSOR 0xe00
#define SHELLY_HAP_AID_BASE_SMOKE_SENSOR 0xf00
#define SHELLY_HAP_AID_BASE_CARBON_MONOXIDE_SENSOR 0x1000
#define SHELLY_HAP_AID_BASE_CARBON_DIOXIDE_SENSOR 0x1100

#define SHELLY_HAP_IID_BASE_SWITCH 0x100
#define SHELLY_HAP_IID_STEP_SWITCH 4
Expand All @@ -66,6 +68,13 @@
#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 SHELLY_HAP_IID_BASE_CARBON_MONOXIDE_SENSOR 0x1100
#define SHELLY_HAP_IID_BASE_CARBON_DIOXIDE_SENSOR 0x1200

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

namespace shelly {

Expand Down
2 changes: 2 additions & 0 deletions src/shelly_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Component {
kTemperatureSensor = 12,
kLeakSensor = 13,
kSmokeSensor = 14,
kCarbonMonoxideSensor = 15,
kCarbonDioxideSensor = 16,
kMax,
};

Expand Down
Loading

0 comments on commit d6cefae

Please sign in to comment.