Skip to content

Commit 7ca6f04

Browse files
committed
support addon gen3; fix device ids for +/gen3
dig_in only supported on 1Gen3 so far
1 parent 78f93bc commit 7ca6f04

File tree

4 files changed

+75
-69
lines changed

4 files changed

+75
-69
lines changed

mos.yml

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ libs:
175175
# Not enough space on 2.5
176176
# - location: https://github.com/mongoose-os-libs/rpc-mqtt
177177
# - location: https://github.com/mongoose-os-libs/rpc-service-ota
178+
# For testing GPIOs:
179+
# - location: https://github.com/mongoose-os-libs/rpc-service-gpio
178180

179181
conds:
180182
- when: mos.platform == "esp32c3"
@@ -642,9 +644,9 @@ conds:
642644
STOCK_FW_MODEL: PlusPlugS
643645
MAX_NUM_HAP_SESSIONS: 16
644646
config_schema:
645-
- ["device.id", "shellyplusplug-s-??????"]
646-
- ["shelly.name", "shellyplusplug-s-??????"]
647-
- ["wifi.ap.ssid", "shellyplusplug-s-??????"]
647+
- ["device.id", "shellyplusplug-s-????????????"]
648+
- ["shelly.name", "shellyplusplug-s-????????????"]
649+
- ["wifi.ap.ssid", "shellyplusplug-s-????????????"]
648650
- ["sw1", "sw", {title: "Plug settings"}]
649651
- ["sw1.name", "Shelly Plus Plug S"]
650652
- ["sw1.in_mode", -1]
@@ -687,9 +689,9 @@ conds:
687689
STOCK_FW_MODEL: PlusRGBWPM
688690
MAX_NUM_HAP_SESSIONS: 16
689691
config_schema:
690-
- ["device.id", "ShellyPlusRGBWPM-??????"]
691-
- ["shelly.name", "ShellyPlusRGBWPM-??????"]
692-
- ["wifi.ap.ssid", "ShellyPlusRGBWPM-??????"]
692+
- ["device.id", "ShellyPlusRGBWPM-????????????"]
693+
- ["shelly.name", "ShellyPlusRGBWPM-????????????"]
694+
- ["wifi.ap.ssid", "ShellyPlusRGBWPM-????????????"]
693695

