Skip to content

Add missing cover icons#56

Open
fish1725 wants to merge 1 commit intocustom-cards:masterfrom
fish1725:add_missing_cover_icons
Open

Add missing cover icons#56
fish1725 wants to merge 1 commit intocustom-cards:masterfrom
fish1725:add_missing_cover_icons

Conversation

@fish1725
Copy link

@fish1725 fish1725 commented Feb 6, 2022

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the cover icon mapping to include more device classes and more granular icons for transitional states (opening/closing), aiming to mirror Home Assistant frontend behavior.

Changes:

  • Expand coverIcon to handle additional device_class values (e.g., gate, damper, curtain, shade).
  • Add distinct icons for opening / closing states across multiple cover device classes.
  • Replace the prior fallback (domainIcon("cover", state.state)) with an explicit fallback mapping for cover states.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return "mdi:garage-open";
}
case "gate":
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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.
return open ? "mdi:circle" : "mdi:circle-slice-8";
case "shutter":
return open ? "mdi:window-shutter-open" : "mdi:window-shutter";
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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.
return "mdi:window-shutter-open";
}
case "curtain":
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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 "blind":
return open ? "mdi:blinds-open" : "mdi:blinds";
case "shade":
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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 "window":
return open ? "mdi:window-open" : "mdi:window-closed";
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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.
}
default:
return domainIcon("cover", state.state);
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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.
switch (state.attributes.device_class) {
case "garage":
return open ? "mdi:garage-open" : "mdi:garage";
switch (state) {
Copy link

Copilot AI Feb 21, 2026

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.
@iantrich
Copy link
Member

I've been away far too long, thanks for this. I totally get it if you're not longer involved in this, I haven't touched HA in 4 years, but I like the suggestions and will move forward with them even if you are unable to address the review comments. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants