Merge remote-tracking branch 'origin/dev' into main

This commit is contained in:
proddy
2020-09-14 11:06:23 +02:00
3 changed files with 12 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ import MenuItem from '@material-ui/core/MenuItem';
import { ENDPOINT_ROOT } from '../api'; import { ENDPOINT_ROOT } from '../api';
import { restController, RestControllerProps, RestFormLoader, RestFormProps, FormActions, FormButton, BlockFormControlLabel, SectionContent } from '../components'; import { restController, RestControllerProps, RestFormLoader, RestFormProps, FormActions, FormButton, BlockFormControlLabel, SectionContent } from '../components';
import { isIP, isHostname, or } from '../validators'; import { isIP, isHostname, or, optional } from '../validators';
import { EMSESPSettings } from './EMSESPtypes'; import { EMSESPSettings } from './EMSESPtypes';
@@ -19,7 +19,7 @@ type EMSESPSettingsControllerProps = RestControllerProps<EMSESPSettings>;
class EMSESPSettingsController extends Component<EMSESPSettingsControllerProps> { class EMSESPSettingsController extends Component<EMSESPSettingsControllerProps> {
componentDidMount() { componentDidMount() {
ValidatorForm.addValidationRule('isIPOrHostname', or(isIP, isHostname)); ValidatorForm.addValidationRule('isIPOrHostname', optional(or(isIP, isHostname)));
this.props.loadData(); this.props.loadData();
} }

View File

@@ -106,8 +106,12 @@ void Sensors::loop() {
case TYPE_DS18S20: case TYPE_DS18S20:
case TYPE_DS1822: case TYPE_DS1822:
case TYPE_DS1825: case TYPE_DS1825:
found_.emplace_back(addr); float f;
found_.back().temperature_c = get_temperature_c(addr); f = get_temperature_c(addr);
if ((f != NAN) && (f >= -55) && (f <= 125)) {
found_.emplace_back(addr);
found_.back().temperature_c = f;
}
/* /*
// comment out for debugging // comment out for debugging
@@ -220,7 +224,7 @@ float Sensors::get_temperature_c(const uint8_t addr[]) {
break; break;
} }
} }
uint32_t raw = (raw_value * 625 + 500) / 1000; // round to 0.1 uint32_t raw = ((uint32_t)raw_value * 625 + 500) / 1000; // round to 0.1
return (float)raw / 10; return (float)raw / 10;
#else #else
return NAN; return NAN;

View File

@@ -633,7 +633,6 @@ bool System::check_upgrade() {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
Serial.begin(115200); Serial.begin(115200);
Serial.println(F("FS is Littlefs")); Serial.println(F("FS is Littlefs"));
Serial.flush();
Serial.end(); Serial.end();
#endif #endif
return false; return false;
@@ -649,9 +648,11 @@ bool System::check_upgrade() {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
Serial.begin(115200); Serial.begin(115200);
Serial.println(F("No old SPIFFS found!")); Serial.println(F("No old SPIFFS found!"));
Serial.flush();
Serial.end(); Serial.end();
#endif #endif
// if there is neither SPIFFS or LittleFS we can assume the ESP8266 has been erased
l_cfg.setAutoFormat(true); // reset to normal behaviour
LittleFS.setConfig(l_cfg);
return false; return false;
} }