Skip to content

Commit

Permalink
Merge pull request #283 from anarion80/issue278
Browse files Browse the repository at this point in the history
Fix for ON states for climate entities #278
  • Loading branch information
matt8707 authored Jan 28, 2024
2 parents d47b47b + d945de8 commit 57ed153
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/Components/StateLogic.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
{@html title}
{/if}

<!-- Climate -->
{:else if getDomain(entity_id) === 'climate' && attributes?.hvac_action}
{$lang(attributes?.hvac_action)}

<!-- Humidifier -->
{:else if getDomain(entity_id) === 'humidifier' && entity?.state === 'on' && attributes?.action}
{$lang('humidifier_' + attributes?.action)}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/Main/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
lang,
motion,
onStates,
climateHvacActionToMode,
ripple,
states
} from '$lib/Stores';
Expand Down Expand Up @@ -71,7 +72,9 @@
// icon is image if extension, e.g. test.png
$: image = icon?.includes('.');
$: stateOn = $onStates?.includes(entity?.state);
$: stateOn = $onStates?.includes(
attributes?.hvac_action ? $climateHvacActionToMode?.[attributes?.hvac_action] : entity?.state
);
/**
* Toggles the state of the specified entity
Expand Down
11 changes: 11 additions & 0 deletions src/lib/Stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ export const onStates = readable([
'gas'
]);

// climate states
export const climateHvacActionToMode = readable<Record<string, string>>({
cooling: 'cool',
drying: 'dry',
fan: 'fan_only',
preheating: 'heat',
heating: 'heat',
idle: 'off',
off: 'off'
});

// drawer
export const drawerSearch = writable<string | undefined>();
export const focusSearch = writable<boolean>(false);
Expand Down

0 comments on commit 57ed153

Please sign in to comment.