Skip to content

Commit

Permalink
Support for PlusRGBWPM (#1443)
Browse files Browse the repository at this point in the history
* intitial support for rgbwpm (thanks to @lanmarc77 for pinouts and testing)
  • Loading branch information
markirb committed Aug 29, 2024
1 parent 54c2ef4 commit 6ee8790
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- ShellyPlus2PM
- ShellyPlusI4
- ShellyPlusPlugS
- ShellyPlusRGBWPM
- ShellyRGBW2
- ShellyUNI
- ShellyVintage
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyUDuo ShellyURGBW2 ShellyUNI
Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyUDuo ShellyURGBW2 ShellyUNI ShellyPlusRGBWPM
.SUFFIXES:

MOS ?= mos
Expand All @@ -27,7 +27,7 @@ ifneq "$(VERBOSE)$(V)" "00"
MOS_BUILD_FLAGS_FINAL += --verbose
endif

build: Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyURGBW2 ShellyUNI
build: Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyURGBW2 ShellyUNI ShellyPlusRGBWPM

release:
$(MAKE) build CLEAN=1 RELEASE=1
Expand Down Expand Up @@ -80,6 +80,10 @@ ShellyPlus2PM: PLATFORM=esp32
ShellyPlus2PM: build-ShellyPlus2PM
@true

ShellyPlusRGBWPM: PLATFORM=esp32
ShellyPlusRGBWPM: build-ShellyPlusRGBWPM
@true

ShellyPlusI4: PLATFORM=esp32
ShellyPlusI4: build-ShellyPlusI4
@true
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ Currently not supported.
|Power measurement |✗ |✓ |✓ |✗ |✓
|Temperature/Humidity measurement<sup>4</sup>|✓ |✓ |✓ |✓ |✗

### Light Controllers

| |[+RGBWPM]|
|-|-|
|Brightness control ||
|CCT ||
|RGB(W) ||
|Switch & Co <sup>1</sup> |-|
|Power measurement |-|


### Pro devices

Currently not supported.
Expand Down Expand Up @@ -155,6 +166,7 @@ This firmware is free software and is distributed under [Apache 2.0 license](LIC
[+1]: https://www.shelly.cloud/en/products/shop/shelly-plus-1
[+1PM]: https://www.shelly.cloud/en/products/shop/shelly-plus-1-pm-2-pack/shelly-plus-1-pm
[+2PM]: https://www.shelly.cloud/en/products/shop/shelly-plus-2-pm
[+RGBWPM]: https://www.shelly.cloud/en/products/shop/shelly-plus-rgbw-pm
[+Plug S]: https://www.shelly.cloud/en/products/shop/shelly-plus-plug-s
[1L]: https://www.shelly.cloud/en/products/shop/shelly-1l
[Plug]: https://www.shelly.cloud/en/products/shop/1xplug
Expand Down
5 changes: 3 additions & 2 deletions fs_src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ function updateComponent(cd) {
if (cd.type == Component_Type.kLightBulb) {
if (cd.bulb_type == LightBulbController_BulbType.kCCT) {
headText = "CCT";
if (lastInfo.model == "ShellyRGBW2") {
if (lastInfo.model == "ShellyRGBW2" ||
lastInfo.model == "ShellyPlusRGBWPM") {
if (cd.id == 1) {
headText += " R/G";
} else {
Expand Down Expand Up @@ -937,7 +938,7 @@ function updateElement(key, value, info) {
updateInnerText(el("uptime"), durationStr(value));
break;
case "model":
if (value.endsWith("RGBW2")) {
if (value.endsWith("RGBW2") || value.endsWith("RGBWPM")) {
el("sys_mode_container").style.display = "block";
if (el("sys_mode_0")) el("sys_mode_0").remove();
} else {
Expand Down
61 changes: 61 additions & 0 deletions mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,62 @@ conds:
- ["bl0937.power_coeff", "f", 0, {title: "BL0937 counts -> watts conversion coefficient"}]
- ["bl0937.power_coeff", 1.64358469] # (16 + 1010 + 1935) / (9.55 + 617 + 1175)


- when: build_vars.MODEL == "ShellyPlusRGBWPM"
apply:
name: PlusRGBWPM
libs:
- location: https://github.com/mongoose-os-libs/mongoose
sources:
- src/ShellyRGBW2
build_vars:
MGOS_ROOT_FS_TYPE: LFS
MGOS_ROOT_FS_SIZE: 458752
ESP_IDF_EXTRA_PARTITION: "aux,0x55,0x00,0x3f0000,48K"
ESP_IDF_EXTRA_PARTITION_2: "shelly,data,0x88,0x3fc000,16K,encrypted"
ESP_IDF_SDKCONFIG_OPTS: >
${build_vars.ESP_IDF_SDKCONFIG_OPTS}
CONFIG_FREERTOS_UNICORE=y
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
cdefs:
LED_GPIO: 14
LED_ON: 0
BTN_GPIO: 22
BTN_DOWN: 0
GPIO_R: 25
GPIO_G: 26
GPIO_B: 27
GPIO_W: 4
GPIO_I1: 36
GPIO_I2: 37
GPIO_I3: 38
GPIO_I4: 39
PRODUCT_HW_REV: "0.1.6"
STOCK_FW_MODEL: PlusRGBWPM
MAX_NUM_HAP_SESSIONS: 16
config_schema:
- ["device.id", "ShellyPlusRGBWPM-??????"]
- ["shelly.name", "ShellyPlusRGBWPM-??????"]
- ["wifi.ap.ssid", "ShellyPlusRGBWPM-??????"]

- ["lb1", "lb", {title: "Light 1 settings"}]
- ["lb2", "lb", {title: "Light 2 settings"}]
- ["lb3", "lb", {title: "Light 3 settings"}]
- ["lb4", "lb", {title: "Light 4 settings"}]

- ["in1", "in", {title: "Input 1 settings"}]
- ["in1.ssw.name", "Shelly SSW1"]
- ["in1.sensor.name", "Shelly S1"]
- ["in2", "in", {title: "Input 2 settings"}]
- ["in2.ssw.name", "Shelly SSW2"]
- ["in2.sensor.name", "Shelly S2"]
- ["in3", "in", {title: "Input 3 settings"}]
- ["in3.ssw.name", "Shelly SSW3"]
- ["in3.sensor.name", "Shelly S3"]
- ["in4", "in", {title: "Input 4 settings"}]
- ["in4.ssw.name", "Shelly SSW4"]
- ["in4.sensor.name", "Shelly S4"]

- when: build_vars.MODEL == "ShellyPlus1"
apply:
name: Plus1
Expand Down Expand Up @@ -855,6 +911,11 @@ conds:
BOOT_CONFIG_ADDR: 0x7000 # To be compatible with stock firmware.
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
GPIO_R: 12
GPIO_G: 15
GPIO_B: 14
GPIO_W: 4
GPIO_I1: 5
LED_GPIO: 2
LED_ON: 0
BTN_GPIO: 13
Expand Down
2 changes: 2 additions & 0 deletions src/Shelly1PM/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void CreatePeripherals(std::vector<std::unique_ptr<Input>> *inputs,
}
sys_temp->reset(new TempSensorSDNT1608X103F3950(0, 3.3f, 33000.0f));

// Note: this does not work currently, it always detects an addon. most likely
// pin in is always pulled somewhere?
int pin_in = 3;
int pin_out = LED_GPIO;

Expand Down
29 changes: 20 additions & 9 deletions src/ShellyRGBW2/shelly_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,29 @@ void CreatePeripherals(std::vector<std::unique_ptr<Input>> *inputs,
std::vector<std::unique_ptr<Output>> *outputs,
std::vector<std::unique_ptr<PowerMeter>> *pms UNUSED_ARG,
std::unique_ptr<TempSensor> *sys_temp UNUSED_ARG) {
outputs->emplace_back(new OutputPin(1, 12, 1)); // R / CW0
outputs->emplace_back(new OutputPin(2, 15, 1)); // G / WW0
outputs->emplace_back(new OutputPin(3, 14, 1)); // B / CW1
outputs->emplace_back(new OutputPin(4, 4, 1)); // W / WW1
auto *in = new InputPin(1, 5, 1, MGOS_GPIO_PULL_NONE, true);
outputs->emplace_back(new OutputPin(1, GPIO_R, 1)); // CW0
outputs->emplace_back(new OutputPin(2, GPIO_G, 1)); // WW0
outputs->emplace_back(new OutputPin(3, GPIO_B, 1)); // CW1
outputs->emplace_back(new OutputPin(4, GPIO_W, 1)); // WW1
auto *in = new InputPin(1, GPIO_I1, 1, MGOS_GPIO_PULL_NONE, true);
in->AddHandler(std::bind(&HandleInputResetSequence, in, 0, _1, _2));
in->Init();
inputs->emplace_back(in);

#ifdef GPIO_I2
in = new InputPin(2, GPIO_I2, 1, MGOS_GPIO_PULL_NONE, true);
in->Init();
inputs->emplace_back(in);

in = new InputPin(3, GPIO_I3, 1, MGOS_GPIO_PULL_NONE, true);
in->Init();
inputs->emplace_back(in);

in = new InputPin(4, GPIO_I4, 1, MGOS_GPIO_PULL_NONE, true);
in->Init();
inputs->emplace_back(in);
#endif

InitSysLED(LED_GPIO, LED_ON);
InitSysBtn(BTN_GPIO, BTN_DOWN);
}
Expand Down Expand Up @@ -100,10 +114,7 @@ void CreateComponents(std::vector<std::unique_ptr<Component>> *comps,
out_pin += 3;
}

Input *in = FindInput(1);
if (i != 0) {
in = nullptr; // support input only for first device
}
Input *in = FindInput(i + 1);

hap_light.reset(new hap::LightBulb(
i + 1, in, std::move(lightbulb_controller), lb_cfg, is_optional));
Expand Down

0 comments on commit 6ee8790

Please sign in to comment.