Skip to content

Fix stateIcon passing wrong arguments to binarySensorIcon#91

Open
iantrich with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-broken-stateicon-function
Open

Fix stateIcon passing wrong arguments to binarySensorIcon#91
iantrich with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-broken-stateicon-function

Conversation

Copilot AI commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

binarySensorIcon has signature (state?: string, stateObj?: HassEntity), but stateIcon was calling it as binarySensorIcon(hassEntity) — passing the full entity as the state string. This meant device_class was never resolved, so all binary sensors fell through to the default icon.

Changes

  • src/state_icon.ts: Wrap binarySensorIcon in the domainIcons map with an adapter that correctly destructures the entity:
    // Before
    binary_sensor: binarySensorIcon,
    
    // After
    binary_sensor: (stateObj: HassEntity) => binarySensorIcon(stateObj.state, stateObj),
  • test/icons.test.ts: Add stateIcon regression tests for binary_sensor with a device_class in both on/off states.
Original prompt

This section details on the original issue you should resolve

<issue_title>Broken "stateIcon" function</issue_title>
<issue_description>Six months ago, changes were made to the project (specifically in this commit), they broke the "stateIcon" function, so the second argument is not passed for binary_sensor and the device type is now not determined

JonahKr pls fix your code</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…object correctly

Co-authored-by: iantrich <1287159+iantrich@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix broken stateIcon function for binary_sensor Fix stateIcon passing wrong arguments to binarySensorIcon Feb 27, 2026
@iantrich iantrich marked this pull request as ready for review February 27, 2026 17:21
@iantrich

Copy link
Copy Markdown
Member

cc @JonahKr

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.

Broken "stateIcon" function

2 participants