mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add NTP check to scheduler
This commit is contained in:
@@ -309,13 +309,16 @@ const de: Translation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default de;
|
export default de;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const en: Translation = {
|
|||||||
STAY: 'Stay',
|
STAY: 'Stay',
|
||||||
LEAVE: 'Leave',
|
LEAVE: 'Leave',
|
||||||
SCHEDULER: 'Scheduler',
|
SCHEDULER: 'Scheduler',
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.',
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP',
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.',
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar',
|
||||||
SCHEDULE: 'Schedule',
|
SCHEDULE: 'Schedule',
|
||||||
TIME: 'Time',
|
TIME: 'Time',
|
||||||
TIMER: 'Timer',
|
TIMER: 'Timer',
|
||||||
WEEKLY: 'Weekly',
|
WEEKLY: 'Weekly',
|
||||||
SCHEDULE_SAVED: 'Schedule updated'
|
SCHEDULE_SAVED: 'Schedule updated',
|
||||||
|
SCHEDULE_TIMER_1: 'on startup',
|
||||||
|
SCHEDULE_TIMER_2: 'every minute',
|
||||||
|
SCHEDULE_TIMER_3: 'every hour'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default en;
|
export default en;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const fr: Translation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default fr;
|
export default fr;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const nl: Translation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nl;
|
export default nl;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const no: Translation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default no;
|
export default no;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const pl: BaseTranslation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default pl;
|
export default pl;
|
||||||
|
|||||||
@@ -309,13 +309,16 @@ const sv: Translation = {
|
|||||||
STAY: 'Stay', // TODO translate
|
STAY: 'Stay', // TODO translate
|
||||||
LEAVE: 'Leave', // TODO translate
|
LEAVE: 'Leave', // TODO translate
|
||||||
SCHEDULER: 'Scheduler', // TODO translate
|
SCHEDULER: 'Scheduler', // TODO translate
|
||||||
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP.', // TODO translate
|
SCHEDULER_HELP_1: 'Add custom scheduled commands to automate EMS-ESP', // TODO translate
|
||||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar.', // TODO translate
|
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar', // TODO translate
|
||||||
SCHEDULE: 'Schedule', // TODO translate
|
SCHEDULE: 'Schedule', // TODO translate
|
||||||
TIME: 'Time', // TODO translate
|
TIME: 'Time', // TODO translate
|
||||||
TIMER: 'Timer', // TODO translate
|
TIMER: 'Timer', // TODO translate
|
||||||
WEEKLY: 'Weekly', // TODO translate
|
WEEKLY: 'Weekly', // TODO translate
|
||||||
SCHEDULE_SAVED: 'Schedule updated' // TODO translate
|
SCHEDULE_SAVED: 'Schedule updated', // TODO translate
|
||||||
|
SCHEDULE_TIMER_1: 'on startup', // TODO translate
|
||||||
|
SCHEDULE_TIMER_2: 'every minute', // TODO translate
|
||||||
|
SCHEDULE_TIMER_3: 'every hour' // TODO translate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default sv;
|
export default sv;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
ToggleButton,
|
ToggleButton,
|
||||||
|
MenuItem,
|
||||||
ToggleButtonGroup,
|
ToggleButtonGroup,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
TextField
|
TextField
|
||||||
@@ -27,7 +28,15 @@ import WarningIcon from '@mui/icons-material/Warning';
|
|||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
import DoneIcon from '@mui/icons-material/Done';
|
import DoneIcon from '@mui/icons-material/Done';
|
||||||
|
|
||||||
import { ButtonRow, FormLoader, BlockFormControlLabel, SectionContent, BlockNavigation } from 'components';
|
import {
|
||||||
|
ValidatedTextField,
|
||||||
|
MessageBox,
|
||||||
|
ButtonRow,
|
||||||
|
FormLoader,
|
||||||
|
BlockFormControlLabel,
|
||||||
|
SectionContent,
|
||||||
|
BlockNavigation
|
||||||
|
} from 'components';
|
||||||
|
|
||||||
import * as EMSESP from './api';
|
import * as EMSESP from './api';
|
||||||
|
|
||||||
@@ -62,6 +71,8 @@ const SettingsScheduler: FC = () => {
|
|||||||
const [schedule, setSchedule] = useState<ScheduleItem[]>([emptySchedule]);
|
const [schedule, setSchedule] = useState<ScheduleItem[]>([emptySchedule]);
|
||||||
const [scheduleItem, setScheduleItem] = useState<ScheduleItem>();
|
const [scheduleItem, setScheduleItem] = useState<ScheduleItem>();
|
||||||
|
|
||||||
|
const [ntpAvailable, setNTPavailable] = useState<boolean>(true);
|
||||||
|
|
||||||
const [dow, setDow] = useState<string[]>([]);
|
const [dow, setDow] = useState<string[]>([]);
|
||||||
|
|
||||||
function getDayNames() {
|
function getDayNames() {
|
||||||
@@ -136,7 +147,9 @@ const SettingsScheduler: FC = () => {
|
|||||||
|
|
||||||
const fetchSchedule = useCallback(async () => {
|
const fetchSchedule = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
setOriginalSchedule((await EMSESP.readSchedule()).data);
|
const response = await EMSESP.readSchedule();
|
||||||
|
setNTPavailable(response.data.ntp_available);
|
||||||
|
setOriginalSchedule(response.data.schedule);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setErrorMessage(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
setErrorMessage(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||||
}
|
}
|
||||||
@@ -222,6 +235,7 @@ const SettingsScheduler: FC = () => {
|
|||||||
if (schedule) {
|
if (schedule) {
|
||||||
try {
|
try {
|
||||||
const response = await EMSESP.writeSchedule({
|
const response = await EMSESP.writeSchedule({
|
||||||
|
ntp_available: ntpAvailable,
|
||||||
schedule: schedule
|
schedule: schedule
|
||||||
.filter((si) => !si.deleted)
|
.filter((si) => !si.deleted)
|
||||||
.map((new_si) => {
|
.map((new_si) => {
|
||||||
@@ -406,7 +420,6 @@ const SettingsScheduler: FC = () => {
|
|||||||
label={LL.DESCRIPTION()}
|
label={LL.DESCRIPTION()}
|
||||||
value={scheduleItem.description}
|
value={scheduleItem.description}
|
||||||
fullWidth
|
fullWidth
|
||||||
autoFocus
|
|
||||||
margin="normal"
|
margin="normal"
|
||||||
sx={{ width: '60ch' }}
|
sx={{ width: '60ch' }}
|
||||||
onChange={updateValue(setScheduleItem)}
|
onChange={updateValue(setScheduleItem)}
|
||||||
@@ -415,14 +428,33 @@ const SettingsScheduler: FC = () => {
|
|||||||
control={<Checkbox checked={scheduleItem.active} onChange={updateValue(setScheduleItem)} name="active" />}
|
control={<Checkbox checked={scheduleItem.active} onChange={updateValue(setScheduleItem)} name="active" />}
|
||||||
label={LL.ACTIVE()}
|
label={LL.ACTIVE()}
|
||||||
/>
|
/>
|
||||||
<TextField
|
|
||||||
name="time"
|
{(scheduleItem.flags & ScheduleFlag.SCHEDULE_TIMER) === ScheduleFlag.SCHEDULE_TIMER ? (
|
||||||
type="time"
|
<ValidatedTextField
|
||||||
label={LL.TIME()}
|
name="time"
|
||||||
value={scheduleItem.time}
|
label={LL.TIMER()}
|
||||||
margin="normal"
|
value={scheduleItem.time}
|
||||||
onChange={updateValue(setScheduleItem)}
|
fullWidth
|
||||||
/>
|
variant="outlined"
|
||||||
|
onChange={updateValue(setScheduleItem)}
|
||||||
|
margin="normal"
|
||||||
|
select
|
||||||
|
>
|
||||||
|
<MenuItem value={'00:00'}>{LL.SCHEDULE_TIMER_1()}</MenuItem>
|
||||||
|
<MenuItem value={'00:01'}>{LL.SCHEDULE_TIMER_2()}</MenuItem>
|
||||||
|
<MenuItem value={'01:00'}>{LL.SCHEDULE_TIMER_3()}</MenuItem>
|
||||||
|
</ValidatedTextField>
|
||||||
|
) : (
|
||||||
|
<TextField
|
||||||
|
name="time"
|
||||||
|
type="time"
|
||||||
|
label={LL.TIME()}
|
||||||
|
value={scheduleItem.time}
|
||||||
|
margin="normal"
|
||||||
|
onChange={updateValue(setScheduleItem)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
name="command"
|
name="command"
|
||||||
label={LL.COMMAND()}
|
label={LL.COMMAND()}
|
||||||
@@ -480,8 +512,8 @@ const SettingsScheduler: FC = () => {
|
|||||||
{blocker ? <BlockNavigation blocker={blocker} /> : null}
|
{blocker ? <BlockNavigation blocker={blocker} /> : null}
|
||||||
<Box mb={2} color="warning.main">
|
<Box mb={2} color="warning.main">
|
||||||
<Typography variant="body2">{LL.SCHEDULER_HELP_1()}</Typography>
|
<Typography variant="body2">{LL.SCHEDULER_HELP_1()}</Typography>
|
||||||
<Typography variant="body2">{LL.SCHEDULER_HELP_2()}</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
|
{!ntpAvailable && <MessageBox level="warning" message={LL.SCHEDULER_HELP_2()} mt={1} />}
|
||||||
{renderSchedule()}
|
{renderSchedule()}
|
||||||
{renderEditSchedule()}
|
{renderEditSchedule()}
|
||||||
<Box display="flex" flexWrap="wrap">
|
<Box display="flex" flexWrap="wrap">
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
WriteSensor,
|
WriteSensor,
|
||||||
WriteAnalog,
|
WriteAnalog,
|
||||||
SensorData,
|
SensorData,
|
||||||
ScheduleItem,
|
|
||||||
Schedule
|
Schedule
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
@@ -97,7 +96,7 @@ export function getCustomizations(): AxiosPromise<void> {
|
|||||||
return AXIOS.get('/getCustomizations');
|
return AXIOS.get('/getCustomizations');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readSchedule(): AxiosPromise<ScheduleItem[]> {
|
export function readSchedule(): AxiosPromise<Schedule> {
|
||||||
return AXIOS.get('/getSchedule');
|
return AXIOS.get('/getSchedule');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ export interface ScheduleItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Schedule {
|
export interface Schedule {
|
||||||
|
ntp_available: boolean;
|
||||||
schedule: ScheduleItem[];
|
schedule: ScheduleItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -600,44 +600,47 @@ const emsesp_devicedata_4 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// SCHEDULE
|
// SCHEDULE
|
||||||
let emsesp_schedule = [
|
let emsesp_schedule = {
|
||||||
{
|
ntp_available: true,
|
||||||
id: '1',
|
schedule: [
|
||||||
active: true,
|
{
|
||||||
flags: 31,
|
id: '1',
|
||||||
time: '07:30',
|
active: true,
|
||||||
cmd: 'hc1/mode',
|
flags: 31,
|
||||||
value: 'day',
|
time: '07:30',
|
||||||
description: 'Turn on central heating in morning'
|
cmd: 'hc1/mode',
|
||||||
},
|
value: 'day',
|
||||||
{
|
description: 'Turn on central heating in morning'
|
||||||
id: '2',
|
},
|
||||||
active: true,
|
{
|
||||||
flags: 31,
|
id: '2',
|
||||||
time: '23:00',
|
active: true,
|
||||||
cmd: 'hc1/mode',
|
flags: 31,
|
||||||
value: 'night',
|
time: '23:00',
|
||||||
description: 'Turn off central heating for the night'
|
cmd: 'hc1/mode',
|
||||||
},
|
value: 'night',
|
||||||
{
|
description: 'Turn off central heating for the night'
|
||||||
id: '3',
|
},
|
||||||
active: true,
|
{
|
||||||
flags: 128,
|
id: '3',
|
||||||
time: '00:01',
|
active: true,
|
||||||
cmd: 'thermostat/hc2/seltemp',
|
flags: 128,
|
||||||
value: '20',
|
time: '00:01',
|
||||||
description: 'Force thermostat temperature to 20 degrees every minute'
|
cmd: 'thermostat/hc2/seltemp',
|
||||||
},
|
value: '20',
|
||||||
{
|
description: 'Force thermostat temperature to 20 degrees every minute'
|
||||||
id: '4',
|
},
|
||||||
active: false,
|
{
|
||||||
flags: 85,
|
id: '4',
|
||||||
time: '04:00',
|
active: false,
|
||||||
cmd: 'system/restart',
|
flags: 85,
|
||||||
value: '',
|
time: '04:00',
|
||||||
description: 'auto restart EMS-EPS at 4am every other day'
|
cmd: 'system/restart',
|
||||||
}
|
value: '',
|
||||||
];
|
description: 'auto restart EMS-EPS at 4am every other day'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
// CUSTOMIZATIONS
|
// CUSTOMIZATIONS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user