Skip to content

Commit

Permalink
Merge pull request #172 from matt8707/climate
Browse files Browse the repository at this point in the history
Update button 'climate' modal, closes #22 #85 #93
  • Loading branch information
matt8707 authored Jan 13, 2024
2 parents 08c83e0 + b36a590 commit d377e58
Show file tree
Hide file tree
Showing 71 changed files with 475 additions and 95 deletions.
6 changes: 6 additions & 0 deletions scripts/translations/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def process_dir(_dir, _output, _keys):
("locate", ["ui.dialogs.more_info_control.vacuum.locate"]),
("return_home", ["ui.dialogs.more_info_control.vacuum.return_home"]),
("start_pause", ["ui.dialogs.more_info_control.vacuum.start_pause"]),
("battery", ["ui.dialogs.entity_registry.editor.device_classes.binary_sensor.battery"]),
],
),
( # MEDIA_PLAYER
Expand Down Expand Up @@ -270,6 +271,11 @@ def process_dir(_dir, _output, _keys):
("cooling", ["entity_component", "_", "state_attributes", "hvac_action", "state", "cooling"]),
("fan", ["entity_component", "_", "state_attributes", "hvac_action", "state", "fan"]),
("drying", ["entity_component", "_", "state_attributes", "hvac_action", "state", "drying"]),
("target_temp_low", ["services", "set_temperature", "fields", "target_temp_low", "name"]),
("target_temp_high", ["services", "set_temperature", "fields", "target_temp_high", "name"]),
("both", ["entity_component", "_", "state_attributes", "swing_mode", "state", "both"]),
("horizontal", ["entity_component", "_", "state_attributes", "swing_mode", "state", "horizontal"]),
("vertical", ["entity_component", "_", "state_attributes", "swing_mode", "state", "vertical"]),
],
),
( # DEVICE_TRACKER
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Components/Select.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { lang } from '$lib/Stores';
import { onMount, tick } from 'svelte';
import { onMount } from 'svelte';
import Svelecte from 'svelecte';
import SelectItem from '$lib/Components/SelectItem.svelte';
import { createEventDispatcher } from 'svelte';
Expand Down
8 changes: 0 additions & 8 deletions src/lib/Components/StateLogic.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@
<!-- instead of idle? -->
{$lang('camera')}

<!-- Climate -->
{:else if entity_id && entity_id.split('.')[0] === 'climate'}
{#if state === 'fan_only' || state == 'dry' || state === 'off' || attributes?.hvac_action === 'idle'}
{@html $lang(state) || state}
{:else}
{@html $lang(attributes?.hvac_action) || attributes?.hvac_action}
{/if}

<!-- Weather -->
{:else if entity_id && entity_id.split('.')[0] === 'weather'}
{$lang('weather_' + state?.replace('_', '-')) || state || $lang('unknown')}
Expand Down
29 changes: 15 additions & 14 deletions src/lib/Components/WheelPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,24 @@
</script>

<svelte:document
on:mousedown|preventDefault={handleMouseDown}
on:mouseup={handleMouseUp}
on:mousemove={handleMouseMove}
on:pointerdown={handleMouseDown}
on:pointerup={handleMouseUp}
on:pointermove={handleMouseMove}
on:touchend={() => (touchScrolling = true)}
/>

<div class="wheel">
<button
on:click={() => handleClick('decrease')}
style:cursor={max ? 'unset' : 'pointer'}
style:color={max ? 'rgba(255, 255, 255, 0.1)' : 'white'}
on:click={() => handleClick('increase')}
style:cursor={min ? 'unset' : 'pointer'}
style:color={min ? 'rgba(255, 255, 255, 0.1)' : 'white'}
style:transition="color {$motion}ms ease"
use:Ripple={{
...$ripple,
opacity: max ? '0' : $ripple.opacity
opacity: min ? '0' : $ripple.opacity
}}
>
<Icon icon="mingcute:up-fill" height="none" />
<Icon icon="mingcute:down-fill" height="none" />
</button>

<div
Expand All @@ -202,16 +202,16 @@
</div>

<button
on:click={() => handleClick('increase')}
style:cursor={min ? 'unset' : 'pointer'}
style:color={min ? 'rgba(255, 255, 255, 0.1)' : 'white'}
on:click={() => handleClick('decrease')}
style:cursor={max ? 'unset' : 'pointer'}
style:color={max ? 'rgba(255, 255, 255, 0.1)' : 'white'}
style:transition="color {$motion}ms ease"
use:Ripple={{
...$ripple,
opacity: min ? '0' : $ripple.opacity
opacity: max ? '0' : $ripple.opacity
}}
>
<Icon icon="mingcute:down-fill" height="none" />
<Icon icon="mingcute:up-fill" height="none" />
</button>
</div>

Expand Down Expand Up @@ -262,8 +262,9 @@
}
.wheel {
margin-top: 1.5rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
}
</style>
12 changes: 3 additions & 9 deletions src/lib/Main/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -246,25 +246,19 @@
break;
case 'alarm_control_panel':
openModal(() => import('$lib/Modal/AlarmControlPanelModal.svelte'), {
sel
});
openModal(() => import('$lib/Modal/AlarmControlPanelModal.svelte'), { sel });
break;
case 'lock':
openModal(() => import('$lib/Modal/LockModal.svelte'), { sel });
break;
case 'climate':
openModal(() => import('$lib/Modal/ClimateModal.svelte'), {
selected: sel
});
openModal(() => import('$lib/Modal/ClimateModal.svelte'), { sel });
break;
case 'camera':
openModal(() => import('$lib/Modal/CameraModal.svelte'), {
sel
});
openModal(() => import('$lib/Modal/CameraModal.svelte'), { sel });
break;
case 'media_player':
Expand Down
11 changes: 4 additions & 7 deletions src/lib/Modal/ButtonConfig.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@
.sort()
.map((key) => ({ id: key, label: key }));
$: options_attr = Object.keys(entity.attributes)
.filter((key) => key !== 'friendly_name')
.map((key) => ({
id: key,
label: key
}));
$: options_attr = Object.keys(entity.attributes).map((key) => ({
id: key,
label: key
}));
function set(key: string, event?: any) {
sel = updateObj(sel, key, event);
Expand Down Expand Up @@ -238,7 +236,6 @@
options={options_attr}
placeholder={$lang('state')}
value={sel?.attribute}
clearable={true}
on:change={(event) => {
set('attribute', event);
}}
Expand Down
Loading

0 comments on commit d377e58

Please sign in to comment.