Skip to content

Commit

Permalink
Add ShellyUDuo
Browse files Browse the repository at this point in the history
To test CCTController
  • Loading branch information
rojer committed Jun 3, 2022
1 parent 81ed305 commit 889f850
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Makefile
@@ -1,7 +1,7 @@
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules

.PHONY: build check-format format release upload \
Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlus1 ShellyPlus1PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyURGBW2 ShellyUNI
Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlus1 ShellyPlus1PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyUDuo ShellyURGBW2 ShellyUNI
.SUFFIXES:

MOS ?= mos
Expand Down Expand Up @@ -93,6 +93,10 @@ ShellyU25: PLATFORM=ubuntu
ShellyU25: build-ShellyU25
@true

ShellyUDuo: PLATFORM=ubuntu
ShellyUDuo: build-ShellyUDuo
@true

ShellyURGBW2: PLATFORM=ubuntu
ShellyURGBW2: build-ShellyURGBW2
@true
Expand Down
22 changes: 22 additions & 0 deletions mos.yml
Expand Up @@ -838,6 +838,28 @@ conds:
- ["in1.ssw.name", "ShellyU SSW1"]
- ["in1.sensor.name", "ShellyU S1"]

- when: build_vars.MODEL == "ShellyUDuo"
apply:
sources:
- src/ShellyDuo/shelly_init.cpp
- src/mock/pwm
- src/mock/wifi_config
libs:
- location: https://github.com/mongoose-os-libs/mongoose
variant: ubuntu-nossl
cdefs:
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '""'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 0
BTN_NOISY: 0
config_schema:
- ["device.id", "ShellyUBulbDuo-??????"]
- ["shelly.name", "ShellyUBulbDuo-??????"]
- ["wifi.ap.ssid", "ShellyUBulbDuo-??????"]
- ["lb1", "lb", {title: "Light bulb settings"}]
- ["lb1.initial_state", 2] # last

- when: build_vars.MODEL == "ShellyU25"
apply:
sources:
Expand Down
4 changes: 2 additions & 2 deletions src/ShellyDuo/shelly_init.cpp
Expand Up @@ -34,7 +34,7 @@ void CreatePeripherals(UNUSED_ARG std::vector<std::unique_ptr<Input>> *inputs,

void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
std::vector<std::unique_ptr<mgos::hap::Accessory>> *accs,
HAPAccessoryServerRef *svr) {
HAPAccessoryServerRef *svr UNUSED_ARG) {
std::unique_ptr<LightBulbControllerBase> lightbulb_controller;
std::unique_ptr<hap::LightBulb> hap_light;
auto *lb_cfg = (struct mgos_config_lb *) mgos_sys_config_get_lb1();
Expand All @@ -56,4 +56,4 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,

comps->push_back(std::move(hap_light));
}
} // namespace shelly
} // namespace shelly
3 changes: 2 additions & 1 deletion src/shelly_light_bulb_controller.cpp
Expand Up @@ -52,7 +52,8 @@ void LightBulbController<T>::TransitionTimerCB() {
int64_t elapsed = mgos_uptime_micros() - transition_start_;

if (elapsed >= cur.transition_time_micros) {
LOG(LL_INFO, ("Transition finished"));
LOG(LL_INFO,
("Transition finished, end state: %s", state_now_.ToString().c_str()));
state_now_ = cur.state_end;
transitions_.pop_front();
transition_timer_.Clear();
Expand Down

0 comments on commit 889f850

Please sign in to comment.