Skip to content
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

Default button actions overrides #183

Merged
merged 9 commits into from
Nov 5, 2021

Conversation

vicfergar
Copy link
Contributor

This PR includes a new configuration option called start_action that can be used to define which service to call when the start button is pressed.

I have updated documentation file too.

This can solve issue #158

@vicfergar vicfergar changed the title Feature/start action Option start action included to customize start button action Feb 7, 2021
@vicfergar vicfergar changed the title Option start action included to customize start button action start-action option included to customize start button action Feb 7, 2021
Copy link
Owner

@denysdovhan denysdovhan left a comment

Choose a reason for hiding this comment

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

I've suggested a few changes. Please, test locally.

src/vacuum-card.js Outdated Show resolved Hide resolved
src/vacuum-card.js Outdated Show resolved Hide resolved
src/vacuum-card.js Outdated Show resolved Hide resolved
src/vacuum-card.js Outdated Show resolved Hide resolved
@denysdovhan denysdovhan added the enhancement New feature or request label Feb 8, 2021
Copy link
Contributor Author

@vicfergar vicfergar left a comment

Choose a reason for hiding this comment

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

Proposed changes included and tested locally. Thanks!

@vicfergar
Copy link
Contributor Author

There is something that maybe should be changed. Differentiate between HandleStart and HandleResume, because probably for most cases only HandleStart must be replaced.

Would you like if I add this distinction and include custom action (resume_action) just in case someone needs to override the default behavior for resume too?

@denysdovhan
Copy link
Owner

@vicfergar yes, I'd like to. Maybe we can also add custom handlers for stop and pause. Grouping them under the prop would be great.

I'd like to call it actions and rename actions to shortcuts, but it's gonna be a breaking change 😞

@vicfergar
Copy link
Contributor Author

vicfergar commented Feb 8, 2021

@denysdovhan I'm agree with that. If breaking change is an issue (I suppose it can be 😄), what about a group called custom_actions or override_actions and rename current actions to shortcuts (while accepting actions as backward compatibility)

Something like:

type: 'custom:vacuum-card'
entity: vacuum.vacuum_cleaner
override_actions:
  start:
    service: xiaomi_miio.vacuum_clean_segment
    service_data:
      entity_id: vacuum.vacuum_cleaner
      segments: [16, 20]
  resume:
    service: script.custom_resume
  pause:
    service: script.custom_pause
  stop:
    service: script.custom_stop
  return_to_base:
    service: script.custom_return_to_base
  localize:
    service: script.custom_localize
shortcuts: #or actions for backward compatibility
  - name: Clean living room
    service: script.clean_living_room
    icon: 'mdi:sofa'

What do you think?

@denysdovhan
Copy link
Owner

denysdovhan commented Feb 9, 2021

We can release a breaking version — this is not a problem. It's relatively easy to check what we have in actions. If it's an object — it's an override for start, stop, etc; if it's an array — it's a list of shortcuts and we should display a deprecation warning and do not render them.

 - New 'actions' option to override default button behavior
 - Old 'actions' option replaced by 'shortcuts' option
 - New waring message included for deprecated option (english and spanish only)
@vicfergar
Copy link
Contributor Author

Hi @denysdovhan I tried to acomplish the proposed solution.

Please let me know if you would like to change something or propose any change if needed 😉

@vicfergar vicfergar changed the title start-action option included to customize start button action Default button actions overrides Apr 6, 2021
@vicfergar
Copy link
Contributor Author

Hi @denysdovhan

Any news on this? I have been using this branch without problems for a while since our last conversation.

README.md Outdated Show resolved Hide resolved
@mikhail5555
Copy link

If its not too big of a feature creep, could you maybe add the option to completely disable the default buttons? (I personally use only selected rooms cleaning which renders that button useless and only prone to misclicks)

@vicfergar vicfergar requested a review from denysdovhan October 4, 2021 06:23
@denysdovhan denysdovhan merged commit 1ac4d93 into denysdovhan:master Nov 5, 2021
@denysdovhan
Copy link
Owner

Thanks for contributing!

github-actions bot pushed a commit that referenced this pull request Nov 5, 2021
# [2.0.0](v1.25.1...v2.0.0) (2021-11-05)

### Features

* Default button actions overrides ([#183](#183)) ([1ac4d93](1ac4d93))

### BREAKING CHANGES

* `actions` are replaced with `shortcuts`

Co-authored-by: Denys Dovhan <[email protected]>
@github-actions
Copy link

github-actions bot commented Nov 5, 2021

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to cociweb/lawn-mower-card that referenced this pull request May 28, 2024
# 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants