Skip to content

Commit

Permalink
Merge pull request #3 from arendst/development
Browse files Browse the repository at this point in the history
Update my fork
  • Loading branch information
mike2nl authored Sep 28, 2018
2 parents 63dbd6d + f05a471 commit aa45f16
Show file tree
Hide file tree
Showing 25 changed files with 428 additions and 217 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ See [Community](https://groups.google.com/d/forum/sonoffusers) for forum.<br />
See [Chat](https://discord.gg/Ks2Kzd4) for more user experience.

The following devices are supported:
- [iTead Sonoff Basic](https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch-1.html)
- [iTead Sonoff Basic (R2)](https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch-1.html)
- [iTead Sonoff RF](https://www.itead.cc/smart-home/sonoff-rf.html)
- [iTead Sonoff SV](https://www.itead.cc/smart-home/sonoff-sv.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff_th.jpg" width="250" align="right" />
- [iTead Sonoff TH10/TH16 with temperature sensor](https://www.itead.cc/smart-home/sonoff-th.html)
Expand Down Expand Up @@ -90,10 +90,15 @@ The following devices are supported:
- [MagicHome PWM LED controller](https://github.com/arendst/Sonoff-Tasmota/wiki/MagicHome-LED-strip-controller)
- AriLux AL-LC01, AL-LC06 and AL-LC11 PWM LED controller
- [Supla device - Espablo-inCan mod. for electrical Installation box](https://forum.supla.org/viewtopic.php?f=33&t=2188)
- [BlitzWolf BW-SHP2 Smart Socket with Energy Monitoring](https://www.banggood.com/BlitzWolf-BW-SHP2-Smart-WIFI-Socket-EU-Plug-220V-16A-Work-with-Amazon-Alexa-Google-Assistant-p-1292899.html)
- [BlitzWolf BW-SHP2 Smart Socket with Energy Monitoring](https://www.banggood.com/BlitzWolf-BW-SHP2-Smart-WIFI-Socket-EU-Plug-220V-16A-Work-with-Amazon-Alexa-Google-Assistant-p-1292899.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/shelly2_small_250a.png" width="250" align="right" />
- [Luani HVIO board](https://luani.de/projekte/esp8266-hvio/)
- Xiaomi-Phillips Bulbs
- Wemos D1 mini, NodeMcu and Ledunia
- [Wemos D1 mini](https://wiki.wemos.cc/products:d1:d1_mini)
- [HuaFan Smart Socket](HuaFan-Smart-Socket)
- [Hyleton-313 Smart Plug](Hyleton-313-Smart-Plug)
- [Allterco Shelly 1](https://shelly.cloud/shelly1-open-source/)
- [Allterco Shelly 2 with Energy Monitoring](https://shelly.cloud/shelly2/)
- NodeMcu and Ledunia
- [KS-602 based switches like GresaTek, Jesiya, NewRice, Lyasi etc](https://ucexperiment.wordpress.com/2017/11/14/reprogramming-a-lyasi-wifi-wall-switch-with-esp8285/)

### Contribute
You can contribute to Sonoff-Tasmota by
Expand Down
15 changes: 15 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env_default = sonoff
;env_default = sonoff-classic
;env_default = sonoff-knx
;env_default = sonoff-sensors
;env_default = sonoff-display
;env_default = sonoff-BG
;env_default = sonoff-BR
;env_default = sonoff-CN
Expand Down Expand Up @@ -167,6 +168,20 @@ upload_resetmethod = ${common.upload_resetmethod}
upload_speed = ${common.upload_speed}
extra_scripts = ${common.extra_scripts}

[env:sonoff-display]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_DISPLAYS
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
upload_speed = ${common.upload_speed}
extra_scripts = ${common.extra_scripts}

[env:sonoff-BG]
platform = ${common.platform}
framework = ${common.framework}
Expand Down
14 changes: 13 additions & 1 deletion sonoff/_changelog.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/* 6.2.1.7 20180925
/* 6.2.1.9 20180928
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
*
* 6.2.1.8 20180926
* Change status JSON message providing more switch and retain information
* Change pinmode for no-pullup defined switches to pullup when configured as switchmode PUSHBUTTON (=3 and up) (#3896)
* Add delay after restart before processing rule sensor data (#3811)
* Fix Home Assistant forced light discovery (#3908)
* Add rule triggers SWITCH1#BOOT and POWER1#BOOT (#3904, #3910)
* Add support for Neo Coolcam Wifi Smart Power Plug
*
* 6.2.1.7 20180925
* Remove restart after ntpserver change and force NTP re-sync (#3890)
* Release full Shelly2 support
* Released tools/decode-config.py by Norbert Richter to decode configuration data. See file for information
* Add define USE_DISPLAYS for selecting image sonoff-display
*
* 6.2.1.6 20180922
* Removed commands PowerCal, VoltageCal and CurrentCal as more functionality is provided by commands PowerSet, VoltageSet and CurrentSet
Expand Down
2 changes: 1 addition & 1 deletion sonoff/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
#define D_JSON_TYPE "Type"
#define D_JSON_UPTIME "Uptime"
#define D_JSON_UTC_TIME "UTC"
#define D_JSON_UVINDEX "UvIndex"
#define D_JSON_UV_INDEX "UvIndex"
#define D_JSON_UV_LEVEL "UvLevel"
#define D_JSON_UV_POWER "UvPower"
#define D_JSON_VCC "Vcc"
Expand Down
50 changes: 25 additions & 25 deletions sonoff/language/bg-BG.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
* Updated until v6.2.0.1
* Updated until v6.2.1.8
\*********************************************************************/

//#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
Expand Down Expand Up @@ -82,7 +82,7 @@
#define D_DNS_SERVER "DNS Сървър"
#define D_DONE "Изпълнено"
#define D_DST_TIME "DST"
#define D_ECO2 "eCO2"
#define D_ECO2 "eCO₂"
#define D_EMULATION "Емулация"
#define D_ENABLED "Активиран"
#define D_ERASE "Изтриване"
Expand Down Expand Up @@ -163,15 +163,15 @@
#define D_USER "Потребител"
#define D_UTC_TIME "UTC"
#define D_UV_INDEX "UV индекс"
#define D_UV_INDEX_1 "Low"
#define D_UV_INDEX_2 "Mid"
#define D_UV_INDEX_3 "High"
#define D_UV_INDEX_4 "Danger"
#define D_UV_INDEX_5 "BurnL1/2"
#define D_UV_INDEX_6 "BurnL3"
#define D_UV_INDEX_7 "OoR"
#define D_UV_LEVEL "Ниво на ултравиолетово излъчване"
#define D_UV_POWER "UV Power"
#define D_UV_INDEX_1 "Нисък"
#define D_UV_INDEX_2 "Среден"
#define D_UV_INDEX_3 "Висок"
#define D_UV_INDEX_4 "Много висок"
#define D_UV_INDEX_5 "Изгаряне 1/2 степен"
#define D_UV_INDEX_6 "Изгаряне 3-та степен"
#define D_UV_INDEX_7 "Извън обхват"
#define D_UV_LEVEL "UV ниво"
#define D_UV_POWER "UV мощност"
#define D_VERSION "Версия"
#define D_VOLTAGE "Напрежение"
#define D_WARMLIGHT "Топла"
Expand All @@ -181,8 +181,8 @@
#define D_WARNING_MINIMAL_VERSION "ПРЕДУПРЕЖДЕНИЕ Тази версия не поддържа постоянни настройки"
#define D_LEVEL_10 "ниво 1-0"
#define D_LEVEL_01 "ниво 0-1"
#define D_SERIAL_LOGGING_DISABLED "Серийния логинг изключен"
#define D_SYSLOG_LOGGING_REENABLED "Системния логинг активиран"
#define D_SERIAL_LOGGING_DISABLED "Серийният лог изключен"
#define D_SYSLOG_LOGGING_REENABLED "Системният лог активиран"

#define D_SET_BAUDRATE_TO "Задаване скорост на предаване (Baudrate)"
#define D_RECEIVED_TOPIC "Получен топик"
Expand All @@ -194,7 +194,7 @@
#define D_BLOCKED_LOOP "Блокиран цикъл"
#define D_WPS_FAILED_WITH_STATUS "WPS конфигурацията е НЕУСПЕШНА със статус"
#define D_ACTIVE_FOR_3_MINUTES "активно в течение на 3 минути"
#define D_FAILED_TO_START "неуспешно стартиране"
#define D_FAILED_TO_START "Неуспешно стартиране"
#define D_PATCH_ISSUE_2186 "Проблем с патч 2186"
#define D_CONNECTING_TO_AP "Свързване към точка за достъп"
#define D_IN_MODE "в режим"
Expand Down Expand Up @@ -241,7 +241,7 @@
#define D_CONFIGURE_WIFI "Конфигурация на WiFi"
#define D_CONFIGURE_MQTT "Конфигурация на MQTT"
#define D_CONFIGURE_DOMOTICZ "Конфигурация на Domoticz"
#define D_CONFIGURE_LOGGING "Конфигурация на логинга"
#define D_CONFIGURE_LOGGING "Конфигурация на лога"
#define D_CONFIGURE_OTHER "Драги конфигурации"
#define D_CONFIRM_RESET_CONFIGURATION "Потвърдете изчистването"
#define D_RESET_CONFIGURATION "Изчистване на конфигурацията"
Expand Down Expand Up @@ -275,7 +275,7 @@
#define D_CLIENT "Клиент"
#define D_FULL_TOPIC "Пълен топик"

#define D_LOGGING_PARAMETERS "Параметри на логинга"
#define D_LOGGING_PARAMETERS "Параметри на лога"
#define D_SERIAL_LOG_LEVEL "Степен на серийния лог"
#define D_WEB_LOG_LEVEL "Степен на Уеб лога"
#define D_SYS_LOG_LEVEL "Степен на системния лог"
Expand Down Expand Up @@ -379,13 +379,13 @@
#define D_DOMOTICZ_TEMP "Temp"
#define D_DOMOTICZ_TEMP_HUM "Temp,Hum"
#define D_DOMOTICZ_TEMP_HUM_BARO "Temp,Hum,Baro"
#define D_DOMOTICZ_POWER_ENERGY "Power,Energy"
#define D_DOMOTICZ_ILLUMINANCE "Illuminance"
#define D_DOMOTICZ_COUNT "Count/PM1"
#define D_DOMOTICZ_VOLTAGE "Voltage/PM2,5"
#define D_DOMOTICZ_CURRENT "Current/PM10"
#define D_DOMOTICZ_AIRQUALITY "AirQuality"
#define D_DOMOTICZ_UPDATE_TIMER "Update timer"
#define D_DOMOTICZ_POWER_ENERGY "Мощност,Енергия"
#define D_DOMOTICZ_ILLUMINANCE "Осветеност"
#define D_DOMOTICZ_COUNT "Брояч/PM1"
#define D_DOMOTICZ_VOLTAGE "Напрежение/PM2,5"
#define D_DOMOTICZ_CURRENT "Ток/PM10"
#define D_DOMOTICZ_AIRQUALITY "Качество на въздуха"
#define D_DOMOTICZ_UPDATE_TIMER "Период на опресняване"

// xdrv_09_timers.ino
#define D_CONFIGURE_TIMER "Конфигуриране на таймер"
Expand Down Expand Up @@ -464,7 +464,7 @@
#define D_SENSOR_I2C_SCL "I2C SCL"
#define D_SENSOR_I2C_SDA "I2C SDA"
#define D_SENSOR_WS2812 "WS2812"
#define D_SENSOR_DFR562 "MP3 Player"
#define D_SENSOR_DFR562 "MP3 плейър"
#define D_SENSOR_IRSEND "IRsend"
#define D_SENSOR_SWITCH "Ключ" // Suffix "1"
#define D_SENSOR_BUTTON "Бутон" // Suffix "1"
Expand Down Expand Up @@ -506,7 +506,7 @@
#define D_UNIT_KILOOHM "kΩ"
#define D_UNIT_KILOWATTHOUR "kWh"
#define D_UNIT_LUX "lx"
#define D_UNIT_MICROGRAM_PER_CUBIC_METER "µg/m3"
#define D_UNIT_MICROGRAM_PER_CUBIC_METER "µg/"
#define D_UNIT_MICROMETER "µm"
#define D_UNIT_MICROSECOND "µs"
#define D_UNIT_MILLIAMPERE "mA"
Expand Down
16 changes: 8 additions & 8 deletions sonoff/language/de-DE.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@
#define D_USER "Benutzer"
#define D_UTC_TIME "UTC"
#define D_UV_INDEX "UV-Index"
#define D_UV_INDEX_1 "Low"
#define D_UV_INDEX_2 "Mid"
#define D_UV_INDEX_3 "High"
#define D_UV_INDEX_4 "Danger"
#define D_UV_INDEX_5 "BurnL1/2"
#define D_UV_INDEX_6 "BurnL3"
#define D_UV_INDEX_7 "OoR"
#define D_UV_INDEX_1 "Niedrig"
#define D_UV_INDEX_2 "Mittel"
#define D_UV_INDEX_3 "Hoch"
#define D_UV_INDEX_4 "Intensiv"
#define D_UV_INDEX_5 "Gefährlich"
#define D_UV_INDEX_6 "Schädlich"
#define D_UV_INDEX_7 "Messwert!"
#define D_UV_LEVEL "UV-Level"
#define D_UV_POWER "UV Power"
#define D_UV_POWER "UV Intensität"
#define D_VERSION "Version"
#define D_VOLTAGE "Spannung"
#define D_WARMLIGHT "warm"
Expand Down
14 changes: 7 additions & 7 deletions sonoff/language/es-AR.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@
#define D_USER "Usuario"
#define D_UTC_TIME "UTC"
#define D_UV_INDEX "Índice UV"
#define D_UV_INDEX_1 "Low"
#define D_UV_INDEX_2 "Mid"
#define D_UV_INDEX_3 "High"
#define D_UV_INDEX_4 "Danger"
#define D_UV_INDEX_5 "BurnL1/2"
#define D_UV_INDEX_6 "BurnL3"
#define D_UV_INDEX_7 "OoR"
#define D_UV_INDEX_1 "Bajo"
#define D_UV_INDEX_2 "Medio"
#define D_UV_INDEX_3 "Alto"
#define D_UV_INDEX_4 "Peligroso"
#define D_UV_INDEX_5 "Quemaduras 1 a 2 grad"
#define D_UV_INDEX_6 "Quemaduras 3 grad"
#define D_UV_INDEX_7 "Fuera de Rango"
#define D_UV_LEVEL "Nivel UV"
#define D_UV_POWER "UV Power"
#define D_VERSION "Versión"
Expand Down
22 changes: 11 additions & 11 deletions sonoff/language/fr-FR.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Use online command StateText to translate ON, OFF, HOLD and TOGGLE.
* Use online command Prefix to translate cmnd, stat and tele.
*
* Updated until v6.1.1.7
* Updated until v6.2.1.7
\*********************************************************************/

#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English)
Expand Down Expand Up @@ -65,7 +65,7 @@
#define D_BY "par" // Written by me
#define D_BYTES "Bytes"
#define D_CELSIUS "Celsius"
#define D_CHANNEL "Channel"
#define D_CHANNEL "Canal"
#define D_CO2 "Dioxyde de carbone"
#define D_CODE "code" // Button code
#define D_COLDLIGHT "Froid"
Expand Down Expand Up @@ -163,15 +163,15 @@
#define D_USER "Utilisateur"
#define D_UTC_TIME "UTC"
#define D_UV_INDEX "Indice UV"
#define D_UV_INDEX_1 "Low"
#define D_UV_INDEX_2 "Mid"
#define D_UV_INDEX_3 "High"
#define D_UV_INDEX_4 "Danger"
#define D_UV_INDEX_5 "BurnL1/2"
#define D_UV_INDEX_6 "BurnL3"
#define D_UV_INDEX_7 "OoR"
#define D_UV_INDEX_1 "Faible"
#define D_UV_INDEX_2 "Modéré"
#define D_UV_INDEX_3 "Élevé"
#define D_UV_INDEX_4 "Très élevé"
#define D_UV_INDEX_5 "Brûlure niv.1/2"
#define D_UV_INDEX_6 "Brûlure niv.3"
#define D_UV_INDEX_7 "Hors échelle"
#define D_UV_LEVEL "Niveau UV"
#define D_UV_POWER "UV Power"
#define D_UV_POWER "Puissance UV"
#define D_VERSION "Version"
#define D_VOLTAGE "Tension"
#define D_WARMLIGHT "Chaud"
Expand All @@ -184,7 +184,7 @@
#define D_SERIAL_LOGGING_DISABLED "Journalisation série désactivée"
#define D_SYSLOG_LOGGING_REENABLED "Jounalisation syslog réactivée"

#define D_SET_BAUDRATE_TO "Définir baudrate à"
#define D_SET_BAUDRATE_TO "Définir le débit à"
#define D_RECEIVED_TOPIC "Topic reçu" // Terme MQTT
#define D_DATA_SIZE "Taille données"
#define D_ANALOG_INPUT "Analogique"
Expand Down
8 changes: 0 additions & 8 deletions sonoff/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,12 @@ void RtcSettingsSave()
RtcSettings.valid = RTC_MEM_VALID;
ESP.rtcUserMemoryWrite(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM));
rtc_settings_crc = GetRtcSettingsCrc();
#ifdef DEBUG_THEO
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Dump: Save"));
RtcSettingsDump();
#endif // DEBUG_THEO
}
}

void RtcSettingsLoad()
{
ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM)); // 0x290
#ifdef DEBUG_THEO
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Dump: Load"));
RtcSettingsDump();
#endif // DEBUG_THEO
if (RtcSettings.valid != RTC_MEM_VALID) {
memset(&RtcSettings, 0, sizeof(RTCMEM));
RtcSettings.valid = RTC_MEM_VALID;
Expand Down
27 changes: 23 additions & 4 deletions sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ uint16_t blink_counter = 0; // Number of blink cycles
uint16_t seriallog_timer = 0; // Timer to disable Seriallog
uint16_t syslog_timer = 0; // Timer to re-enable syslog_level
uint16_t holdbutton[MAX_KEYS] = { 0 }; // Timer for button hold
uint16_t switch_no_pullup = 0; // Switch pull-up bitmask flags
int16_t save_data_counter; // Counter and flag for config save to Flash
RulesBitfield rules_flag; // Rule state flags (16 bits)
uint8_t serial_local = 0; // Handle serial locally;
Expand Down Expand Up @@ -1119,6 +1120,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
else if ((CMND_SWITCHMODE == command_code) && (index > 0) && (index <= MAX_SWITCHES)) {
if ((payload >= 0) && (payload < MAX_SWITCH_OPTION)) {
Settings.switchmode[index -1] = payload;
GpioSwitchPinMode(index -1);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_NVALUE, command, index, Settings.switchmode[index-1]);
}
Expand Down Expand Up @@ -1412,6 +1414,7 @@ void PublishStatus(uint8_t payload)
{
uint8_t option = STAT;
char stemp[MAX_FRIENDLYNAMES * (sizeof(Settings.friendlyname[0]) +MAX_FRIENDLYNAMES)];
char stemp2[MAX_SWITCHES * 3];

// Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX
if (!strcmp(Settings.mqtt_prefix[0],Settings.mqtt_prefix[1]) && (!payload)) option++; // TELE
Expand All @@ -1426,8 +1429,12 @@ void PublishStatus(uint8_t payload)
for (byte i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s\"%s\"" ), stemp, (i > 0 ? "," : ""), Settings.friendlyname[i]);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS "\":{\"" D_CMND_MODULE "\":%d,\"" D_CMND_FRIENDLYNAME "\":[%s],\"" D_CMND_TOPIC "\":\"%s\",\"" D_CMND_BUTTONTOPIC "\":\"%s\",\"" D_CMND_POWER "\":%d,\"" D_CMND_POWERONSTATE "\":%d,\"" D_CMND_LEDSTATE "\":%d,\"" D_CMND_SAVEDATA "\":%d,\"" D_JSON_SAVESTATE "\":%d,\"" D_CMND_BUTTONRETAIN "\":%d,\"" D_CMND_POWERRETAIN "\":%d}}"),
Settings.module +1, stemp, mqtt_topic, Settings.button_topic, power, Settings.poweronstate, Settings.ledstate, Settings.save_data, Settings.flag.save_state, Settings.flag.mqtt_button_retain, Settings.flag.mqtt_power_retain);
stemp2[0] = '\0';
for (byte i = 0; i < MAX_SWITCHES; i++) {
snprintf_P(stemp2, sizeof(stemp2), PSTR("%s%s%d" ), stemp2, (i > 0 ? "," : ""), Settings.switchmode[i]);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS "\":{\"" D_CMND_MODULE "\":%d,\"" D_CMND_FRIENDLYNAME "\":[%s],\"" D_CMND_TOPIC "\":\"%s\",\"" D_CMND_BUTTONTOPIC "\":\"%s\",\"" D_CMND_POWER "\":%d,\"" D_CMND_POWERONSTATE "\":%d,\"" D_CMND_LEDSTATE "\":%d,\"" D_CMND_SAVEDATA "\":%d,\"" D_JSON_SAVESTATE "\":%d,\"" D_CMND_SWITCHTOPIC "\":\"%s\",\"" D_CMND_SWITCHMODE "\":[%s],\"" D_CMND_BUTTONRETAIN "\":%d,\"" D_CMND_SWITCHRETAIN "\":%d,\"" D_CMND_SENSORRETAIN "\":%d,\"" D_CMND_POWERRETAIN "\":%d}}"),
Settings.module +1, stemp, mqtt_topic, Settings.button_topic, power, Settings.poweronstate, Settings.ledstate, Settings.save_data, Settings.flag.save_state, Settings.switch_topic, stemp2, Settings.flag.mqtt_button_retain, Settings.flag.mqtt_switch_retain, Settings.flag.mqtt_sensor_retain, Settings.flag.mqtt_power_retain);
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS));
}

Expand Down Expand Up @@ -2291,11 +2298,23 @@ void SerialInput()

/********************************************************************************************/

void GpioSwitchPinMode(uint8_t index)
{
if (pin[GPIO_SWT1 +index] < 99) {
// pinMode(pin[GPIO_SWT1 +index], (16 == pin[GPIO_SWT1 +index]) ? INPUT_PULLDOWN_16 : bitRead(switch_no_pullup, index) ? INPUT : INPUT_PULLUP);

uint8_t no_pullup = 0;
if (bitRead(switch_no_pullup, index)) {
no_pullup = (Settings.switchmode[index] < PUSHBUTTON);
}
pinMode(pin[GPIO_SWT1 +index], (16 == pin[GPIO_SWT1 +index]) ? INPUT_PULLDOWN_16 : (no_pullup) ? INPUT : INPUT_PULLUP);
}
}

void GpioInit()
{
uint8_t mpin;
uint8_t key_no_pullup = 0;
uint16_t switch_no_pullup = 0;
mytmplt def_module;

if (!Settings.module || (Settings.module >= MAXMODULE)) {
Expand Down Expand Up @@ -2452,7 +2471,7 @@ void GpioInit()
for (byte i = 0; i < MAX_SWITCHES; i++) {
lastwallswitch[i] = 1; // Init global to virtual switch state;
if (pin[GPIO_SWT1 +i] < 99) {
pinMode(pin[GPIO_SWT1 +i], (16 == pin[GPIO_SWT1 +i]) ? INPUT_PULLDOWN_16 : bitRead(switch_no_pullup, i) ? INPUT : INPUT_PULLUP);
GpioSwitchPinMode(i);
lastwallswitch[i] = digitalRead(pin[GPIO_SWT1 +i]); // Set global now so doesn't change the saved power state on first switch check
}
virtualswitch[i] = lastwallswitch[i];
Expand Down
Loading

0 comments on commit aa45f16

Please sign in to comment.