Skip to content

Commit c1f3aad

Browse files
committed
add ability to hide default climate options
1 parent 41ebfa1 commit c1f3aad

File tree

2 files changed

+71
-56
lines changed

2 files changed

+71
-56
lines changed

src/app.ts

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -365,56 +365,61 @@ const pageIcons = connect(
365365
}
366366
const config = getConfig() // always re-read in case config has been mutated by config screens, and app page is not refreshed
367367
const customClimates = Object.values(config.customClimates).map((x) => x.name)
368-
quickOptions(customClimates.concat(STANDARD_CLIMATE_OPTIONS), {
369-
title: 'Confirm climate action',
370-
onOptionSelect: (opt) => {
371-
if (opt === 'Cancel') return
372-
let payload = undefined
373-
if (!STANDARD_CLIMATE_OPTIONS.includes(opt)) {
374-
payload = Object.values(config.customClimates).filter((x) => x.name === opt)[0]
375-
}
376-
doAsyncUpdate({
377-
command: 'climate',
378-
bl: bl,
379-
payload: payload
380-
? ({ ...payload, enable: true } as ClimateRequest)
381-
: ({
382-
enable: opt !== 'Off' ? true : false,
383-
frontDefrost: opt === 'Warm' ? true : false,
384-
rearDefrost: opt === 'Warm' ? true : false,
385-
steering: opt === 'Warm' ? true : false,
386-
temp: opt === 'Warm' ? config.climateTempWarm : config.climateTempCold,
387-
durationMinutes: 15,
388-
} as ClimateRequest),
389-
actions: updatingActions,
390-
actionKey: 'climate',
391-
updatingText: payload
392-
? `Starting custom climate ...`
393-
: opt === 'Warm'
394-
? 'Starting pre-heat ...'
395-
: opt === 'Cool'
396-
? 'Starting cool ...'
397-
: 'Stopping climate ...',
398-
successText: payload
399-
? `Custom climate Started!`
400-
: opt === 'Warm'
401-
? 'Climate heating!'
402-
: opt === 'Cool'
403-
? 'Climate cooling!'
404-
: 'Climate stopped!',
405-
failureText: `Failed to ${opt === 'Off' ? 'Stop' : 'Start'} climate!!!`,
406-
successCallback: (data) => {
407-
updateStatus({
408-
...bl.getCachedStatus(),
409-
status: {
410-
...data,
411-
isClimateOn: opt !== 'Off' ? true : false,
412-
},
413-
} as Status)
414-
},
415-
})
368+
quickOptions(
369+
config.hideDefaultClimates && customClimates.length > 0
370+
? customClimates
371+
: customClimates.concat(STANDARD_CLIMATE_OPTIONS),
372+
{
373+
title: 'Confirm climate action',
374+
onOptionSelect: (opt) => {
375+
if (opt === 'Cancel') return
376+
let payload = undefined
377+
if (!STANDARD_CLIMATE_OPTIONS.includes(opt)) {
378+
payload = Object.values(config.customClimates).filter((x) => x.name === opt)[0]
379+
}
380+
doAsyncUpdate({
381+
command: 'climate',
382+
bl: bl,
383+
payload: payload
384+
? ({ ...payload, enable: true } as ClimateRequest)
385+
: ({
386+
enable: opt !== 'Off' ? true : false,
387+
frontDefrost: opt === 'Warm' ? true : false,
388+
rearDefrost: opt === 'Warm' ? true : false,
389+
steering: opt === 'Warm' ? true : false,
390+
temp: opt === 'Warm' ? config.climateTempWarm : config.climateTempCold,
391+
durationMinutes: 15,
392+
} as ClimateRequest),
393+
actions: updatingActions,
394+
actionKey: 'climate',
395+
updatingText: payload
396+
? `Starting custom climate ...`
397+
: opt === 'Warm'
398+
? 'Starting pre-heat ...'
399+
: opt === 'Cool'
400+
? 'Starting cool ...'
401+
: 'Stopping climate ...',
402+
successText: payload
403+
? `Custom climate Started!`
404+
: opt === 'Warm'
405+
? 'Climate heating!'
406+
: opt === 'Cool'
407+
? 'Climate cooling!'
408+
: 'Climate stopped!',
409+
failureText: `Failed to ${opt === 'Off' ? 'Stop' : 'Start'} climate!!!`,
410+
successCallback: (data) => {
411+
updateStatus({
412+
...bl.getCachedStatus(),
413+
status: {
414+
...data,
415+
isClimateOn: opt !== 'Off' ? true : false,
416+
},
417+
} as Status)
418+
},
419+
})
420+
},
416421
},
417-
})
422+
)
418423
},
419424
},
420425
),

src/config.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface Config {
4343
vin: string | undefined
4444
widgetConfig: WidgetConfig
4545
customClimates: CustomClimateConfig[]
46+
hideDefaultClimates: boolean
4647
chargeLimits: ChargeLimitConfig[]
4748
}
4849

@@ -73,6 +74,7 @@ export interface FlattenedConfig {
7374
vin: string | undefined
7475
widgetConfig: WidgetConfig
7576
customClimates: CustomClimateConfig[]
77+
hideDefaultClimates: boolean
7678
chargeLimits: ChargeLimitConfig[]
7779
}
7880

@@ -109,6 +111,7 @@ const DEFAULT_CONFIG = {
109111
allowWidgetRemoteRefresh: false,
110112
carColor: 'white',
111113
manufacturer: 'hyundai',
114+
hideDefaultClimates: false,
112115
customClimates: [],
113116
chargeLimits: [
114117
{
@@ -207,8 +210,9 @@ export async function loadConfigScreen(bl: Bluelink | undefined = undefined) {
207210
promptForUpdate,
208211
allowWidgetRemoteRefresh,
209212
carColor,
210-
manufacturer: manufacturer,
211-
vin: vin,
213+
manufacturer,
214+
vin,
215+
hideDefaultClimates,
212216
}) => {
213217
// read and combine with current saved config as other config screens may have changed settings (custom climates etc)
214218
const config = getConfig()
@@ -232,6 +236,7 @@ export async function loadConfigScreen(bl: Bluelink | undefined = undefined) {
232236
promptForUpdate: promptForUpdate,
233237
manufacturer: manufacturer?.toLowerCase(),
234238
vin: vin ? vin.toUpperCase().trim() : undefined,
239+
hideDefaultClimates: hideDefaultClimates,
235240
},
236241
} as Config
237242
setConfig(newConfig)
@@ -347,11 +352,6 @@ export async function loadConfigScreen(bl: Bluelink | undefined = undefined) {
347352
label: 'Enable debug logging',
348353
isRequired: false,
349354
},
350-
multiCar: {
351-
type: 'checkbox',
352-
label: 'Enable Multi Car Support (see docs at bluelink.andyfase.com',
353-
isRequired: false,
354-
},
355355
promptForUpdate: {
356356
type: 'checkbox',
357357
label: 'Enable prompting for app updates',
@@ -400,6 +400,16 @@ export async function loadConfigScreen(bl: Bluelink | undefined = undefined) {
400400
})
401401
},
402402
},
403+
hideDefaultClimates: {
404+
type: 'checkbox',
405+
label: 'Hide default climate options',
406+
isRequired: false,
407+
},
408+
multiCar: {
409+
type: 'checkbox',
410+
label: 'Enable Multi Car Support',
411+
isRequired: false,
412+
},
403413
},
404414
})(getFlattenedConfig())
405415
}

0 commit comments

Comments
 (0)