added shower trigger and coldshot times - #436

This commit is contained in:
Proddy
2022-05-01 22:59:35 +02:00
parent 270b81fafd
commit 5e9e995e4b
14 changed files with 155 additions and 89 deletions

View File

@@ -343,11 +343,6 @@ const SettingsApplication: FC = () => {
label="Convert temperature values to Fahrenheit"
disabled={saving}
/>
<BlockFormControlLabel
control={<Checkbox checked={data.low_clock} onChange={updateFormValue} name="low_clock" />}
label="Underclock CPU speed"
disabled={saving}
/>
<BlockFormControlLabel
control={<Checkbox checked={data.notoken_api} onChange={updateFormValue} name="notoken_api" />}
label="Bypass Access Token authorization on API calls"
@@ -358,6 +353,11 @@ const SettingsApplication: FC = () => {
label="Enable Read only mode (blocks all outgoing EMS Tx write commands)"
disabled={saving}
/>
<BlockFormControlLabel
control={<Checkbox checked={data.low_clock} onChange={updateFormValue} name="low_clock" />}
label="Underclock CPU speed"
disabled={saving}
/>
<Grid container spacing={0} direction="row" justifyContent="flex-start" alignItems="flex-start">
<BlockFormControlLabel
control={<Checkbox checked={data.shower_timer} onChange={updateFormValue} name="shower_timer" />}
@@ -367,8 +367,36 @@ const SettingsApplication: FC = () => {
<BlockFormControlLabel
control={<Checkbox checked={data.shower_alert} onChange={updateFormValue} name="shower_alert" />}
label="Enable Shower Alert"
disabled={saving}
disabled={!data.shower_timer}
/>
{data.shower_alert && (
<>
<Grid item xs={2}>
<ValidatedTextField
fieldErrors={fieldErrors}
name="shower_alert_trigger"
label="Trigger Time (minutes)"
variant="outlined"
value={data.shower_alert_trigger}
type="number"
onChange={updateFormValue}
disabled={!data.shower_timer}
/>
</Grid>
<Grid item xs={2}>
<ValidatedTextField
fieldErrors={fieldErrors}
name="shower_alert_coldshot"
label="Cold Shot Time (seconds)"
variant="outlined"
value={data.shower_alert_coldshot}
type="number"
onChange={updateFormValue}
disabled={!data.shower_timer}
/>
</Grid>
</>
)}
</Grid>
<Typography sx={{ pt: 2 }} variant="h6" color="primary">
Formatting Options

View File

@@ -9,6 +9,8 @@ export interface Settings {
master_thermostat: number;
shower_timer: boolean;
shower_alert: boolean;
shower_alert_coldshot: number;
shower_alert_trigger: number;
rx_gpio: number;
tx_gpio: number;
telnet_enabled: boolean;
@@ -41,8 +43,8 @@ export enum busConnectionStatus {
export interface Stat {
id: string; // name
s: number; // success
f: number; // fail
q: number; // quality
f: number; // fail
q: number; // quality
}
export interface Status {
status: busConnectionStatus;

View File

@@ -40,5 +40,9 @@ export const createSettingsValidator = (settings: Settings) =>
{ required: true, message: 'Mark interval is required' },
{ type: 'number', min: 0, max: 10, message: 'Port must be between 0 and 10' }
]
}),
...(settings.shower_alert && {
shower_alert_trigger: [{ type: 'number', min: 1, max: 20, message: 'Time must be between 1 and 20 minutes' }],
shower_alert_coldshot: [{ type: 'number', min: 1, max: 10, message: 'Time must be between 1 and 10 seconds' }]
})
});