mirror of https://github.com/arendst/Tasmota.git
Fix Shelly Ghost and Rule sensors
* 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)
This commit is contained in:
parent
bac33345a0
commit
6939d6eead
|
@ -1,5 +1,7 @@
|
|||
/* 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)
|
||||
*
|
||||
* 6.2.1.7 20180925
|
||||
* Remove restart after ntpserver change and force NTP re-sync (#3890)
|
||||
|
|
|
@ -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;
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -2296,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)) {
|
||||
|
@ -2457,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];
|
||||
|
|
|
@ -399,9 +399,9 @@ const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = {
|
|||
HUAFAN_SS,
|
||||
KMC_70011,
|
||||
AILIGHT,
|
||||
WEMOS,
|
||||
PHILIPS,
|
||||
WITTY,
|
||||
PHILIPS
|
||||
WEMOS
|
||||
};
|
||||
|
||||
// Default module settings
|
||||
|
@ -1060,6 +1060,24 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
/*
|
||||
Optionals
|
||||
|
||||
{ "Arilux LC10", // Arilux LC10 (ESP8285), RGBW + RF
|
||||
// https://github.com/arendst/Sonoff-Tasmota/wiki/MagicHome-with-ESP8285
|
||||
// https://www.aliexpress.com/item/DC5-24V-Wireless-WIFI-LED-RGB-Controller-RGBW-Controller-IR-RF-Remote-Control-IOS-Android-for/32827253255.html
|
||||
// https://www.aliexpress.com/item/Wifi-LED-RGB-Controler-DC12V-MIni-Wifi-RGB-RGBW-LED-Controller-for-RGB-RGBW-LED-Strip/32673444047.html
|
||||
GPIO_USER, // GPIO00 Optional Button
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
0,
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor0
|
||||
GPIO_ARIRFRCV, // GPIO04 RF receiver input
|
||||
GPIO_PWM2, // GPIO05 RGB LED Green
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_PWM4, // GPIO13 RGBW LED White
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
GPIO_LED2_INV, // GPIO15 RF receiver control
|
||||
0, 0
|
||||
}
|
||||
|
||||
{ "Xenon 3CH", // Xenon 3CH (ESP8266) - (#1128)
|
||||
0, 0, 0,
|
||||
GPIO_KEY2, // GPIO03 Serial TXD and Optional sensor
|
||||
|
|
|
@ -425,7 +425,7 @@ void RulesEvery50ms()
|
|||
|
||||
void RulesEvery100ms()
|
||||
{
|
||||
if (Settings.rule_enabled) { // Any rule enabled
|
||||
if (Settings.rule_enabled && (uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811)
|
||||
mqtt_data[0] = '\0';
|
||||
int tele_period_save = tele_period;
|
||||
tele_period = 2; // Do not allow HA updates during next function call
|
||||
|
|
Loading…
Reference in New Issue