694696
- ["lb1", "lb", {title: "Light 1 settings"}]
695697
- ["lb2", "lb", {title: "Light 2 settings"}]
@@ -748,9 +750,9 @@ conds:
748750
MGOS_CONFIG_DEV_6: "shelly"
749751
MGOS_CONFIG_DEV_7: "shelly,4096"
750752
config_schema:
751-
- ["device.id", "ShellyPlus1PMMini-??????"]
752-
- ["shelly.name", "ShellyPlus1PMMini-??????"]
753-
- ["wifi.ap.ssid", "ShellyPlus1PMMini-??????"]
753+
- ["device.id", "ShellyPlus1PMMini-????????????"]
754+
- ["shelly.name", "ShellyPlus1PMMini-????????????"]
755+
- ["wifi.ap.ssid", "ShellyPlus1PMMini-????????????"]
754756
- ["sw1", "sw", {title: "SW1 settings"}]
755757
- ["sw1.name", "Shelly SW"]
756758
- ["in1", "in", {title: "Input 1 settings"}]
@@ -806,13 +808,13 @@ conds:
806808
RELAY1_GPIO: 5
807809
SWITCH1_GPIO: 10
808810
ADC_GPIO: 3
809-
ADDON_OUT_GPIO: -1 #most likely: 8
810-
ADDON_IN_GPIO: -1 #most likely: 21
811-
ADDON_DIG_GPIO: -1 #most likely: 9
811+
ADDON_OUT_GPIO: 9
812+
ADDON_IN_GPIO: 21
813+
ADDON_DIG_GPIO: 6
812814
config_schema:
813-
- ["device.id", "Shelly1Gen3-??????"]
814-
- ["shelly.name", "Shelly1Gen3-??????"]
815-
- ["wifi.ap.ssid", "Shelly1Gen3-??????"]
815+
- ["device.id", "Shelly1G3-????????????"]
816+
- ["shelly.name", "Shelly1G3-????????????"]
817+
- ["wifi.ap.ssid", "Shelly1G3-????????????"]
816818
- ["sw1", "sw", {title: "SW1 settings"}]
817819
- ["sw1.name", "Shelly SW"]
818820
- ["in1", "in", {title: "Input 1 settings"}]
@@ -824,11 +826,7 @@ conds:
824826
- ["gdo1", "gdo", {title: "GDO1 settings"}]
825827
- ["gdo1.name", "Garage Door"]
826828
- ["gdo1.open_sensor_mode", -1]
827-
# Calibration values from stock
828-
- ["bl0937_0", "o", {title: "BL0937 calibration"}]
829-
- ["bl0937_0.apower_scale", "f", 2.028531, {title: "BL0937 apower scale"}]
830-
- ["bl0937_0.voltage_scale", "f", 0.15510, {title: "BL0937 voltage scale"}]
831-
- ["bl0937_0.current_scale", "f", 0.01287, {title: "BL0937 current scale"}]
829+
832830
- ["ts1", "ts", {title: "TS1 settings"}]
833831
- ["ts1.name", "Shelly TS1"]
834832
- ["ts2", "ts", {title: "TS2 settings"}]
@@ -880,12 +878,12 @@ conds:
880878
SWITCH3_GPIO: 6
881879
SWITCH4_GPIO: 5
882880
ADC_GPIO: 3
883-
ADDON_OUT_GPIO: -1
884-
ADDON_IN_GPIO: -1
881+
ADDON_OUT_GPIO: 9
882+
ADDON_IN_GPIO: 21
885883
ADDON_DIG_GPIO: -1
886884
config_schema:
887-
- ["device.id", "ShellyI4G3-??????"]
888-
- ["shelly.name", "ShellyI4G3-??????"]
885+
- ["device.id", "ShellyI4G3-????????????"]
886+
- ["shelly.name", "ShellyI4G3-????????????"]
889887
- ["wifi.ap.ssid", "ShellyI4G3-????????????"]
890888
- ["in1", "in", {title: "Input 1 settings"}]
891889
- ["in1.ssw.name", "Shelly SSW1"]
@@ -951,9 +949,9 @@ conds:
951949
MGOS_CONFIG_DEV_6: "shelly"
952950
MGOS_CONFIG_DEV_7: "shelly,4096"
953951
config_schema:
954-
- ["device.id", "ShellyPlugSG3-??????"]
955-
- ["shelly.name", "ShellyPlugSG3-??????"]
956-
- ["wifi.ap.ssid", "ShellyPlugSG3-??????"]
952+
- ["device.id", "ShellyPlugSG3-????????????"]
953+
- ["shelly.name", "ShellyPlugSG3-????????????"]
954+
- ["wifi.ap.ssid", "ShellyPlugSG3-????????????"]
957955
- ["sw1", "sw", {title: "Plug settings"}]
958956
- ["sw1.name", "Shelly Plus Plug S"]
959957
- ["sw1.in_mode", -1]
@@ -1009,17 +1007,17 @@ conds:
10091007
RELAY1_GPIO: 4
10101008
SWITCH1_GPIO: 10
10111009
ADC_GPIO: 3
1012-
ADDON_OUT_GPIO: -1
1013-
ADDON_IN_GPIO: -1
1010+
ADDON_OUT_GPIO: 9
1011+
ADDON_IN_GPIO: 21
10141012
ADDON_DIG_GPIO: -1
10151013
UART_TX_GPIO: 6
10161014
UART_RX_GPIO: 7
10171015
MGOS_CONFIG_DEV_6: "shelly"
10181016
MGOS_CONFIG_DEV_7: "shelly,4096"
10191017
config_schema:
1020-
- ["device.id", "Shelly1PMGen3-??????"]
1021-
- ["shelly.name", "Shelly1PMGen3-??????"]
1022-
- ["wifi.ap.ssid", "Shelly1PMGen3-??????"]
1018+
- ["device.id", "Shelly1PMG3-????????????"]
1019+
- ["shelly.name", "Shelly1PMG3-????????????"]
1020+
- ["wifi.ap.ssid", "Shelly1PMG3-????????????"]
10231021
- ["sw1", "sw", {title: "SW1 settings"}]
10241022
- ["sw1.name", "Shelly SW"]
10251023
- ["in1", "in", {title: "Input 1 settings"}]
@@ -1098,18 +1096,18 @@ conds:
10981096
SWITCH2_GPIO: 10
10991097
ADC_GPIO: 4
11001098
SDA_GPIO: 6
1101-
ADDON_OUT_GPIO: -1
1102-
ADDON_IN_GPIO: -1
1099+
ADDON_OUT_GPIO: 9
1100+
ADDON_IN_GPIO: 21
11031101
ADDON_DIG_GPIO: -1
11041102
I2C_RST_GPIO: 0
11051103
PM_CH0: 0
11061104
PM_CH1: 1
11071105
MGOS_CONFIG_DEV_6: "shelly"
11081106
MGOS_CONFIG_DEV_7: "shelly,4096"
11091107
config_schema:
1110-
- ["device.id", "Shelly2PMG3-??????"]
1111-
- ["shelly.name", "Shelly2PMG3-??????"]
1112-
- ["wifi.ap.ssid", "Shelly2PMG3-??????"]
1108+
- ["device.id", "Shelly2PMG3-????????????"]
1109+
- ["shelly.name", "Shelly2PMG3-????????????"]
1110+
- ["wifi.ap.ssid", "Shelly2PMG3-????????????"]
11131111
- ["i2c.enable", true]
11141112
- ["i2c.sda_gpio", 6]
11151113
- ["i2c.scl_gpio", 7]
@@ -1184,8 +1182,8 @@ conds:
11841182
MGOS_CONFIG_DEV_6: "shelly"
11851183
MGOS_CONFIG_DEV_7: "shelly,4096"
11861184
config_schema:
1187-
- ["device.id", "Shelly1PMMiniG3-????????????"]
1188-
- ["shelly.name", "Shelly1PMMiniG3-????????????"]
1185+
- ["device.id", "Shelly1PMMiniG3-????????????"]
1186+
- ["shelly.name", "Shelly1PMMiniG3-????????????"]
11891187
- ["wifi.ap.ssid", "Shelly1PMMiniG3-????????????"]
11901188
- ["sw1", "sw", {title: "SW1 settings"}]
11911189
- ["sw1.name", "Shelly SW"]
@@ -1234,9 +1232,9 @@ conds:
12341232
STOCK_FW_MODEL: Mini1G3
12351233
MAX_NUM_HAP_SESSIONS: 16
12361234
config_schema:
1237-
- ["device.id", "ShellyMini1G3-??????"]
1238-
- ["shelly.name", "ShellyMini1G3-??????"]
1239-
- ["wifi.ap.ssid", "ShellyMini1G3-??????"]
1235+
- ["device.id", "ShellyMini1G3-????????????"]
1236+
- ["shelly.name", "ShellyMini1G3-????????????"]
1237+
- ["wifi.ap.ssid", "ShellyMini1G3-????????????"]
12401238
- ["sw1", "sw", {title: "SW1 settings"}]
12411239
- ["sw1.name", "Shelly SW"]
12421240
- ["in1", "in", {title: "Input 1 settings"}]
@@ -1274,9 +1272,9 @@ conds:
12741272
STOCK_FW_MODEL: Plus1Mini
12751273
MAX_NUM_HAP_SESSIONS: 16
12761274
config_schema:
1277-
- ["device.id", "ShellyPlus1Mini-??????"]
1278-
- ["shelly.name", "ShellyPlus1Mini-??????"]
1279-
- ["wifi.ap.ssid", "ShellyPlus1Mini-??????"]
1275+
- ["device.id", "ShellyPlus1Mini-????????????"]
1276+
- ["shelly.name", "ShellyPlus1Mini-????????????"]
1277+
- ["wifi.ap.ssid", "ShellyPlus1Mini-????????????"]
12801278
- ["sw1", "sw", {title: "SW1 settings"}]
12811279
- ["sw1.name", "Shelly SW"]
12821280
- ["in1", "in", {title: "Input 1 settings"}]
@@ -1321,9 +1319,9 @@ conds:
13211319
ADDON_IN_GPIO: 1
13221320
ADDON_DIG_GPIO: 19
13231321
config_schema:
1324-
- ["device.id", "ShellyPlus1-??????"]
1325-
- ["shelly.name", "ShellyPlus1-??????"]
1326-
- ["wifi.ap.ssid", "ShellyPlus1-??????"]
1322+
- ["device.id", "shellyplus1-????????????"]
1323+
- ["shelly.name", "ShellyPlus1-????????????"]
1324+
- ["wifi.ap.ssid", "ShellyPlus1-????????????"]
13271325
- ["sw1", "sw", {title: "SW1 settings"}]
13281326
- ["sw1.name", "Shelly SW"]
13291327
- ["in1", "in", {title: "Input 1 settings"}]
@@ -1382,9 +1380,9 @@ conds:
13821380
ADDON_IN_GPIO: 1
13831381
ADDON_DIG_GPIO: 19
13841382
config_schema:
1385-
- ["device.id", "ShellyPlus1PM-??????"]
1386-
- ["shelly.name", "ShellyPlus1PM-??????"]
1387-
- ["wifi.ap.ssid", "ShellyPlus1PM-??????"]
1383+
- ["device.id", "ShellyPlus1PM-????????????"]
1384+
- ["shelly.name", "ShellyPlus1PM-????????????"]
1385+
- ["wifi.ap.ssid", "ShellyPlus1PM-????????????"]
13881386
- ["sw1", "sw", {title: "SW1 settings"}]
13891387
- ["sw1.name", "Shelly SW"]
13901388
- ["in1", "in", {title: "Input 1 settings"}]
@@ -1460,9 +1458,9 @@ conds:
14601458
PM_CH0: 1
14611459
PM_CH1: 0
14621460
config_schema:
1463-
- ["device.id", "ShellyPlus2PM-??????"]
1464-
- ["shelly.name", "ShellyPlus2PM-??????"]
1465-
- ["wifi.ap.ssid", "ShellyPlus2PM-??????"]
1461+
- ["device.id", "ShellyPlus2PM-????????????"]
1462+
- ["shelly.name", "ShellyPlus2PM-????????????"]
1463+
- ["wifi.ap.ssid", "ShellyPlus2PM-????????????"]
14661464
- ["i2c.enable", true]
14671465
- ["i2c.sda_gpio", 33]
14681466
- ["i2c.scl_gpio", 25]
@@ -1540,8 +1538,8 @@ conds:
15401538
ADDON_IN_GPIO: 1
15411539
ADDON_DIG_GPIO: 19
15421540
config_schema:
1543-
- ["device.id", "ShellyPlusI4-??????"]
1544-
- ["shelly.name", "ShellyPlusI4-??????"]
1541+
- ["device.id", "ShellyPlusI4-????????????"]
1542+
- ["shelly.name", "ShellyPlusI4-????????????"]
15451543
- ["wifi.ap.ssid", "ShellyPlusI4-????????????"]
15461544
- ["in1", "in", {title: "Input 1 settings"}]
15471545
- ["in1.ssw.name", "Shelly SSW1"]
@@ -1694,9 +1692,9 @@ conds:
16941692
STOCK_FW_MODEL: PlusUni
16951693
MAX_NUM_HAP_SESSIONS: 16
16961694
config_schema:
1697-
- ["device.id", "ShellyPlusUni-????????????"]
1698-
- ["shelly.name", "ShellyPlusUni--????????????"]
1699-
- ["wifi.ap.ssid", "ShellyPlusUni--????????????"]
1695+
- ["device.id", "ShellyPlusUni-????????????"]
1696+
- ["shelly.name", "ShellyPlusUni-????????????"]
1697+
- ["wifi.ap.ssid", "ShellyPlusUni-????????????"]
17001698

