diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b110988..a7213a8b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,6 +22,7 @@ jobs: - Shelly1PMGen3 - Shelly1Gen3 - ShellyI4Gen3 + - ShellyPlugSGen3 # - Shelly25 # - ShellyColorBulb # - ShellyDuo diff --git a/Makefile b/Makefile index f23c2157..4eb615f4 100644 --- a/Makefile +++ b/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 ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyUDuo ShellyURGBW2 ShellyUNI ShellyPlus1Mini ShellyPlusRGBWPM ShellyMini1Gen3 ShellyMini1PMGen3 Shelly2PMGen3 Shelly1PMGen3 Shelly1Gen3 ShellyI4Gen3 + Shelly1 Shelly1L Shelly1PM Shelly25 Shelly2 ShellyColorBulb ShellyDuo ShellyI3 ShellyPlug ShellyPlugS ShellyPlusPlugS ShellyPlus1 ShellyPlus1PM ShellyPlus2PM ShellyPlusI4 ShellyRGBW2 ShellyVintage ShellyU ShellyU25 ShellyUDuo ShellyURGBW2 ShellyUNI ShellyPlus1Mini ShellyPlusRGBWPM ShellyMini1Gen3 ShellyMini1PMGen3 Shelly2PMGen3 Shelly1PMGen3 Shelly1Gen3 ShellyI4Gen3 ShellyPlugSGen3 .SUFFIXES: MOS ?= mos @@ -112,6 +112,10 @@ Shelly2PMGen3: PLATFORM=esp32c3 Shelly2PMGen3: build-Shelly2PMGen3 @true +ShellyPlugSGen3: PLATFORM=esp32c3 +ShellyPlugSGen3: build-ShellyPlugSGen3 + @true + ShellyMini1Gen3: PLATFORM=esp32c3 ShellyMini1Gen3: build-ShellyMini1Gen3 @true diff --git a/README.md b/README.md index b2b76100..bc931f57 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,15 @@ Reverting to stock firmware is also possible [see here](https://github.com/mongo ### Gen 3 Devices -| |[1 G3] |[1PM G3] |[2PM G3] |[I4 G3] |[Mini1 G3]|[Mini1PM G3] -|- |- |- |- |- |- |- -|Switch & Co.1 |✓ |✓ |✓ |✗ |✓ |✓ -|Stateless Input2 |✓ |✓ |✓ |✓ |✓ |✓ -|Sensors3 |✓ |✓ |✓ |✓ |✓ |✓ -|Garage door opener |✓ |✓ |✓ |✗ |✓ |✓ -|Roller shutter mode |✗ |✗ |- |✗ |✗ |✗ -|Power measurement |✗ |✓ |- |✗ |✗ |✓ -|Temperature/Humidity measurement4|- |- |- |- |✗ |✗ +| |[1 G3] |[1PM G3] |[2PM G3] |[I4 G3] |[Mini1 G3]|[Mini1PM G3]|[PlugS G3] +|- |- |- |- |- |- |- |- +|Switch & Co.1 |✓ |✓ |✓ |✗ |✓ |✓ |✓ +|Stateless Input2 |✓ |✓ |✓ |✓ |✓ |✓ |✗ +|Sensors3 |✓ |✓ |✓ |✓ |✓ |✓ |✗ +|Garage door opener |✓ |✓ |✓ |✗ |✓ |✓ |✗ +|Roller shutter mode |✗ |✗ |- |✗ |✗ |✗ |✗ +|Power measurement |✗ |✓ |- |✗ |✗ |✓ |✓ +|Temperature/Humidity measurement4|- |- |- |- |✗ |✗ |✗ ### Plus devices @@ -190,6 +190,7 @@ This firmware is free software and is distributed under [Apache 2.0 license](LIC [1PM G3]: https://www.shelly.cloud/en/products/shop/shelly-1pm-gen3 [1 G3]: https://www.shelly.cloud/en/products/shop/shelly-1-gen3 [I4 G3]: https://www.shelly.cloud/en/products/shop/shelly-i4-gen3 +[PlugS G3]: https://www.shelly.com/products/shelly-plug-s-gen3 [+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 diff --git a/mos.yml b/mos.yml index bebba570..e2067a61 100644 --- a/mos.yml +++ b/mos.yml @@ -623,6 +623,10 @@ conds: LED_ON: 1 BTN_GPIO: 9 BTN_DOWN: 0 + RELAY_GPIO: 4 + NEOPX_GPIO: 25 + NEOPX1_GPIO: 26 + ADC_GPIO: 33 PRODUCT_HW_REV: "2.0.0" STOCK_FW_MODEL: PlusPlugS MAX_NUM_HAP_SESSIONS: 16 @@ -893,6 +897,54 @@ conds: - ["ts5", "ts", {title: "TS5 settings"}] - ["ts5.name", "Shelly TS5"] + - when: build_vars.MODEL == "ShellyPlugSGen3" + apply: + name: PlugSG3 + sources: + - src/ShellyPlusPlugS + - src/BL0942 + libs: + - location: https://github.com/mongoose-os-libs/mongoose + build_vars: + OTA_DATA_ADDR: 0x10000 + OTA_DATA_SIZE: 0x4000 + NVS_ADDR: 0x14000 + NVS_SIZE: 0xC000 + APP_OFFSET: 0x20000 + APP_SLOT_SIZE: 0x280000 + MGOS_ROOT_FS_TYPE: LFS + MGOS_ROOT_FS_SIZE: 1048576 + ESP_IDF_EXTRA_PARTITION: "scratch,data,0x80,0x720000,0x80000,encrypted" + ESP_IDF_EXTRA_PARTITION_2: "shelly,data,0x88,0x7F0000,64K,encrypted" + ESP_IDF_SDKCONFIG_OPTS: > + ${build_vars.ESP_IDF_SDKCONFIG_OPTS} + CONFIG_FREERTOS_UNICORE=y + CONFIG_ESPTOOLPY_FLASHMODE_DIO=y + CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y + cdefs: + LED_GPIO: -1 + LED_ON: 1 + BTN_GPIO: 18 + BTN_DOWN: 0 + RELAY_GPIO: 5 + NEOPX_GPIO: 4 + ADC_GPIO: 3 + UART_TX_GPIO: 6 + UART_RX_GPIO: 7 + PRODUCT_HW_REV: "?" + STOCK_FW_MODEL: PlusPlugS + MAX_NUM_HAP_SESSIONS: 16 + config_schema: + - ["device.id", "ShellyPlugSG3-??????"] + - ["shelly.name", "ShellyPlugSG3-??????"] + - ["wifi.ap.ssid", "ShellyPlugSG3-??????"] + - ["sw1", "sw", {title: "Plug settings"}] + - ["sw1.name", "Shelly Plus Plug S"] + - ["sw1.in_mode", -1] + - ["sw1.svc_type", 1] # Outlet + - ["sw1.initial_state", 2] + - ["sw1.state_led_en", 1] + - when: build_vars.MODEL == "Shelly1PMGen3" apply: name: S1PMG3 diff --git a/src/ShellyPlusPlugS/shelly_init.cpp b/src/ShellyPlusPlugS/shelly_init.cpp index aea806b8..508ef145 100644 --- a/src/ShellyPlusPlugS/shelly_init.cpp +++ b/src/ShellyPlusPlugS/shelly_init.cpp @@ -22,22 +22,32 @@ #include "shelly_sys_led_btn.hpp" #include "shelly_temp_sensor_ntc.hpp" +#ifdef UART_TX_GPIO +#include "shelly_pm_bl0942.hpp" +#endif + namespace shelly { void CreatePeripherals(std::vector> *inputs, std::vector> *outputs, std::vector> *pms, std::unique_ptr *sys_temp) { - outputs->emplace_back(new OutputPin(1, 4, 1)); + outputs->emplace_back(new OutputPin(1, RELAY_GPIO, 1)); - // TODO: GPIO 25 and 26 are actually neopixel lights, and are not used as such - // currently - outputs->emplace_back(new OutputPin(2, 25, 1)); - outputs->emplace_back(new OutputPin(3, 26, 1)); + outputs->emplace_back(new OutputPin(2, NEOPX_GPIO, 1)); +#ifdef NEOPX1_GPIO + outputs->emplace_back(new OutputPin(3, NEOPX1_GPIO, 1)); +#endif +#ifndef UART_TX_GPIO std::unique_ptr pm( new BL0937PowerMeter(1, 10 /* CF */, 22 /* CF1 */, 19 /* SEL */, 2, mgos_sys_config_get_bl0937_power_coeff())); +#else + std::unique_ptr pm( + new BL0942PowerMeter(1, UART_TX_GPIO, UART_RX_GPIO, 1, 1)); +#endif + const Status &st = pm->Init(); if (st.ok()) { pms->emplace_back(std::move(pm)); @@ -45,7 +55,7 @@ void CreatePeripherals(std::vector> *inputs, const std::string &s = st.ToString(); LOG(LL_ERROR, ("PM init failed: %s", s.c_str())); } - sys_temp->reset(new TempSensorSDNT1608X103F3950(33, 3.3f, 10000.0f)); + sys_temp->reset(new TempSensorSDNT1608X103F3950(ADC_GPIO, 3.3f, 10000.0f)); InitSysLED(LED_GPIO, LED_ON); InitSysBtn(BTN_GPIO, BTN_DOWN);