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
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const en: Translation = {
|
||||
STAY: 'Stay',
|
||||
LEAVE: 'Leave',
|
||||
SCHEDULER: 'Scheduler',
|
||||
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_1: 'Add custom scheduled commands to automate EMS-ESP',
|
||||
SCHEDULER_HELP_2: 'The NTP service needs to be active if using the calendar',
|
||||
SCHEDULE: 'Schedule',
|
||||
TIME: 'Time',
|
||||
TIMER: 'Timer',
|
||||
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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const fr: Translation = {
|
||||
STAY: 'Stay', // TODO translate
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const nl: Translation = {
|
||||
STAY: 'Stay', // TODO translate
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const no: Translation = {
|
||||
STAY: 'Stay', // TODO translate
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const pl: BaseTranslation = {
|
||||
STAY: 'Stay', // TODO translate
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -309,13 +309,16 @@ const sv: Translation = {
|
||||
STAY: 'Stay', // TODO translate
|
||||
LEAVE: 'Leave', // TODO translate
|
||||
SCHEDULER: 'Scheduler', // 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_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
|
||||
SCHEDULE: 'Schedule', // TODO translate
|
||||
TIME: 'Time', // TODO translate
|
||||
TIMER: 'Timer', // 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;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
ToggleButton,
|
||||
MenuItem,
|
||||
ToggleButtonGroup,
|
||||
Checkbox,
|
||||
TextField
|
||||
@@ -27,7 +28,15 @@ import WarningIcon from '@mui/icons-material/Warning';
|
||||
import CancelIcon from '@mui/icons-material/Cancel';
|
||||
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';
|
||||
|
||||
@@ -62,6 +71,8 @@ const SettingsScheduler: FC = () => {
|
||||
const [schedule, setSchedule] = useState<ScheduleItem[]>([emptySchedule]);
|
||||
const [scheduleItem, setScheduleItem] = useState<ScheduleItem>();
|
||||
|
||||
const [ntpAvailable, setNTPavailable] = useState<boolean>(true);
|
||||
|
||||
const [dow, setDow] = useState<string[]>([]);
|
||||
|
||||
function getDayNames() {
|
||||
@@ -136,7 +147,9 @@ const SettingsScheduler: FC = () => {
|
||||
|
||||
const fetchSchedule = useCallback(async () => {
|
||||
try {
|
||||
setOriginalSchedule((await EMSESP.readSchedule()).data);
|
||||
const response = await EMSESP.readSchedule();
|
||||
setNTPavailable(response.data.ntp_available);
|
||||
setOriginalSchedule(response.data.schedule);
|
||||
} catch (error) {
|
||||
setErrorMessage(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
}
|
||||
@@ -222,6 +235,7 @@ const SettingsScheduler: FC = () => {
|
||||
if (schedule) {
|
||||
try {
|
||||
const response = await EMSESP.writeSchedule({
|
||||
ntp_available: ntpAvailable,
|
||||
schedule: schedule
|
||||
.filter((si) => !si.deleted)
|
||||
.map((new_si) => {
|
||||
@@ -406,7 +420,6 @@ const SettingsScheduler: FC = () => {
|
||||
label={LL.DESCRIPTION()}
|
||||
value={scheduleItem.description}
|
||||
fullWidth
|
||||
autoFocus
|
||||
margin="normal"
|
||||
sx={{ width: '60ch' }}
|
||||
onChange={updateValue(setScheduleItem)}
|
||||
@@ -415,6 +428,23 @@ const SettingsScheduler: FC = () => {
|
||||
control={<Checkbox checked={scheduleItem.active} onChange={updateValue(setScheduleItem)} name="active" />}
|
||||
label={LL.ACTIVE()}
|
||||
/>
|
||||
|
||||
{(scheduleItem.flags & ScheduleFlag.SCHEDULE_TIMER) === ScheduleFlag.SCHEDULE_TIMER ? (
|
||||
<ValidatedTextField
|
||||
name="time"
|
||||
label={LL.TIMER()}
|
||||
value={scheduleItem.time}
|
||||
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"
|
||||
@@ -423,6 +453,8 @@ const SettingsScheduler: FC = () => {
|
||||
margin="normal"
|
||||
onChange={updateValue(setScheduleItem)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<TextField
|
||||
name="command"
|
||||
label={LL.COMMAND()}
|
||||
@@ -480,8 +512,8 @@ const SettingsScheduler: FC = () => {
|
||||
{blocker ? <BlockNavigation blocker={blocker} /> : null}
|
||||
<Box mb={2} color="warning.main">
|
||||
<Typography variant="body2">{LL.SCHEDULER_HELP_1()}</Typography>
|
||||
<Typography variant="body2">{LL.SCHEDULER_HELP_2()}</Typography>
|
||||
</Box>
|
||||
{!ntpAvailable && <MessageBox level="warning" message={LL.SCHEDULER_HELP_2()} mt={1} />}
|
||||
{renderSchedule()}
|
||||
{renderEditSchedule()}
|
||||
<Box display="flex" flexWrap="wrap">
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
WriteSensor,
|
||||
WriteAnalog,
|
||||
SensorData,
|
||||
ScheduleItem,
|
||||
Schedule
|
||||
} from './types';
|
||||
|
||||
@@ -97,7 +96,7 @@ export function getCustomizations(): AxiosPromise<void> {
|
||||
return AXIOS.get('/getCustomizations');
|
||||
}
|
||||
|
||||
export function readSchedule(): AxiosPromise<ScheduleItem[]> {
|
||||
export function readSchedule(): AxiosPromise<Schedule> {
|
||||
return AXIOS.get('/getSchedule');
|
||||
}
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ export interface ScheduleItem {
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
ntp_available: boolean;
|
||||
schedule: ScheduleItem[];
|
||||
}
|
||||
|
||||
|
||||
@@ -600,7 +600,9 @@ const emsesp_devicedata_4 = {
|
||||
};
|
||||
|
||||
// SCHEDULE
|
||||
let emsesp_schedule = [
|
||||
let emsesp_schedule = {
|
||||
ntp_available: true,
|
||||
schedule: [
|
||||
{
|
||||
id: '1',
|
||||
active: true,
|
||||
@@ -637,7 +639,8 @@ let emsesp_schedule = [
|
||||
value: '',
|
||||
description: 'auto restart EMS-EPS at 4am every other day'
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
// CUSTOMIZATIONS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user