Comments (2)
Yes indeed this is strange code looking without context. The idea was to set it only, if there is a meaningful value inside, but the if clause seems to be wrong. Based on the branching in my configuration dump it can easily happen that on new introduced variables I get a 0 or a FF. In General the clause is ok.
No, now I r member. This is right because this is only on initialization. Does mean if there is e.g. 5 inside do not change because this is configuration setting , but if it is 0 then it is a init. value that needs to be corrected. The clause should only executed if wrong values at boot time are in the configuration. Let’s. Check where your error is. The IF seems to be ok.
from sonoff-tasmota.
Hi,
I tested and suggested code is ok in that file but in set command there is an error. Divider must be also set there, I suggest the code in sonoff.ino about line 778 (release o)
RtcSettings.pulse_counter[index -1] keeps the value multiply by Settings.pulse_devider[index -1] and huge variable is needed in my case divider 4100 unsigned long that already has ben set
now the command response and sprinf on www shows correct values, may be there is a possibility some how tu keep proper value in RtcSettings.pulse_counter[index -1] as displayed. For saved value the huge value is also stored. Values need to be extended to payload32.
else if ((CMND_COUNTER == command_code) && (index > 0) && (index <= MAX_COUNTERS)) {
if ((data_len > 0) && (pin[GPIO_CNTR1 + index -1] < 99)) {
//stb mod
RtcSettings.pulse_counter[index -1] = payload32 * Settings.pulse_devider[index -1];
Settings.pulse_counter[index -1] = payload32 * Settings.pulse_devider[index -1];
//stb end
}
//stb mod
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_LVALUE, command, index, (RtcSettings.pulse_counter[index -1]/Settings.pulse_devider[index -1]));
//end
}
else if ((CMND_COUNTERTYPE == command_code) && (index > 0) && (index <= MAX_COUNTERS)) {
if ((payload >= 0) && (payload <= 1) && (pin[GPIO_CNTR1 + index -1] < 99)) {
bitWrite(Settings.pulse_counter_type, index -1, payload &1);
RtcSettings.pulse_counter[index -1] = 0;
Settings.pulse_counter[index -1] = 0;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_NVALUE, command, index, bitRead(Settings.pulse_counter_type, index -1));
}
else if (CMND_COUNTERDEBOUNCE == command_code) {
if ((data_len > 0) && (payload16 < 32001)) {
Settings.pulse_counter_debounce = payload16;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.pulse_counter_debounce);
}
//STB mod
else if ((CMND_COUNTERDEVIDER == command_code) && (index > 0) && (index <= MAX_COUNTERS)) {
if (data_len > 0) {
unsigned long _counter;
_counter = Settings.pulse_devider[index -1];
Settings.pulse_devider[index -1] = payload16;
RtcSettings.pulse_counter[index -1] = _counter * Settings.pulse_devider[index -1];
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_NVALUE, command, index, Settings.pulse_devider[index -1]);
}
//end
from sonoff-tasmota.
Related Issues (20)
- SetOption80 1 HangUp the Device HOT 13
- Can´t connect to WIFI after upload your Firmware HOT 2
- SHUTTER50PERCENT not work HOT 7
- Erratic Behaviour when Slow Blinds - includes fix HOT 1
- Dim the lights in the switch? HOT 6
- Shutter dead time support HOT 11
- Vcc in state HOT 3
- Alexa Dimming doesnt work HOT 4
- PCF8574 on master HOT 2
- PCF8574: ports on at startup HOT 9
- MQTT Report during movement HOT 1
- DeepSleep consumption HOT 1
- MQT: TLS connection error: 0 HOT 4
- Calibration 2nd shutter HOT 1
- Shutter with LC-TECH X2 in mode 1 allows changing direction without power removal HOT 5
- MQT: TLS connection error: 0 HOT 1
- Mq sensor
- Sonoff touch TX T3 Us
- upgrading from Sonoff-Tasmota 6.5.0.11 stb-1.5 by Theo Arends HOT 7
- Shutter - inverse mode - slider not correct HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonoff-tasmota.