Skip to content

Commit

Permalink
rgbw2: switch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
markirb committed Jul 9, 2024
1 parent 968271a commit 3490778
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion fs_src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ function updateElement(key, value, info) {
case "model":
if (value.endsWith("RGBW2")) {
el("sys_mode_container").style.display = "block";
if (el("sys_mode_0")) el("sys_mode_0").remove();
} else {
if (el("sys_mode_3")) el("sys_mode_3").remove();
if (el("sys_mode_4")) el("sys_mode_4").remove();
Expand Down
10 changes: 9 additions & 1 deletion mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ conds:
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
- ["shelly.mode", 3] # 3 - RGB, 4 - RGBW, 5 - RGB+W, 6 - CCT, 7 - White
- ["shelly.mode", 3] # 0 - Default (4 Switches), 3 - RGB, 4 - RGBW, 5 - RGB+W, 6 - CCT, 7 - White
- ["device.id", "shellyrgbw2-??????"]
- ["shelly.name", "shellyrgbw2-??????"]
- ["wifi.ap.ssid", "shellyrgbw2-??????"]
Expand All @@ -880,6 +880,14 @@ conds:
- ["in1", "in", {title: "Input 1 settings"}]
- ["in1.ssw.name", "Shelly SSW1"]
- ["in1.sensor.name", "Shelly S1"]
- ["sw1", "sw", {title: "SW1 settings"}]
- ["sw1.name", "Shelly SW1"]
- ["sw2", "sw", {title: "SW2 settings"}]
- ["sw2.name", "Shelly SW2"]
- ["sw3", "sw", {title: "SW3 settings"}]
- ["sw3.name", "Shelly SW3"]
- ["sw4", "sw", {title: "SW4 settings"}]
- ["sw4.name", "Shelly SW4"]

- when: build_vars.MODEL == "ShellyUNI"
apply:
Expand Down
11 changes: 11 additions & 0 deletions src/ShellyRGBW2/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
ndev = 4;
} else if (mode == (int) Mode::kRGBpW) {
ndev = 2;
} else if (mode == (int) Mode::kDefault) {
CreateHAPSwitch(1, mgos_sys_config_get_sw1(), mgos_sys_config_get_in1(),
comps, accs, svr, false /* to_pri_acc */);
CreateHAPSwitch(2, mgos_sys_config_get_sw2(), mgos_sys_config_get_in1(),
comps, accs, svr, false /* to_pri_acc */);
CreateHAPSwitch(3, mgos_sys_config_get_sw3(), mgos_sys_config_get_in1(),
comps, accs, svr, false /* to_pri_acc */);
CreateHAPSwitch(4, mgos_sys_config_get_sw4(), mgos_sys_config_get_in1(),
comps, accs, svr, false /* to_pri_acc */);

return;
}

int out_pin = 1;
Expand Down

0 comments on commit 3490778

Please sign in to comment.