-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add pressed and released event to allow usage as momentary button #360
base: master
Are you sure you want to change the base?
Conversation
Great stuff, thanks, I'm going to have a look 😊 |
Really looking forward having this feature :D thank you so much Any plans to accept this PR or date to merge it back to master? :) |
This should be ready to merge now, I now use the helpers for it, and added some fixes for later changes of the helpers repository |
Will this be merged? |
+1 |
Me too! |
+1 |
Will this be merged? |
I don't get it, why is this ignored @RomRider ? |
Because I don't have time to test it properly, yet |
Can the community support you somehow? |
I am also looking forward to this as a door opener button, i will do some test when my other PR is accepted! Do i get this correctly, the pressed_action is added because the hold_action would execute the action delayed? |
Not specifically because of that but it can be used that way, hold action gets triggered after you remove your finger from the button. You could use it to move a camera right for as long as you are holding the button |
That's exactly my goal! @indykoning |
Ok, i checked out your branch and build the js file. Copied it to my "config/www" folder. Then i added the file as resource in my Configuration -> Lovelace. I can now add the card on my Dashboard with following configuration:
But the normal action (tap_action) is executed when i release the button, so it seems not to work. What am i doing wrong? When executing the service via developer tools it is working. I also checked the .js file for "release" action and it is present (it is not in the file from master) Any ideas what i am missing? |
This is untested, that's why it's not merged. |
This is a Pull Request and should work. Also i don't think @indykoning did not test this. That is why i am assuming i am doing something wrong. |
Yeah i'm actually using it right now 😉
And you are correct the tap or hold actions will still execute as well since those events are still happening as well of course |
Thanks for the tip, it works with "press_action"!
Well done with your work! |
Looking forward to the release of this! Thank you for developing and merging. |
Since im using this solution now daily i have found a little flaw. You have a custom-button card in lovelace (eg. door opener). Use-Case: Special Use-Case: Can anyone confirm this? Do we also need a move (drag) action? Would be perfect if there is no need to define the drag action, only in the backround the drag action does the same as release. |
Since this MR is from 2020 I am afraid that this will never be merged back. |
This is very good idea and I am looking forward to have it available in HA. However I am not sure how soon this can happen :( |
@Maco65 make sure the new button-card.js is the only file in the directory. I also had to remove/rename the compressed gzip (button-card.js.gz) file. |
@enorfelt thanks for help. In config/www I have only few jpg files and
now, when I click it turns on the light and when I click again it turns it off. |
@Maco65 Please remember to define a resource for your js file |
Did it at the same time as placing js file in |
@CubieMedia you are Star! and I have learned something... |
@indykoning I wan to THANK you for this change. It is so useful for me (I use it to control movement of the camera [it moves as long a button it depressed] and movement of lights). It sound easy, but I could not find a good solution and this SIMPLE solution is EXCELLENT. Thanks! |
I have looked into the code and came up with following Patch to solve this problem. Since i can not upload Patch files, this is renamed to .txt Please test and then we have to get in touch with @RomRider |
|
A Patch file is a technical documentation how code has changed, this can be applied automaticly with your IDE (eg. PyCharm) or manually. Since this are only four changes you can apply them manually if you are not familiar with this kind of work. Look for the filename and line numbers and the lines that start with '-' and '+'. Then rebuild your js file and test. |
Sorry for late response. The challenge for me is that I do not have environment and knowledge to "rebuild js file". Last time it was @PiotrMachowski who did it and I was happy to just place js file in my HA instance. |
I have created a new patch file and the resulting js file into this zip. For me it feels not like good code since i don't know much about web handling and events. Sadly @RomRider seems to be "dead" so this Pull Request will soon die as it is. |
I'm not dead, I have no time ATM |
@RomRider dude, you stopped maintaining this... at least you could merge all the PR's that look promising. shouldn't take you more than an hour. would be fair towards the community. |
Sadly this PR is not ready for merge since there is some event handling missing. But the RePing of RomRider is nice :-) |
Hi, https://github.com/custom-cards/button-card#installation-and-tracking-with-hacs I have similar behavior as @Maco65 is working as normal tap action. |
@maciekelga - it work fine now for me for almost a year now. The challenge is on mobile device where once a while I have to refresh the view in order for my buttons to work. |
I found myself needing this feature. In my dumb (as in not-connected to any network) motorized pool cover the remove, because of safety reasons, only moves (opens or closes) the cover (which is a fairly heavy structure) for as long as you have the button pressed. If you release the button for any reason it stops immediately. I've made the motors smart with ESPHome but I am yet to find a way to make a UI in home assistant that works in a similar safe way. |
As this solution is not 200% stable (in my case it happened that I have released the button and the system still was "thinking" it is pressed (especially on mobile) I think you need to double check if such situation will not create any trouble for your structure. |
even though this might be 'needed' by some of you, it would be appreciated if we'd all show Romrider some courtesy and not 'Hey Dude' him. He didnt merge this for a reason, (not being able to test it properly), and reading all of the issues in this topic with the manual edits, we shouldnt blame but applaud him. For not breaking the most versatile card we have. If anyone of you all is convinced this, or other PR's should be merged, it would be an easy feat to fork this repo, rename it and have a go at it. Dont start complaining when people actually start using it, and expect you to fix and maintain though.... |
@indykoning , thanks for this mod, but... I did all of those but the below card is acting as a toggle card. Can you help with this ? type: custom:button-card ************** update: remove the original button-card.js from hacs **************** |
Closing as this is implemented in the next release. Thanks for the PR and patience :) |
Note: I didn't test all the possibilities/ways of breaking the card with press/release so please report back with bugs in new individual issues. Also I am not responsible if you break your swimming pool with it for eg. or anything else because it doesn't trigger the release action ;) |
Actually, I'm going to revert the change, this creates so much chalenge and breaks so much things (scrolling, button kept on while moving...) |
It's pitty but understandable. |
Will this be continued? |
I am personally using this "test" version (with once a while instability). |
Any news? |
I added two config values to allow a
pressed_action
andrelease_action
to be added to allow this button to be used as a momentary button, calling a service eg: light.turn_on when it is pressed down and calling another service eg: light.turn_off to be called once this button is released.