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 2, 2023
2 parents 4a16bea + 6492dd0 commit 8fda2eb
Show file tree
Hide file tree
Showing 17 changed files with 1,519 additions and 13 deletions.
6 changes: 6 additions & 0 deletions fs_src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ <h1 id="head">Input</h1>
<option id="type_10" value="10">Doorbell</option>
<option id="type_13" value="13">Leak Sensor</option>
<option id="type_14" value="14">Smoke Sensor</option>
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
</select>
</div>
<div class="form-control">
Expand Down Expand Up @@ -646,6 +648,8 @@ <h1 id="head">Disabled Input</h1>
<option id="type_10" value="10">Doorbell</option>
<option id="type_13" value="13">Leak Sensor</option>
<option id="type_14" value="14">Smoke Sensor</option>
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
</select>
</div>
<div class="button-container">
Expand Down Expand Up @@ -675,6 +679,8 @@ <h1 id="head">Sensor</h1>
<option id="type_10" value="10">Doorbell</option>
<option id="type_13" value="13">Leak Sensor</option>
<option id="type_14" value="14">Smoke Sensor</option>
<option id="type_15" value="15">Carbon Monoxide Sensor</option>
<option id="type_16" value="16">Carbon Dioxide Sensor</option>
</select>
</div>
<div class="form-control">
Expand Down
20 changes: 16 additions & 4 deletions fs_src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class Component_Type {
static kTemperatureSensor = 12;
static kLeakSensor = 13;
static kSmokeSensor = 14;
static kMax = 15;
static kCarbonMonoxideSensor = 15;
static kCarbonDioxideSensor = 16;
static kMax = 17;
};

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

function updateComponent(cd) {
let c = findOrAddContainer(cd);
let whatSensor;
if (!c) return;
switch (cd.type) {
case Component_Type.kSwitch:
Expand Down Expand Up @@ -879,10 +882,19 @@ function updateComponent(cd) {
break;
}
case Component_Type.kMotionSensor:
whatSensor ||= "motion";
case Component_Type.kOccupancySensor:
whatSensor ||= "occupancy";
case Component_Type.kContactSensor:
whatSensor ||= "contact";
case Component_Type.kLeakSensor:
case Component_Type.kSmokeSensor: {
whatSensor ||= "leak";
case Component_Type.kSmokeSensor:
whatSensor ||= "smoke";
case Component_Type.kCarbonMonoxideSensor:
whatSensor ||= "carbon monoxide";
case Component_Type.kCarbonDioxideSensor: {
whatSensor ||= "carbon dioxide";
let headText = `Input ${cd.id}`;
if (cd.name) headText += ` (${cd.name})`;
updateInnerText(el(c, "head"), headText);
Expand All @@ -893,8 +905,8 @@ function updateComponent(cd) {
setValueIfNotModified(el(c, "idle_time"), cd.idle_time);
el(c, "idle_time_container").style.display =
(cd.in_mode == 0 ? "none" : "block");
let what = (cd.type == 7 ? "motion" : "occupancy");
let statusText = (cd.state ? `${what} detected` : `no ${what} detected`);
let statusText =
(cd.state ? `${whatSensor} detected` : `no ${whatSensor} detected`);
if (cd.last_ev_age > 0) {
statusText += `; last ${secondsToDateString(cd.last_ev_age)} ago`;
}
Expand Down
2 changes: 2 additions & 0 deletions mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ libs:
- 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
version: pull/10/head # use unmerged changes from https://github.com/mongoose-os-libs/homekit-adk/pull/10
- 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 +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 8fda2eb

Please sign in to comment.