mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
This commit is contained in:
34
interface/pnpm-lock.yaml
generated
34
interface/pnpm-lock.yaml
generated
@@ -1117,8 +1117,8 @@ packages:
|
||||
resolution: {integrity: sha512-DLIsRzJVBQu72meAKPkWQOLcujdXT32hwdfnkI1frSiSRMK1MofjKHf+MEx0SB6fjEFXL8fBDv1dKymBlOp4Qw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
caniuse-lite@1.0.30001754:
|
||||
resolution: {integrity: sha512-x6OeBXueoAceOmotzx3PO4Zpt4rzpeIFsSr6AAePTZxSkXiYDUmpypEl7e2+8NCd9bD7bXjqyef8CJYPC1jfxg==}
|
||||
caniuse-lite@1.0.30001755:
|
||||
resolution: {integrity: sha512-44V+Jm6ctPj7R52Na4TLi3Zri4dWUljJd+RDm+j8LtNCc/ihLCT+X1TzoOAkRETEWqjuLnh9581Tl80FvK7jVA==}
|
||||
|
||||
caw@2.0.1:
|
||||
resolution: {integrity: sha512-Cg8/ZSBEa8ZVY9HspcGUYaK63d/bN7rqS3CYCzEGUxuYv6UlmcjzDUz2fCFFHyTvUW5Pk0I+3hkA3iXlIj6guA==}
|
||||
@@ -1225,8 +1225,8 @@ packages:
|
||||
resolution: {integrity: sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
csstype@3.2.1:
|
||||
resolution: {integrity: sha512-98XGutrXoh75MlgLihlNxAGbUuFQc7l1cqcnEZlLNKc0UrVdPndgmaDmYTDDh929VS/eqTZV0rozmhu2qqT1/g==}
|
||||
csstype@3.2.2:
|
||||
resolution: {integrity: sha512-D80T+tiqkd/8B0xNlbstWDG4x6aqVfO52+OlSUNIdkTvmNw0uQpJLeos2J/2XvpyidAFuTPmpad+tUxLndwj6g==}
|
||||
|
||||
currently-unhandled@0.4.1:
|
||||
resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==}
|
||||
@@ -1337,8 +1337,8 @@ packages:
|
||||
duplexer3@0.1.5:
|
||||
resolution: {integrity: sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==}
|
||||
|
||||
electron-to-chromium@1.5.253:
|
||||
resolution: {integrity: sha512-O0tpQ/35rrgdiGQ0/OFWhy1itmd9A6TY9uQzlqj3hKSu/aYpe7UIn5d7CU2N9myH6biZiWF3VMZVuup8pw5U9w==}
|
||||
electron-to-chromium@1.5.254:
|
||||
resolution: {integrity: sha512-DcUsWpVhv9svsKRxnSCZ86SjD+sp32SGidNB37KpqXJncp1mfUgKbHvBomE89WJDbfVKw1mdv5+ikrvd43r+Bg==}
|
||||
|
||||
emoji-regex@8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
@@ -3290,7 +3290,7 @@ snapshots:
|
||||
'@emotion/memoize': 0.9.0
|
||||
'@emotion/unitless': 0.10.0
|
||||
'@emotion/utils': 1.4.2
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
|
||||
'@emotion/sheet@1.4.0': {}
|
||||
|
||||
@@ -3507,7 +3507,7 @@ snapshots:
|
||||
'@popperjs/core': 2.11.8
|
||||
'@types/react-transition-group': 4.4.12(@types/react@19.2.5)
|
||||
clsx: 2.1.1
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
prop-types: 15.8.1
|
||||
react: 19.2.0
|
||||
react-dom: 19.2.0(react@19.2.0)
|
||||
@@ -3533,7 +3533,7 @@ snapshots:
|
||||
'@emotion/cache': 11.14.0
|
||||
'@emotion/serialize': 1.3.3
|
||||
'@emotion/sheet': 1.4.0
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
prop-types: 15.8.1
|
||||
react: 19.2.0
|
||||
optionalDependencies:
|
||||
@@ -3548,7 +3548,7 @@ snapshots:
|
||||
'@mui/types': 7.4.8(@types/react@19.2.5)
|
||||
'@mui/utils': 7.3.5(@types/react@19.2.5)(react@19.2.0)
|
||||
clsx: 2.1.1
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
prop-types: 15.8.1
|
||||
react: 19.2.0
|
||||
optionalDependencies:
|
||||
@@ -3796,7 +3796,7 @@ snapshots:
|
||||
|
||||
'@types/react@19.2.5':
|
||||
dependencies:
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
|
||||
'@types/responselike@1.0.3':
|
||||
dependencies:
|
||||
@@ -4021,8 +4021,8 @@ snapshots:
|
||||
browserslist@4.28.0:
|
||||
dependencies:
|
||||
baseline-browser-mapping: 2.8.28
|
||||
caniuse-lite: 1.0.30001754
|
||||
electron-to-chromium: 1.5.253
|
||||
caniuse-lite: 1.0.30001755
|
||||
electron-to-chromium: 1.5.254
|
||||
node-releases: 2.0.27
|
||||
update-browserslist-db: 1.1.4(browserslist@4.28.0)
|
||||
|
||||
@@ -4080,7 +4080,7 @@ snapshots:
|
||||
|
||||
camelcase@2.1.1: {}
|
||||
|
||||
caniuse-lite@1.0.30001754: {}
|
||||
caniuse-lite@1.0.30001755: {}
|
||||
|
||||
caw@2.0.1:
|
||||
dependencies:
|
||||
@@ -4211,7 +4211,7 @@ snapshots:
|
||||
dependencies:
|
||||
css-tree: 1.1.3
|
||||
|
||||
csstype@3.2.1: {}
|
||||
csstype@3.2.2: {}
|
||||
|
||||
currently-unhandled@0.4.1:
|
||||
dependencies:
|
||||
@@ -4294,7 +4294,7 @@ snapshots:
|
||||
dom-helpers@5.2.1:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.28.4
|
||||
csstype: 3.2.1
|
||||
csstype: 3.2.2
|
||||
|
||||
dom-serializer@1.4.1:
|
||||
dependencies:
|
||||
@@ -4367,7 +4367,7 @@ snapshots:
|
||||
|
||||
duplexer3@0.1.5: {}
|
||||
|
||||
electron-to-chromium@1.5.253: {}
|
||||
electron-to-chromium@1.5.254: {}
|
||||
|
||||
emoji-regex@8.0.0: {}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
Grid,
|
||||
InputAdornment,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Typography
|
||||
} from '@mui/material';
|
||||
|
||||
@@ -193,12 +192,11 @@ const SensorsAnalogDialog = ({
|
||||
label={LL.NAME(0)}
|
||||
value={editItem.n}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="t"
|
||||
label={LL.TYPE(0)}
|
||||
value={editItem.t}
|
||||
@@ -208,11 +206,11 @@ const SensorsAnalogDialog = ({
|
||||
disabled={editItem.s}
|
||||
>
|
||||
{analogTypeMenuItems}
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
{(isCounterOrRate || isFreqType) && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="u"
|
||||
label={LL.UNIT()}
|
||||
value={editItem.u}
|
||||
@@ -222,18 +220,17 @@ const SensorsAnalogDialog = ({
|
||||
disabled={editItem.s}
|
||||
>
|
||||
{uomMenuItems}
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
)}
|
||||
{editItem.t === AnalogType.ADC && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.OFFSET()}
|
||||
value={numberValue(editItem.o)}
|
||||
type="number"
|
||||
sx={{ width: '11ch' }}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -249,13 +246,12 @@ const SensorsAnalogDialog = ({
|
||||
)}
|
||||
{editItem.t === AnalogType.NTC && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.OFFSET()}
|
||||
value={numberValue(editItem.o)}
|
||||
sx={{ width: '11ch' }}
|
||||
type="number"
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -271,13 +267,12 @@ const SensorsAnalogDialog = ({
|
||||
)}
|
||||
{editItem.t === AnalogType.COUNTER && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.STARTVALUE()}
|
||||
value={numberValue(editItem.o)}
|
||||
type="number"
|
||||
sx={{ width: '11ch' }}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -288,13 +283,12 @@ const SensorsAnalogDialog = ({
|
||||
)}
|
||||
{editItem.t === AnalogType.RGB && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={'RGB ' + LL.VALUE(0)}
|
||||
value={numberValue(editItem.o)}
|
||||
type="number"
|
||||
sx={{ width: '11ch' }}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
/>
|
||||
@@ -302,13 +296,12 @@ const SensorsAnalogDialog = ({
|
||||
)}
|
||||
{isCounterOrRate && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="f"
|
||||
label={LL.FACTOR()}
|
||||
value={numberValue(editItem.f)}
|
||||
sx={{ width: '14ch' }}
|
||||
type="number"
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -319,13 +312,12 @@ const SensorsAnalogDialog = ({
|
||||
)}
|
||||
{isDigitalOutGPIO && (
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.VALUE(0)}
|
||||
value={numberValue(editItem.o)}
|
||||
sx={{ width: '11ch' }}
|
||||
type="number"
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -337,21 +329,20 @@ const SensorsAnalogDialog = ({
|
||||
{isDigitalOutNonGPIO && (
|
||||
<>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.VALUE(0)}
|
||||
value={numberValue(editItem.o)}
|
||||
select
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
>
|
||||
<MenuItem value={0}>{LL.OFF()}</MenuItem>
|
||||
<MenuItem value={1}>{LL.ON()}</MenuItem>
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="f"
|
||||
label={LL.POLARITY()}
|
||||
value={editItem.f}
|
||||
@@ -362,10 +353,10 @@ const SensorsAnalogDialog = ({
|
||||
>
|
||||
<MenuItem value={1}>{LL.ACTIVEHIGH()}</MenuItem>
|
||||
<MenuItem value={-1}>{LL.ACTIVELOW()}</MenuItem>
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="u"
|
||||
label={LL.STARTVALUE()}
|
||||
sx={{ width: '15ch' }}
|
||||
@@ -381,19 +372,18 @@ const SensorsAnalogDialog = ({
|
||||
<MenuItem value={2}>
|
||||
{LL.ALWAYS()} {LL.ON()}
|
||||
</MenuItem>
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
{isPWM && (
|
||||
<>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="f"
|
||||
label={LL.FREQ()}
|
||||
value={numberValue(editItem.f)}
|
||||
type="number"
|
||||
variant="outlined"
|
||||
sx={{ width: '11ch' }}
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
@@ -408,13 +398,12 @@ const SensorsAnalogDialog = ({
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.DUTY_CYCLE()}
|
||||
value={numberValue(editItem.o)}
|
||||
type="number"
|
||||
sx={{ width: '11ch' }}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
@@ -432,7 +421,7 @@ const SensorsAnalogDialog = ({
|
||||
{editItem.t === AnalogType.PULSE && (
|
||||
<>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="o"
|
||||
label={LL.POLARITY()}
|
||||
value={editItem.o}
|
||||
@@ -443,16 +432,15 @@ const SensorsAnalogDialog = ({
|
||||
>
|
||||
<MenuItem value={0}>{LL.ACTIVEHIGH()}</MenuItem>
|
||||
<MenuItem value={1}>{LL.ACTIVELOW()}</MenuItem>
|
||||
</TextField>
|
||||
</ValidatedTextField>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
<ValidatedTextField
|
||||
name="f"
|
||||
label="Pulse"
|
||||
value={numberValue(editItem.f)}
|
||||
type="number"
|
||||
sx={{ width: '15ch' }}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
disabled={editItem.s}
|
||||
slotProps={{
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore';
|
||||
import WarningIcon from '@mui/icons-material/Warning';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Checkbox,
|
||||
Grid,
|
||||
@@ -30,6 +33,8 @@ import type { MqttSettingsType } from 'types';
|
||||
import { numberValue, updateValueDirty, useRest } from 'utils';
|
||||
import { createMqttSettingsValidator, validate } from 'validators';
|
||||
|
||||
import { callAction } from '../../api/app';
|
||||
|
||||
const MqttSettings = () => {
|
||||
const {
|
||||
loadData,
|
||||
@@ -52,6 +57,16 @@ const MqttSettings = () => {
|
||||
|
||||
const [fieldErrors, setFieldErrors] = useState<ValidateFieldsError>();
|
||||
|
||||
const sendResetMQTT = useCallback(() => {
|
||||
void callAction({ action: 'resetMQTT' })
|
||||
.then(() => {
|
||||
toast.success('MQTT ' + LL.REFRESH() + ' successful');
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error(String(error.error?.message || 'An error occurred'));
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateFormValue = useMemo(
|
||||
() =>
|
||||
updateValueDirty(
|
||||
@@ -114,6 +129,7 @@ const MqttSettings = () => {
|
||||
<SectionContent>
|
||||
{blocker ? <BlockNavigation blocker={blocker} /> : null}
|
||||
<>
|
||||
<Box display="flex" gap={2} mb={1}>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
@@ -124,6 +140,17 @@ const MqttSettings = () => {
|
||||
}
|
||||
label={LL.ENABLE_MQTT()}
|
||||
/>
|
||||
{data.enabled && (
|
||||
<Button
|
||||
startIcon={<SettingsBackupRestoreIcon />}
|
||||
color="secondary"
|
||||
variant="outlined"
|
||||
onClick={sendResetMQTT}
|
||||
>
|
||||
{LL.REFRESH() + ' MQTT'}
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
<Grid container spacing={2} rowSpacing={0}>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
|
||||
@@ -21,7 +21,16 @@ const ValidatedTextField: FC<ValidatedTextFieldProps> = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
<TextField error={!!errors} {...rest} aria-label="Error" />
|
||||
<TextField
|
||||
error={!!errors}
|
||||
{...rest}
|
||||
aria-label="Error"
|
||||
slotProps={{
|
||||
inputLabel: {
|
||||
style: rest.disabled ? { color: 'grey' } : undefined
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{errors?.map((e) => (
|
||||
<FormHelperText key={e.message} sx={{ color: 'rgb(250, 95, 84)' }}>
|
||||
{e.message}
|
||||
|
||||
@@ -5106,6 +5106,10 @@ router
|
||||
// upload URL
|
||||
console.log('upload File from URL', content.param);
|
||||
return status(200);
|
||||
} else if (action === 'resetMQTT') {
|
||||
// reset MQTT
|
||||
console.log('resetting MQTT...');
|
||||
return status(200);
|
||||
}
|
||||
}
|
||||
return status(404); // cmd not found
|
||||
|
||||
@@ -167,7 +167,7 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event) {
|
||||
bool MqttSettingsService::configureMqtt() {
|
||||
// disconnect if already connected
|
||||
if (_mqttClient->connected()) {
|
||||
emsesp::EMSESP::logger().info("Disconnecting to configure");
|
||||
// emsesp::EMSESP::logger().info("Disconnecting to configure");
|
||||
_mqttClient->disconnect(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -321,8 +321,12 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
||||
LOG_DEBUG("Packet %d sent successful", packetId);
|
||||
}
|
||||
|
||||
// called when MQTT settings have changed via the Web forms
|
||||
// called when MQTT settings have changed via the MQTT Settings or Application Settings Web pages
|
||||
void Mqtt::reset_mqtt() {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mqttClient_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,6 +195,9 @@ void WebStatusService::action(AsyncWebServerRequest * request, JsonVariant json)
|
||||
ok = uploadURL(param.c_str());
|
||||
} else if (action == "systemStatus" && is_admin) {
|
||||
ok = setSystemStatus(param.c_str());
|
||||
} else if (action == "resetMQTT" && is_admin) {
|
||||
emsesp::EMSESP::mqtt_.reset_mqtt();
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
|
||||
|
||||
Reference in New Issue
Block a user