-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure getAttributes().status is always string #702
Ensure getAttributes().status is always string #702
Conversation
After upgrading to Home Assistant 2024.2.4, vacuum-card didn't render due to null reference. The error shown on the console: Uncaught (in promise) TypeError: Cannot read properties of null (reading 'toLowerCase') at qr.renderStatus (vacuum-card.js?hacstag=261291295280:4:14674) at qr.render (vacuum-card.js?hacstag=261291295280:4:17680) at qr.update (vacuum-card.js?hacstag=261291295280:1:15173) at qr.performUpdate (vacuum-card.js?hacstag=261291295280:1:6493) at qr.scheduleUpdate (vacuum-card.js?hacstag=261291295280:1:6140) at qr._$Ej (vacuum-card.js?hacstag=261291295280:1:6048) Based on the types, both `status` and `state` attributes can be undefined, while the `state` on the entity itself always has a string value. By reorganizing the return value of `getAttributes`, we ensure the derived `status` won't get overwritten by an undefined `entity.attributes.status`.
Thanks for a fix! |
It appears this fixes the bug I created yesterday #714 can we get a release and do I need to close the bug to this PR? |
@denysdovhan I think you need to release a new version so it can be installed/upgraded trough HACS |
Yeah i was just about to post here that we need a release for people to get automated updates. |
No pressure, just putting something under attention which might have been overseen. Using a forked repository as a quick fix is not a sustainable solution imho, plenty of people will forget to revert back to the original repository once a new release is made and who's going to guarantee that the fork will be maintained? Better to just download the master zip file and upload the contents to the |
@rrooggiieerr It won't be maintained but it will exist at least until a fixed version will be released as I'm using it myself. I recommend everyone using it to subscribe to release notifications for this repo to know when to change it back. |
## [2.8.1](v2.8.0...v2.8.1) (2024-03-13) ### Bug Fixes * Ensure getAttributes().status is always string ([#702](#702)) ([a25f254](a25f254)) * remove some conditions for release ([7945494](7945494)) * Update hu.json ([#605](#605)) ([1a92e99](1a92e99)) * Update ru.json ([#602](#602)) ([733ce63](733ce63)) * Updates to Finnish (fi) translation ([#608](#608)) ([584e19f](584e19f))
🎉 This PR is included in version 2.8.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# 1.0.0 (2024-05-28) ### Bug Fixes * "Encontrar" replaced by "Localizar" as a more adequate translation ([649162c](649162c)) * add and translate missing states ([denysdovhan#231](https://github.com/cociweb/lawn-mower-card/issues/231)) ([8186565](8186565)) * Add image-rendering optimize-contrast in map ([denysdovhan#225](https://github.com/cociweb/lawn-mower-card/issues/225)) ([e020983](e020983)) * Add pt.json in localize.json ([denysdovhan#258](https://github.com/cociweb/lawn-mower-card/issues/258)) ([edf33ad](edf33ad)) * Add sources for German ([denysdovhan#210](https://github.com/cociweb/lawn-mower-card/issues/210)) ([7389324](7389324)) * Add state ""docked" in ru.json ([denysdovhan#205](https://github.com/cociweb/lawn-mower-card/issues/205)) ([93726f4](93726f4)) * Added states for Deebot N79; including auto, spot, and edge. ([denysdovhan#206](https://github.com/cociweb/lawn-mower-card/issues/206)) ([5b18b3f](5b18b3f)) * Adding missing status in HE & Fix status location for RTL languages ([denysdovhan#232](https://github.com/cociweb/lawn-mower-card/issues/232)) ([07ebe3e](07ebe3e)) * bump ha-template ([031bd3b](031bd3b)) * circular progress ([4263164](4263164)) * compact view menu ([5c30871](5c30871)) * Corrected a typo in polish translation ([denysdovhan#223](https://github.com/cociweb/lawn-mower-card/issues/223)) ([cf44a7a](cf44a7a)) * Czech translation update ([denysdovhan#324](https://github.com/cociweb/lawn-mower-card/issues/324)) ([0bf94d8](0bf94d8)) * **deps:** fix stale ha-tempalte bundle ([9548c11](9548c11)) * duplicated in localize ([ae5c993](ae5c993)) * Ensure getAttributes().status is always string ([denysdovhan#702](https://github.com/cociweb/lawn-mower-card/issues/702)) ([a25f254](a25f254)) * Fix `getCardSize()` ([denysdovhan#222](https://github.com/cociweb/lawn-mower-card/issues/222)) ([3e8c4fc](3e8c4fc)) * fix broken ui in editor ([3108530](3108530)) * fix dropdown overflow ([9c02c46](9c02c46)), closes [denysdovhan#365](https://github.com/cociweb/lawn-mower-card/issues/365) * fix german translation ([denysdovhan#283](https://github.com/cociweb/lawn-mower-card/issues/283)) ([777939a](777939a)) * Fix hovering labels for ha-icon-buttons ([denysdovhan#372](https://github.com/cociweb/lawn-mower-card/issues/372)) ([76780e4](76780e4)) * fix problem with ha-template dep ([e6154c7](e6154c7)) * fix toolbar icon centering ([0a53a02](0a53a02)) * HA 2022.3.x ([043b622](043b622)) * ha-button-icon issue ([denysdovhan#278](https://github.com/cociweb/lawn-mower-card/issues/278)) ([32dd911](32dd911)) * he translation ([denysdovhan#265](https://github.com/cociweb/lawn-mower-card/issues/265)) ([0e9c796](0e9c796)) * missing , in ru.json ([c627c85](c627c85)) * More keys for Ukrainian and English ([112072f](112072f)) * no implicit any ([429426e](429426e)) * not rendering falsy values in stats. fix [denysdovhan#373](https://github.com/cociweb/lawn-mower-card/issues/373) ([df278f9](df278f9)) * Polish translation ([denysdovhan#308](https://github.com/cociweb/lawn-mower-card/issues/308)) ([37c3bd0](37c3bd0)) * problem with replacing pkg version ([851f0a2](851f0a2)) * **readme:** Add notice about Ukraine ([03d4799](03d4799)) * regeneratorRuntime is not defined. fix [denysdovhan#374](https://github.com/cociweb/lawn-mower-card/issues/374) ([65382d3](65382d3)) * remove comment. triger semantic release ([218000b](218000b)) * remove some conditions for release ([7945494](7945494)) * Remove unused @semantic-release/changelog ([9638b30](9638b30)) * returning key translation in ru.json ([denysdovhan#209](https://github.com/cociweb/lawn-mower-card/issues/209)) ([e67c495](e67c495)) * Russian translation.json ([denysdovhan#285](https://github.com/cociweb/lawn-mower-card/issues/285)) ([c101dd8](c101dd8)) * Spanish translation ([denysdovhan#186](https://github.com/cociweb/lawn-mower-card/issues/186)) ([1a68059](1a68059)) * The websocket command 'camera_thumbnail' has been deprecated. ([denysdovhan#201](https://github.com/cociweb/lawn-mower-card/issues/201)) ([f4a5e97](f4a5e97)) * untranspiled ?? operator ([64c8f71](64c8f71)) * Update and add missing in pl.json ([denysdovhan#299](https://github.com/cociweb/lawn-mower-card/issues/299)) ([85b06e8](85b06e8)) * Update cs.json ([denysdovhan#368](https://github.com/cociweb/lawn-mower-card/issues/368)) ([84344c6](84344c6)) * Update fr with missing field ([denysdovhan#226](https://github.com/cociweb/lawn-mower-card/issues/226)) ([7e8273a](7e8273a)) * Update German translation ([denysdovhan#674](https://github.com/cociweb/lawn-mower-card/issues/674)) ([025e9d8](025e9d8)) * update german translations for deebot vacuums ([denysdovhan#305](https://github.com/cociweb/lawn-mower-card/issues/305)) ([d8d5261](d8d5261)) * Update he.json ([denysdovhan#219](https://github.com/cociweb/lawn-mower-card/issues/219)) ([0b9a473](0b9a473)) * Update hu.json ([denysdovhan#605](https://github.com/cociweb/lawn-mower-card/issues/605)) ([1a92e99](1a92e99)) * Update locate icon to be aligned with vacuum card ([denysdovhan#182](https://github.com/cociweb/lawn-mower-card/issues/182)) ([3e45131](3e45131)), closes [denysdovhan#136](https://github.com/cociweb/lawn-mower-card/issues/136) * Update ru.json ([denysdovhan#602](https://github.com/cociweb/lawn-mower-card/issues/602)) ([733ce63](733ce63)) * Update Ukrainian translation ([denysdovhan#262](https://github.com/cociweb/lawn-mower-card/issues/262)) ([a6aa0fe](a6aa0fe)) * Updated polish translation ([denysdovhan#734](https://github.com/cociweb/lawn-mower-card/issues/734)) ([b7559ea](b7559ea)) * Updated pt translation ([denysdovhan#672](https://github.com/cociweb/lawn-mower-card/issues/672)) ([763fa40](763fa40)) * Updates to Finnish (fi) translation ([denysdovhan#608](https://github.com/cociweb/lawn-mower-card/issues/608)) ([584e19f](584e19f)) * use corrent branch name in release workflow ([bd87a10](bd87a10)) * Use default lit element in postcss-lit ([0828c08](0828c08)) * wrap actions ([denysdovhan#208](https://github.com/cociweb/lawn-mower-card/issues/208)) ([9003941](9003941)) ### Features * Add @semantic-release/git for updating version in the repo ([4fa126d](4fa126d)) * add ability to combine attribute and entity_id in stats ([e9d8667](e9d8667)) * add image entities as map entities ([15353d3](15353d3)) * Add Japanese Translation ([denysdovhan#719](https://github.com/cociweb/lawn-mower-card/issues/719)) ([bcba901](bcba901)) * Add norsk nynorsk (Norwegian) ([denysdovhan#199](https://github.com/cociweb/lawn-mower-card/issues/199)) ([73288b6](73288b6)) * Add romanian language ([denysdovhan#242](https://github.com/cociweb/lawn-mower-card/issues/242)) ([a5096ab](a5096ab)) * Add semantic release ([22ef139](22ef139)) * Add Traditional Chinese ([denysdovhan#196](https://github.com/cociweb/lawn-mower-card/issues/196)) ([c1ad452](c1ad452)) * add translation to simplified chinese ([denysdovhan#321](https://github.com/cociweb/lawn-mower-card/issues/321)) ([f4b50d3](f4b50d3)) * Add Vietnamese ([denysdovhan#203](https://github.com/cociweb/lawn-mower-card/issues/203)) ([50e5fe6](50e5fe6)) * Added brazilian portuguese language support ([denysdovhan#336](https://github.com/cociweb/lawn-mower-card/issues/336)) ([7d9f04f](7d9f04f)) * Added Catalan translation ([denysdovhan#190](https://github.com/cociweb/lawn-mower-card/issues/190)) ([34de65a](34de65a)) * Added finnish translation ([denysdovhan#173](https://github.com/cociweb/lawn-mower-card/issues/173)) ([e6fc812](e6fc812)) * Added lithuanian translation ([denysdovhan#215](https://github.com/cociweb/lawn-mower-card/issues/215)) ([f35cbe2](f35cbe2)) * Default button actions overrides ([denysdovhan#183](https://github.com/cociweb/lawn-mower-card/issues/183)) ([1ac4d93](1ac4d93)) * Fix color compatibility and add templates ([denysdovhan#353](https://github.com/cociweb/lawn-mower-card/issues/353)) ([4a03d0d](4a03d0d)) * **i18n:** add actions_array warn in Ukrainan ([ad05f3c](ad05f3c)) * New translations added for ES. ([denysdovhan#271](https://github.com/cociweb/lawn-mower-card/issues/271)) ([690fb86](690fb86)) * print version in console ([0a7e447](0a7e447)) * provide value inside value_template ([7a44cc5](7a44cc5)) * run semantic-release on Ci ([c13cb7b](c13cb7b)) * Updated Ukrainian translation ([denysdovhan#264](https://github.com/cociweb/lawn-mower-card/issues/264)) ([fd218b0](fd218b0)) ### BREAKING CHANGES * `actions` are replaced with `shortcuts` Co-authored-by: Denys Dovhan <[email protected]>
After upgrading to Home Assistant 2024.2.4, vacuum-card didn't
render due to null reference. The error shown on the console:
Based on the types, both
status
andstate
attributes can be undefined,while the
state
on the entity itself always has a string value. By reorganizingthe return value of
getAttributes
, we ensure the derivedstatus
won't getoverwritten by an undefined
entity.attributes.status
.Fixes #699.
Aside: I had difficulty getting the actual change in a separate commit as the precommit hook reformatted the file every time. I've included the formatting in a separate commit. I noticed running
npm run format
would also format other files as well.