Skip to content

Commit 8fda2eb

Browse files
committed
Merge branch 'master' into ui-polish
2 parents 4a16bea + 6492dd0 commit 8fda2eb

17 files changed

+1519
-13
lines changed

fs_src/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ <h1 id="head">Input</h1>
595595
<option id="type_10" value="10">Doorbell</option>
596596
<option id="type_13" value="13">Leak Sensor</option>
597597
<option id="type_14" value="14">Smoke Sensor</option>
598+
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
599+
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
598600
</select>
599601
</div>
600602
<div class="form-control">
@@ -646,6 +648,8 @@ <h1 id="head">Disabled Input</h1>
646648
<option id="type_10" value="10">Doorbell</option>
647649
<option id="type_13" value="13">Leak Sensor</option>
648650
<option id="type_14" value="14">Smoke Sensor</option>
651+
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
652+
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
649653
</select>
650654
</div>
651655
<div class="button-container">
@@ -675,6 +679,8 @@ <h1 id="head">Sensor</h1>
675679
<option id="type_10" value="10">Doorbell</option>
676680
<option id="type_13" value="13">Leak Sensor</option>
677681
<option id="type_14" value="14">Smoke Sensor</option>
682+
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
683+
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
678684
</select>
679685
</div>
680686
<div class="form-control">

fs_src/script.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ class Component_Type {
6060
static kTemperatureSensor = 12;
6161
static kLeakSensor = 13;
6262
static kSmokeSensor = 14;
63-
static kMax = 15;
63+
static kCarbonMonoxideSensor = 15;
64+
static kCarbonDioxideSensor = 16;
65+
static kMax = 17;
6466
};
6567

6668
// Keep in sync with shelly::LightBulbController::BulbType.
@@ -677,6 +679,7 @@ function rgbState(c, newState) {
677679

678680
function updateComponent(cd) {
679681
let c = findOrAddContainer(cd);
682+
let whatSensor;
680683
if (!c) return;
681684
switch (cd.type) {
682685
case Component_Type.kSwitch:
@@ -879,10 +882,19 @@ function updateComponent(cd) {
879882
break;
880883
}
881884
case Component_Type.kMotionSensor:
885+
whatSensor ||= "motion";
882886
case Component_Type.kOccupancySensor:
887+
whatSensor ||= "occupancy";
883888
case Component_Type.kContactSensor:
889+
whatSensor ||= "contact";
884890
case Component_Type.kLeakSensor:
885-
case Component_Type.kSmokeSensor: {
891+
whatSensor ||= "leak";
892+
case Component_Type.kSmokeSensor:
893+
whatSensor ||= "smoke";
894+
case Component_Type.kCarbonMonoxideSensor:
895+
whatSensor ||= "carbon monoxide";
896+
case Component_Type.kCarbonDioxideSensor: {
897+
whatSensor ||= "carbon dioxide";
886898
let headText = `Input ${cd.id}`;
887899
if (cd.name) headText += ` (${cd.name})`;
888900
updateInnerText(el(c, "head"), headText);
@@ -893,8 +905,8 @@ function updateComponent(cd) {
893905
setValueIfNotModified(el(c, "idle_time"), cd.idle_time);
894906
el(c, "idle_time_container").style.display =
895907
(cd.in_mode == 0 ? "none" : "block");
896-
let what = (cd.type == 7 ? "motion" : "occupancy");
897-
let statusText = (cd.state ? `${what} detected` : `no ${what} detected`);
908+
let statusText =
909+
(cd.state ? `${whatSensor} detected` : `no ${whatSensor} detected`);
898910
if (cd.last_ev_age > 0) {
899911
statusText += `; last ${secondsToDateString(cd.last_ev_age)} ago`;
900912
}

mos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ libs:
145145
- location: https://github.com/mongoose-os-libs/core
146146
- location: https://github.com/mongoose-os-libs/file-logger
147147
- location: https://github.com/mongoose-os-libs/homekit-adk
148+
version: pull/10/head # use unmerged changes from https://github.com/mongoose-os-libs/homekit-adk/pull/10
148149
- location: https://github.com/mongoose-os-libs/http-server
149150
- location: https://github.com/mongoose-os-libs/ota-http-server
150151
- location: https://github.com/mongoose-os-libs/rpc-service-config
@@ -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)