Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 74 additions & 6 deletions src/cover_icon.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,89 @@
/** Return an icon representing a cover state. */
import { HassEntity } from "home-assistant-js-websocket";
import { domainIcon } from "./domain_icons";

export const coverIcon = (state: HassEntity): string => {
const open = state.state !== "closed";
switch (state.attributes.device_class) {
case "garage":
return open ? "mdi:garage-open" : "mdi:garage";
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the entire HassEntity object (state), but the case labels are strings like "opening"/"closed". This will never match (and should be a TS type error). Switch on state.state instead.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-up-box";
case "closing":
return "mdi:arrow-down-box";
case "closed":
return "mdi:garage";
default:
return "mdi:garage-open";
}
case "gate":
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the entire HassEntity object (state), but the case labels are strings. It should switch on state.state to correctly match "opening"/"closing"/"closed".

Copilot uses AI. Check for mistakes.
case "opening":
case "closing":
return "mdi:gate-arrow-right";
case "closed":
return "mdi:gate";
default:
return "mdi:gate-open";
}
case "door":
return open ? "mdi:door-open" : "mdi:door-closed";
case "damper":
return open ? "mdi:circle" : "mdi:circle-slice-8";
case "shutter":
return open ? "mdi:window-shutter-open" : "mdi:window-shutter";
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the entire HassEntity object (state), but the case labels are strings. It should switch on state.state so the shutter icons can match the cover state.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-up-box";
case "closing":
return "mdi:arrow-down-box";
case "closed":
return "mdi:window-shutter";
default:
return "mdi:window-shutter-open";
}
case "curtain":
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the entire HassEntity object (state) rather than the state string. Switch on state.state so the curtain opening/closing/closed icons work.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-split-vertical";
case "closing":
return "mdi:arrow-collapse-horizontal";
case "closed":
return "mdi:curtains-closed";
default:
return "mdi:curtains";
}
case "blind":
return open ? "mdi:blinds-open" : "mdi:blinds";
case "shade":
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the full HassEntity (state) instead of the state value. Switch on state.state so blind/shade icons match opening/closing/closed.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-up-box";
case "closing":
return "mdi:arrow-down-box";
case "closed":
return "mdi:blinds";
default:
return "mdi:blinds-open";
}
case "window":
return open ? "mdi:window-open" : "mdi:window-closed";
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch is switching on the full HassEntity (state) instead of state.state. As written, none of the string cases will match.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-up-box";
case "closing":
return "mdi:arrow-down-box";
case "closed":
return "mdi:window-closed";
default:
return "mdi:window-open";
}
default:
return domainIcon("cover", state.state);
switch (state) {

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default branch switch is switching on the HassEntity object (state) rather than the entity's state string. Switch on state.state so opening/closing/closed are handled correctly.

Copilot uses AI. Check for mistakes.
case "opening":
return "mdi:arrow-up-box";
case "closing":
return "mdi:arrow-down-box";
case "closed":
return "mdi:window-closed";
default:
return "mdi:window-open";
}
}
};