17011699
- ["sw1", "sw", {title: "SW1 settings"}]
17021700
- ["sw1.name", "Shelly SW1"]

src/ShellyPlus1/shelly_init.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ void CreatePeripherals(std::vector<std::unique_ptr<Input>> *inputs,
5151
sensors = DiscoverDHTSensors(pin_in, pin_out);
5252
}
5353

54-
auto *in2 = new InputPin(2, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
55-
in2->Init();
56-
inputs->emplace_back(in2);
54+
if (ADDON_DIG_GPIO != -1) {
55+
auto *in2 =
56+
new InputPin(2, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
57+
in2->Init();
58+
inputs->emplace_back(in2);
59+
}
5760

5861
} else {
5962
RestoreUART();

src/ShellyPlus1PM/shelly_init.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ void CreatePeripherals(std::vector<std::unique_ptr<Input>> *inputs,
9393
sensors = DiscoverDHTSensors(pin_in, pin_out);
9494
}
9595

96-
auto *in2 = new InputPin(2, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
97-
in2->Init();
98-
inputs->emplace_back(in2);
96+
if (ADDON_DIG_GPIO != -1) {
97+
auto *in2 =
98+
new InputPin(2, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
99+
in2->Init();
100+
inputs->emplace_back(in2);
101+
}
99102

100103
} else {
101104
RestoreUART();

src/ShellyPlus2PM/shelly_init.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ void CreatePeripherals(std::vector<std::unique_ptr<Input>> *inputs,
185185
sensors = DiscoverDHTSensors(pin_in, pin_out);
186186
}
187187

188-
auto *in_digital =
189-
new InputPin(3, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
190-
in_digital->Init();
191-
inputs->emplace_back(in_digital);
188+
if (ADDON_DIG_GPIO != -1) {
189+
auto *in_digital =
190+
new InputPin(3, ADDON_DIG_GPIO, 0, MGOS_GPIO_PULL_NONE, false);
191+
in_digital->Init();
192+
inputs->emplace_back(in_digital);
193+
}
192194

193195
} else {
194196
RestoreUART();

0 commit comments

Comments
 (0)