Skip to content

Commit d6cefae

Browse files
committed
Merge branch 'master' into ui-polish
2 parents fc8d256 + 1e24766 commit d6cefae

24 files changed

+1559
-53
lines changed

mos.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ config_schema:
5252
- ["sw.in_inverted", "b", false, {title: "Invert input, set to true for normally closed input"}]
5353
- ["sw.state", "b", false, {title: "State of the switch"}]
5454
- ["sw.svc_type", "i", 0, {title: "HAP service type, -1 = disable, 0 = switch, 1 = outlet, 2 = lock, 3 = valve"}]
55+
- ["sw.hk_state_inverted", "b", false, {title: "Invert switch state in HomeKit, for switch and outlet only"}]
5556
- ["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
5657
- ["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"}]
5758
- ["sw.auto_off", "b", false, {title: "Whether the switch should automatically turn OFF after turning ON"}]
@@ -88,7 +89,7 @@ config_schema:
8889
- ["gdo.name", "s", "Garage Door", {title: "Accessory name"}]
8990
- ["gdo.close_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open"}]
9091
- ["gdo.open_sensor_mode", "i", 0, {title: "Close sensor mode: 0 - normally closed, 1 - normally open, 2 - disabled"}]
91-
- ["gdo.out_mode", "i", 0, {title: "Output mode: 0 - single (open=close=1), 1 - dual (1=open, 2=close)"}]
92+
- ["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)"}]
9293
- ["gdo.move_time_ms", "i", 30000, {title: "Movement time, ms"}]
9394
- ["gdo.begin_move_time_ms", "i", 7000, {title: "Time allowed for movement to begin, ms"}]
9495
- ["gdo.pulse_time_ms", "i", 300, {title: "Output active time, ms"}]
@@ -187,6 +188,7 @@ conds:
187188
# XXX: fix size calculation with and without BLE
188189
XHAP_ACCESSORY_SERVER_SIZE: 1680
189190
HAP_LOG_LEVEL: 0 # This saves 36K on esp8266.
191+
HAP_TLV_NO_LOG: 1 # Saves us stack
190192
HAP_DISABLE_ASSERTS: 1 # 32K
191193
HAP_DISABLE_PRECONDITIONS: 1 # 40K
192194

src/ShellyDuo/shelly_init.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
4949
return;
5050
}
5151

52+
// Use adaptive lightning when possible (CCT)
53+
std::unique_ptr<hap::AdaptiveLighting> adaptive_light;
54+
adaptive_light.reset(new hap::AdaptiveLighting(hap_light.get(), lb_cfg));
55+
auto st = adaptive_light->Init();
56+
if (st.ok()) {
57+
hap_light->SetAdaptiveLight(std::move(adaptive_light));
58+
}
59+
5260
mgos::hap::Accessory *pri_acc = accs->front().get();
5361
shelly::hap::LightBulb *light_ref = hap_light.get();
5462
hap_light->set_primary(true);

src/ShellyRGBW2/shelly_init.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include "shelly_cct_controller.hpp"
19+
#include "shelly_hap_adaptive_lighting.hpp"
1920
#include "shelly_hap_input.hpp"
2021
#include "shelly_hap_light_bulb.hpp"
2122
#include "shelly_input_pin.hpp"
@@ -114,6 +115,14 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
114115
return;
115116
}
116117

118+
// Use adaptive lightning when possible (CCT)
119+
std::unique_ptr<hap::AdaptiveLighting> adaptive_light;
120+
adaptive_light.reset(new hap::AdaptiveLighting(hap_light.get(), lb_cfg));
121+
st = adaptive_light->Init();
122+
if (st.ok()) {
123+
hap_light->SetAdaptiveLight(std::move(adaptive_light));
124+
}
125+
117126
bool to_pri_acc = (ndev == 1); // only device will become primary accessory
118127
// regardless of sw_hidden status
119128
bool sw_hidden = is_optional && lb_cfg->svc_hidden;

src/shelly_common.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define SHELLY_HAP_AID_BASE_TEMPERATURE_SENSOR 0xc00
4242
#define SHELLY_HAP_AID_BASE_LEAK_SENSOR 0xe00
4343
#define SHELLY_HAP_AID_BASE_SMOKE_SENSOR 0xf00
44+
#define SHELLY_HAP_AID_BASE_CARBON_MONOXIDE_SENSOR 0x1000
45+
#define SHELLY_HAP_AID_BASE_CARBON_DIOXIDE_SENSOR 0x1100
4446

4547
#define SHELLY_HAP_IID_BASE_SWITCH 0x100
4648
#define SHELLY_HAP_IID_STEP_SWITCH 4
@@ -66,6 +68,13 @@
6668
#define SHELLY_HAP_IID_BASE_TEMPERATURE_SENSOR 0xd00
6769
#define SHELLY_HAP_IID_BASE_LEAK_SENSOR 0xe00
6870
#define SHELLY_HAP_IID_BASE_SMOKE_SENSOR 0xf00
71+
#define SHELLY_HAP_IID_BASE_ADAPTIVE_LIGHTING 0x1000
72+
#define SHELLY_HAP_IID_BASE_CARBON_MONOXIDE_SENSOR 0x1100
73+
#define SHELLY_HAP_IID_BASE_CARBON_DIOXIDE_SENSOR 0x1200
74+
75+
#define kChangeReasonAuto "AUTO"
76+
#define kChangeReasonAutoWithNotification "AUTO_NOTIFICATION"
77+
#define kCHangeReasonHAP "HAP"
6978

7079
namespace shelly {
7180

src/shelly_component.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Component {
4040
kTemperatureSensor = 12,
4141
kLeakSensor = 13,
4242
kSmokeSensor = 14,
43+
kCarbonMonoxideSensor = 15,
44+
kCarbonDioxideSensor = 16,
4345
kMax,
4446
};
4547

0 commit comments

Comments
 (0)